When I understand you correct you do want to call your scripts by name from anywhere and not by providing the path to the script like:
./script
when you are in the directory where the script is, or
/home/yourusername/scriptdir/script
when your working directory is somewhere else,
but just do
script
Correct? For this the path to your script must be in your PATH environment variable. To see what is in your PATH now, do:
echo ${PATH}
To add a directory do:
PATH="${PATH}:<scriptdir>"
where is the directory (absolute, starting with /) where your script reside.
Normale the directory bin in your home directory is a good place to use. So:
PATH="${PATH}:/home/yourusername/bin"
is then what should be added.
Check the PATH by doing
echo ${PATH}
again.
Now you do not want to do this every time you go to a terminal. So add the line to your .bashrc, it will then be executed every time you start bash.
PS Many people will not use the {…} around the variable name, but I prefer this notation.
@swerdna: of course, I should have mentioned that.
@Ru_Nez: in your home directory there is a file named .bashrc (mind the . ).
It is executed when you start bash, thus also when you open a terminal with bash inside. In this file you can place statements you want to be executed at that moment in time.
So edit .bashrc and add the statement PATH="…" to it.
Check by opening a new terminal and echo $PATH.
Or, just move your script into the bin directory. As swerdna already pointed out, you do not need to change PATH in that case because $HOME/bin is already there.
Or if you do not want to move your script just create a symlink to the
script and place that symlink in ~/bin (~ == your home directory).
Good luck.
hcvv wrote:
> @swerdna: of course, I should have mentioned that.
>
> @Ru_Nez: in your home directory there is a file named .bashrc (mind the
> . ).
> It is executed when you start bash, thus also when you open a terminal
> with bash inside. In this file you can place statements you want to be
> executed at that moment in time.
>
> So edit .bashrc and add the statement PATH="…" to it.
>
> Check by opening a new terminal and echo $PATH.
>
> Or, just move your script into the bin directory. As swerdna already
> pointed out, you do not need to change PATH in that case because
> $HOME/bin is already there.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org