Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Create Shortcuts to Long and Complicated Paths in Linux (Gogo)
Gogo is a tool to bookmark directories with long and complicated paths in the Unix shell. Because the long paths are difficult to remember and cumbersome to type in, gogo provides a simple way to create shortcuts. In this article we'll see how to install gogo and use it.
Installing Git
We first need to have git installed in our system which will be needed for gogo installation. To install git in an Ubuntu system follow the below command ?
$ sudo apt install git
Running the above code gives us the following result ?
[sudo] password for ubuntu: Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: git-man liberror-perl ????. ????.. Setting up liberror-perl (0.17-1.2) ... Setting up git-man (1:2.7.4-0ubuntu1.7) ... Setting up git (1:2.7.4-0ubuntu1.7) ...
Cloning Gogo Repository
After git is successfully installed, we clone gogo into the system using the below repository ?
$ git clone https://github.com/mgoral/gogo.git
Running the above code gives us the following result ?
Cloning into 'gogo'... remote: Enumerating objects: 85, done. remote: Total 85 (delta 0), reused 0 (delta 0), pack-reused 85 Unpacking objects: 100% (85/85), done. Checking connectivity... done.
Setting Up Gogo
Next we create a bin directory in the user's home directory in case it is not already there and copy gogo to this directory. We will execute gogo from this location ?
mkdir -p ~/bin cp gogo/gogo.py ~/bin/
Adding Gogo to Bash Profile
Next we add gogo to bash profile and verify that it is added successfully ?
cat gogo/gogo.sh >> ~/.bashrc tail ~/.bashrc
Running the above code gives us the following result ?
# Gogo from anywhere.
function gogo {
CMD=`gogo.py $@`
RET=$?
eval "$CMD"
return $RET
}
Using Gogo
Now we can use gogo by going into the directory whose alias we want to create. First let's see the current configuration of gogo ?
$ gogo -l
Running the above code gives us the following result ?
Current gogo configuration (sorted alphabetically): - : - default : /home/ubuntu gogo : ~/.config/gogo sshloc : ssh://ubuntu@127.0.0.1:/bin/bash /home/ubuntu
Creating Directory Aliases
Next go into the directory whose alias you want to create. When inside the directory, execute the gogo -a command to create the alias which can be used from anywhere ?
$ pwd /home/ubuntu/Documents/tutorials/linux # Create an alias named lt to this directory $ gogo -a lt $ gogo -l Current gogo configuration (sorted alphabetically): - : - default : /home/ubuntu gogo : ~/.config/gogo lt : /home/ubuntu/Documents/tutorials/linux sshloc : ssh://ubuntu@127.0.0.1:/bin/bash /home/ubuntu # Go home and type the alias $ cd ~ $ gogo lt ubuntu@ubuntu:~/Documents/tutorials/linux$
Common Gogo Commands
| Command | Description |
|---|---|
gogo -l |
List all configured aliases |
gogo -a <alias> |
Add current directory as alias |
gogo <alias> |
Navigate to aliased directory |
gogo -d <alias> |
Delete an alias |
Conclusion
Gogo simplifies navigation by creating shortcuts to frequently accessed directories. Once configured, you can instantly jump to any bookmarked location using simple aliases, saving time and reducing typing errors.
