richsark wrote:
Hello, I have a bunch of perl scripts located in /Users/richsark/scripts
Is there a way I can excute a perl file or even a .sh file from whereve directory I am in?
so if I am in /Users/richsark/anywhere/file/location
I can put in a few letters of my perl script name then hit tab to auto-complete the rest and run it?
Thanks
Ok. To summarize.
Your PATH must contain both the location of your scripts, and the notion of current working directory (.)
My perl scripts start with a line like this:
#!/usr/bin/env perl
That way, if you investigate perlbrew in google, you will appreciate this syntax.
I put everything in my .bashrc file and the only thing in my .bash_profile is a check for .bashrc as shown below. I do not use a .profile.
.bashrc
# let me execute anything from my current working directory, or designated scripts directory
# additional necessary paths as needed. You may use ~ instead of $HOME.
export PATH=.:$HOME/scripts:$PATH
.bash_profile
# if file exists and > 0
[[ -s $HOME/.bashrc ]] && source $HOME/.bashrc
$ source .bashrc
$ chmod +x myscript.pl myscript.sh
$ cd ~/Downloads
$ ./myscript.pl