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.
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:
to
~/.bash_profile
.You can add . to the path, but as MikeyB says, it is a bad idea.
The reason it is a dangerous thing to do is that if a malicious bit of software with the same name as an executable you are running exists in the current directory, that will be run instead.
I put my shell scripts in /usr/local/bin, seems the best place for them? it's usually empty. Make them executable and forget the .sh extension, and you can just call them plainly.
That's on Ubuntu server.
To answer the question that was asked, add your home directory and the desktop to the path.