简体   繁体   中英

Configuring bash $PATH variable to find UNIX executable file

I have a custom command called git-feature, which is located in a Unix executable file with the same name. I'm trying to configure the $PATH variable in ~/.bash_profile so that it recognizes the Unix file. I updated the PATH variable to include the file's path:

export PATH=$PATH:~/Applications/MAMP/htdocs/code/git-shortcuts/

The echo $PATH command in my bash terminal produces the following result:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/myname/Applications/MAMP/htdocs/code/git-shortcuts/

But trying to call git-feature leads to the following error:

-bash: git-feature: command not found

There are a few similar questions on SO, but none of the ones I found solved this specific type of issue. Do I need to change the PATH variable differently in order for my custom command to be recognized by bash?

You are modifying the PATH variable correctly.

Make sure that git-feature really is in that directory, that it has the executable bit (+x) set, and that the directories leading to it give you rights to execute it:

MYFILE=/Users/myname/Applications/MAMP/htdocs/code/git-shortcuts/git-feature
ls -l "$MYFILE"
chmod +x "$MYFILE"
[ -x "$MYFILE" ] && echo "File can't be executed, check directory rights"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM