Adding Executable Program Commands to the PATH variable
Understanding the PATH variable and adding commands to use in your terminal
SHORT AND SWEET
create new bin folder to use to synlink application binaries to: mkdir ~/bin add new bin folder to PATH (add to ~/.zshrc config) export PATH="/Users/spiffy/bin:$PATH" then synlink the binary for an app (MACos it should be at: App.app - "open package contents"/Contents/MacOS/(APPNAMEFILE) synlink that file into the bin folder ln -s "/Applications/flameshot.app/Contents/MacOS/flameshot" ~/bin
If you encounter the below error while running the command flameshot:
flameshot: command not found
you may try installing the below package as per your choice of distribution:
|Debian||apt-get install flameshot|
|Ubuntu||apt-get install flameshot|
|Arch Linux||pacman -S flameshot|
|Kali Linux||apt-get install flameshot|
|Fedora||dnf install flameshot|
flameshot Command Examples
- Create a fullscreen screenshot:
- Create a screenshot interactively:
- Create a screenshot and save it to a specific path:
flameshot gui –path path/to/directory
- Create a screenshot interactively in a simplified mode:
- Create a screenshot from a specific monitor:
flameshot screen –number 2
- Create a screenshot and print it to the standard output:
flameshot gui –raw
- Create a screenshot and copy it to the clipboard:
flameshot gui –clipboard
- Create a screenshot with a specific delay in milliseconds:
flameshot full –delay 5000
PATH variableYour computer (Mac or Linux, or a Unix-based system) has an environment variable called `PATH`, which contains a set of executable program directories that contain the executable programs.
Executable programs are basically the commands you can use in the shell.
These include the essential boot-stage or early-stage required binaries as well as other general system-wide commands.
As per the Filesystem Hierarchy Standard (FHS), these commands are located hierarchically in the system as follows:
In addition to the system-level binaries, executable programs can also include host specific program commands.
When you install a program or application on your Mac through the
internet, the application will be available to execute using GUI,
usually from the
In order to use the command line command to run the application,
however, the executable file for the application must be saved to
PATH variable. In other words, you must add the
directory of the executable program file for the application to
PATH variable in order to use the name of the
executable file as the command to run it from the shell.
When you install an application through a package manager, such
as Homebrew, it is symlinked to
which is usually included in
For other direct program installations, it is your job to either save
the original executable file to the
PATH variable directly,
or symlink the executable file to a separate
which would be included in
Let’s take a look at how we can go about adding these
local application commands to
**_PATH_** variable so that
we can use their commands in our shell.
Adding to PATH
zsh shell profile (
.zshrc), you can
add the following:
This syntax prepends
/path/to/app/executable/file/directoryto the existing
exportcommand allows all child processes to inherit the marked variable.
$PATHrefers to the
- assigning the
PATHvariable with the trailing
:$PATHessentially adds the path to the front of the existing
PATHvalue with the separator
- You can also append the path to the existing
PATH(add to the end) by instead using
pathis another variable that is tied to the
PATHvariable, but it is an array.
pathare tied together, so changing either one will change the other.
- however the variables’ value syntax are different:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/path/to/app/……>> echo $path
/usr/local/bin /usr/bin /bin /usr/sbin /sbin /path/to/app/……
- Note the
PATHis separated by
pathis separated by whitespace.
- You can force the
pathvariable to have only unique values by using
typeset -U pathcommand before
pathassignment. This will keep the
pathvalue clean by preventing duplicate directory names being added.
/path/to/app/executable/file/directory will likely be a
bin directory starting from
- For example, for Visual Studio Code, the path is:
/Applications/Visual Studio Code.app/Contents/Resources/app/bin
- So, you would set:
export PATH=“/Applications/Visual Studio Code.app/Contents/Resources/app/bin:$PATH”
This allows you to use the ‘code’ command (which is the name of the executable file) to run Visual Studio Code from the command line.
the executable program file to a
Instead of adding each executable program file to
PATH separately, you can symlink the executable program
file to a separate folder and add this folder to
- This separate folder could be a
binfolder on your home directory:
- You will have to create this in your home directory:
>> mkdir ~/bin
You can use
ln command to symlink the executable
lnis a utility program that creates a new directory entry (a linked file), which has the same modes as the original file. The link ‘points’ to the original copy. How the link ‘points’ to the original file is the difference between a hard link and a symbolic link.
- By default
lncreates hard links, where any changes to the original file are effectively independent from the linked file.
- Using the
-sflag creates a symbolic link (symlink), which is a soft copy, allowing for the use of the referenced file when an operation is performed on the linked file.
>> ln -s “/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code” ~/bin
If you have the
~/bin directory added to
PATH variable, you just need to to symlink any
executable program you want to add command for to
This will make the organization of the
PATHmuch cleaner and much easier to see what executable programs are included in the