Bash – How to avoid the ./ when executing a shell script

bashpathshell

I used to know a way to run my shell scripts just by typing there name as long as there were in my home folder or desktop. I hate having to type ./myscript.sh. I would like to be able to type just myscript.sh. How can I fix my terminal to do this?

I'm using GNOME Terminal and Ubuntu 9.04.

Best Answer

It's a bad idea to put the current directory into your path. Move your scripts that you want to frequently run into ~/bin and then add ~/bin to your path.

To do this, add:

export PATH=$PATH:~/bin

to ~/.bash_profile.