“setgo” is a command-line utility that allows the user to change the current directory using a short easy-to-remember name. Each “go” command is prefixed with a dash “-” so all “go” commands are unique and do not conflict with existing commands.
“setgo” creates and maintains any number of “go” commands for each user on a supported operating system. This allows each user to have “go” commands that meet their individual needs.
Setgo is a “shell script” written for UNIX, Linux, and other similar operating systems. The original version of setgo was written in 1991 and the script has been ported to a wide variety of UNIX-based operating systems including Solaris, HP-UX, IBM AIX, Redhat, Fedora, Ubuntu, and CentOS.
The current implementation is oriented around the Bash (Borne Again SHell) although porting the script to other shells such as sh or ksh is a simple matter.
There is now a version for Microsoft Windows™. See Setgo for Windows.
How setgo Works
At login time the shell executes one or more scripts to setup the runtime environment. The setgo utility uses “alias” to associated the desired name with a command sequence that changes the current directory. Because these aliases are “sourced” before the command line prompt is presented to the user (i.e. the $ or # prompt) the aliases become part of the current environment. This is similar to the way a user’s PATH string is set.
Because no UNIX or Linux command begins with a dash “-” each setgo command uses that character as a prefix to make the “go” command unique.
The setgo utility is provided for free and “as is” with no guarantee or warranty expressed or implied. If you break it you own both parts.
Port it, extend it, pass it around.
The setgo utility is a plain-text shell script. It may be downloaded from GitHub at:
If you downloaded the shell script simply copy it to a location on your PATH. If you downloaded the zip archive unpack the script to a location on your PATH.
The setgo file needs execute permissions. Run this:
chmod 775 setgo
The file maintained by setgo is ~/.go in your home directory. So the “go” commands are available when you login the ~/.go file should be “sourced” in your .bashrc, .bash_user, .profile or whatever login script file your shell executes at login time.
if [ -f ~/.go ]; then source ~/.go fi
The ~/.go file is automatically created if it does not exist in your home directory.
setgo . — Create new “go” command for current directory.
setgo work — Create new “go” command named -work.
setgo -f — find all “go” commands with the current directory.
setgo -f work — find all “go” commands contain ‘work’.
setgo -d work — delete existing “go” command -work.
setgo -e . — edit the “go” command for the current directory.
-work — change to the “work” location.
-. — refresh “go” commands after adding a new one.
rego — refresh “go” commands after adding a new one.
setgo – Quick directory change helper
Simple script to maintain a file of “Go” commands…aliases used to
quickly change directories with a simple name. For example, if you
are currently in /etc/init.d and run the command:
a line is added to the file ~/.go that will contain:
alias — -init=’cd /etc/init.d’
which says “add an alias called -init which, when typed at the
command line, will execute the command: cd /etc/init.d”.
The file ~/.go is maintained with a series of aliases that all
have a leading – (dash). This file should be “sourced” in your
.bashrc, .bash_user, .profile or whatever login script file so
the aliases will be included in your environment.
Example: source ~/.go or . ~/.go
The ~/.go file should also contain the ADDITIONAL COMMANDS.
USAGE: setgo [-d][-e][-f] name
-d delete name from ~/.go file.
Does not unalias Go command, see ADDITIONAL COMMANDS.
-e edit the ~/.go file. EDITOR is coded in this script.
-f find all go entries containing name. If name is not specified
then use the current directory name.
name logical “Go” name for the current directory. If “.” (dot) is
specified then the name of the current directory is used.
If neither -d or -f are used then a new go name is added.
To use a “Go” command type: -name
setgo work creates new go name: -work
setgo -f find all entries containing the current directory
setgo -f work find all go entries containing: work
setgo -d work delete go entry: -work
These commands are automagically added:
-. re-sources the ~/.go file.
rego alias for -. (dash dot).
delgo name delete entry “name”.
This command also does an unalias of the entry.
~/.go The ‘go’ command file.