I have a bash script called climb.sh. When I execute it I write
./climb.sh 1
while inside the directory in which the script is located. However, I want to do the same thing wherever I am, and across all shell sessions by simply calling
climb 1
Also, climb.sh takes an numeric argument and calls "cd ../" that many times. In order for the program to work, it has to run alongside the current process, not within some child process.
How to achieve all this? Thanks
/usr/bin/lsinstead of/usr/bin/ls.elf, you should have/usr/local/bin/climbinstead of/usr/local/bin/climb.sh. (/usr/local/binis important because, as described in the linked duplicate, it's a location in the default searchPATHenvironment variable used to find executables used without a/in their names specifying a specific location).sourceing all files in/etc/profile.d/, such that you need to put your script defining a function in a similar location -- but you'll need to look at your specific OS; there's nothing in bash itself that allows it; things like/etc/profile.dare configuration your OS vendor arranges, not functionality built into the shell).alias climb='source /usr/local/bin/climb.sh'could instead by written asclimb() { . /usr/local/bin/climb.sh "$@"; }; export -f climb, installed in the same ways, but then with an impact not only on the shell it's sourced into but also that shell's children).