How to run scripts without typing the full path?
Solution 1:
You can just create symlink. Create it in /usr/local/bin
. All you need is to run command:
sudo ln -s /full/path/to/your/file /usr/local/bin/name_of_new_command
After that you should make your file
executable:
chmod +x /full/path/to/your/file
Now you should be able to run name_of_new_command
at any time in your terminal.
Note that this is good solution only for home usage of Linux.
Solution 2:
You can add /opt/idea/bin
to your PATH
variable:
PATH=/opt/idea/bin:"$PATH"
After this you can run it with simply idea.sh
.
You probably want to add this line in your ~/.bashrc
file.
Solution 3:
You can create a function in your ~/.bashrc
:
some-name () {
/path/to/your/file
# or:
#cd /path/to/your
#./path
}
Or you can create an alias
:
alias some-name='/path/to/your/file'
# or
#alias some-name='cd /path/to/your/; ./file'
In both cases, you can run it by calling:
$ some-name
If the file doesn't depend on where it's running, consider adding it to your ~/bin
:
mkdir -p ~/bin
cp /path/to/you/file ~/bin
# or mv /path/to/you/file ~/bin
# or ln -s /path/to/you/file ~/bin
~/bin
, if it exists, gets added to your $PATH
automatically. Then you directly call file
:
$ file
(Bad choice of name though, consider calling it something less generic.)