6

I'm running 12.04

I have two files

/usr/bin/uim-tomoe-gtk  
~/bin/uim-tomoe-gtk

the first is the tomoe kanji program
the second is a script that runs kanjipad instead

#!/bin/bash
exec kanjipad $@
exit 0

I expect to now be able to type uim-tomoe-gtk into the terminal and get my kanjipad application to start up. But the uim-tomoe-gtk program comes up instead.

What am I doing wrong or what information do I need to provide?

2 Answers 2

8

There are two things you need to do.

Firstly, the shell will not get ~/bin/ in $PATH when you login if it does not exist. You will have to log out and log in again after creating the directory, or start a new login shell with:

/bin/bash -l

or add ~/bin to your path manually with:

export PATH=/home/user/bin:$PATH

Secondly, the shell keeps a cache of where programs are located. If you create a script in ~/bin/ (or /usr/local/) which shadows something in /usr/ then you must manually update the cache. You can clear it completely with this command which should do the trick:

hash -r
2

The problem is probably that /usr/bin is ahead of ~/bin in your PATH, or ~/bin isn't in your PATH at all.

To fix, put this line at the end of your .bash_profile file:

export PATH=~/bin:$PATH

Be warned, though, that this will do the same thing for other scripts in your ~/bin folder. For example if you have /usr/bin/example_command and ~/bin/example_command, the command in your home directory will take precedence.

Honestly, I would just rename the script.

1
  • 2
    ~/bin appears before /usr/bin in the standard Ubuntu configuration, but only if the directory exists at login time (see my answer). Apr 22, 2013 at 0:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .