I want to run a bash script named hello (just as an example) and want to run it by just typing hello rather than path/hello.sh. The purpose is to run scripts like how we run docker, mysql, git etc commands where you only type the name before the arguments and options rather than typing in the path/executable.extension to run it.
I've followed the top answer to this question: Add a bash script to path
which says (for a script named apt-proxy.sh):
Save the script as apt-proxy (without the .sh extension) in some directory, like ~/bin.
Add ~/bin to your PATH, typing export PATH=$PATH:~/bin
If you need it permanently, add that last line in your ~/.bashrc. If you're using zsh, then add it to ~/.zshrc instead.
Then you can just run apt-proxy with your arguments and it will run anywhere. Note that if you export the PATH variable in a specific window it won't update in other bash instances.
So I made a script named hello (without the .sh) and it just contains:
#!/usr/bin/sh
echo "hello"
it's just in my home/username folder so I added export PATH=$PATH:$HOME/username tho this doesn't make sense as that dir is already in the PATH but I don't know what else to do.
I added it to the ~.profile file as I use ubuntu. Then used source to run/update it.
From the linked post, doing this should supposedly make me able to run hello just like that rather than ./hello, but I can't. I have to type ./hello.
How do I run it as just hello?