{"id":12469,"date":"2019-03-27T01:56:05","date_gmt":"2019-03-27T01:56:05","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12469"},"modified":"2019-03-27T01:56:05","modified_gmt":"2019-03-27T01:56:05","slug":"goto-quickly-navigate-to-aliased-directories-with-auto-completion-support","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/27\/goto-quickly-navigate-to-aliased-directories-with-auto-completion-support\/","title":{"rendered":"Goto \u2013 Quickly Navigate to Aliased Directories with Auto-Completion Support"},"content":{"rendered":"<p>In a recent article, we talked about\u00a0<a href=\"https:\/\/www.tecmint.com\/gogo-create-shortcuts-to-long-directory-paths-in-linux\/\" target=\"_blank\" rel=\"noopener\">Gogo \u2013 a tool to create shortcuts for long paths<\/a>\u00a0in a Linux shell. Although\u00a0<strong>gogo<\/strong>\u00a0is a great way to bookmark your favorite directories inside a shell, however, it has one major limitation; it lacks an auto-completion feature.<\/p>\n<p>Because of the above reason, we went all out to find a similar utility with auto-completion support \u2013 where the shell can prompt with suggestions of the available\u00a0<strong>aliases<\/strong>\u00a0(shortcuts to long and complicated paths) and luckily, after crawling through Github, we discovered\u00a0<strong>Goto<\/strong>.<\/p>\n<p><strong>Goto<\/strong>\u00a0is a shell utility to quickly navigate to aliased directories, with support for auto-completion. It comes with a nice auto-completion script so that once you press the\u00a0<strong>tab<\/strong>\u00a0key after the\u00a0<strong>goto<\/strong>\u00a0command or after typing a few charters of an existing alias, bash or zsh prompts with suggestions of the aliases or auto complete the name, respectively.<\/p>\n<p><strong>Goto<\/strong>\u00a0also has additional options for unregistering an alias, expanding an alias\u2019s value as well as cleaning up aliases of deleted directories. Note that goto\u2019s auto-completion only works for aliases; it is separate from shell auto-completion for commands or filenames.<\/p>\n<p><center><img decoding=\"async\" title=\"Goto - Navigate Quickly to Aliased Directories\" src=\"https:\/\/github.com\/iridakos\/goto\/raw\/master\/doc\/goto.gif\" alt=\"Goto - Navigate Quickly to Aliased Directories\" data-lazy-loaded=\"true\" \/><\/center><\/p>\n<h3>How to Install and Use Goto in Linux Systems<\/h3>\n<p>To install Goto, start by cloning the goto repository from Github and move into the local repository directory, then run the install shell script with root user privileges using the sudo command as shown.<\/p>\n<pre>$ cd Downloads\/\r\n$ git clone https:\/\/github.com\/iridakos\/goto.git\r\n$ cd goto\r\n$ ls\r\n$ sudo .\/install\r\n<\/pre>\n<p>This will install\u00a0<strong>goto<\/strong>\u00a0in\u00a0<strong>\/usr\/local\/share\/goto.sh<\/strong>, and it will add a line in your\u00a0<code>~\/.bashrc<\/code>\u00a0(for\u00a0<strong>Bash<\/strong>) or\u00a0<code>~\/.zshrc<\/code>\u00a0(for\u00a0<strong>Zsh<\/strong>) shell startup file, to source it.<\/p>\n<p>Now restart your terminal to start using\u00a0<strong>goto<\/strong>. To create an alias for a directory, register the alias with the\u00a0<code>-r<\/code>flag as follows.<\/p>\n<pre>$ goto -r march ~\/Documents\/Tecmint.com-Articles\/March\/\r\n<\/pre>\n<div id=\"attachment_28873\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/Create-Alias-for-Directory-in-Linux.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28873\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/Create-Alias-for-Directory-in-Linux.png\" sizes=\"auto, (max-width: 772px) 100vw, 772px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/Create-Alias-for-Directory-in-Linux.png 772w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/Create-Alias-for-Directory-in-Linux-768x59.png 768w\" alt=\"Create Alias for Directory in Linux\" width=\"772\" height=\"59\" aria-describedby=\"caption-attachment-28873\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28873\" class=\"wp-caption-text\">Create Alias for Directory in Linux<\/p>\n<\/div>\n<p>To alias your current directory, use this syntax which will automatically be aliased to the whole path.<\/p>\n<pre>$ goto -r home . \r\n<\/pre>\n<p>When you type\u00a0<strong>goto<\/strong>\u00a0and press the\u00a0<strong>tab<\/strong>\u00a0key, it will show all registered aliases and when you type a few letters of a registered alias, goto will auto complete the name. However, to view a list of your currently registered aliases, use the\u00a0<code>-l<\/code>\u00a0flag.<\/p>\n<pre>$ goto -l\r\n<\/pre>\n<div id=\"attachment_28874\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/Check-Available-Aliases-in-Linux.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28874\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/Check-Available-Aliases-in-Linux.png\" alt=\"Check Available Aliases in Linux\" width=\"642\" height=\"78\" aria-describedby=\"caption-attachment-28874\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28874\" class=\"wp-caption-text\">Check Available Aliases in Linux<\/p>\n<\/div>\n<p>To expand an alias to its value using the following command.<\/p>\n<pre>$ goto -x scripts\r\n$ goto -x march\r\n<\/pre>\n<div id=\"attachment_28875\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/expand-an-alias-value.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28875\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/expand-an-alias-value.png\" alt=\"Expand an Alias Value\" width=\"542\" height=\"135\" aria-describedby=\"caption-attachment-28875\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28875\" class=\"wp-caption-text\">Expand an Alias Value<\/p>\n<\/div>\n<p>Goto also allows you to unregister an alias, using the\u00a0<code>-u<\/code>\u00a0option.<\/p>\n<pre>$ goto -l\r\n$ goto -u march\r\n$ goto -l\r\n<\/pre>\n<div id=\"attachment_28876\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/Remove-Directory-Alias-in-Linux.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28876\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/Remove-Directory-Alias-in-Linux.png\" alt=\"Remove Directory Alias in Linux\" width=\"632\" height=\"173\" aria-describedby=\"caption-attachment-28876\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28876\" class=\"wp-caption-text\">Remove Directory Alias in Linux<\/p>\n<\/div>\n<p>If you have removed aliased directories (for example if you have deleted the directories\u00a0<strong>~\/Documents\/Tecmint.com-Articles\/March<\/strong>\u00a0and\u00a0<strong>~\/bin\/shellscripts\/recon<\/strong>\u00a0from the filesystem), yet they still have aliases in goto, you can cleanup all these aliases from goto with the\u00a0<code>-c<\/code>\u00a0flag.<\/p>\n<pre>$ goto -c\r\n<\/pre>\n<p>A significant limitation of\u00a0<strong>goto<\/strong>\u00a0is that it doesn\u2019t allow for accessing a sub-directory under an aliased directory, which is a feature present in\u00a0<a href=\"https:\/\/www.tecmint.com\/gogo-create-shortcuts-to-long-directory-paths-in-linux\/\" target=\"_blank\" rel=\"noopener\">Gogo<\/a>.<\/p>\n<p>For more information, consult the\u00a0<strong>goto<\/strong>\u00a0help message with the\u00a0<code>-h<\/code>\u00a0option.<\/p>\n<pre>$ goto -h\r\n<\/pre>\n<p><strong>Goto Github repository<\/strong>:\u00a0<a href=\"https:\/\/github.com\/iridakos\/goto\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/github.com\/iridakos\/goto<\/a><\/p>\n<p><strong>Goto<\/strong>\u00a0is a powerful way to bookmark your favorite directories inside a shell, with auto-completion support, in Linux. It has more useful features compared to\u00a0<strong>Gogo<\/strong>, as explained above. Give it a try and share with us, your thoughts about it via the feedback form below.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/goto-navigate-aliased-directories-with-auto-completion\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a recent article, we talked about\u00a0Gogo \u2013 a tool to create shortcuts for long paths\u00a0in a Linux shell. Although\u00a0gogo\u00a0is a great way to bookmark your favorite directories inside a shell, however, it has one major limitation; it lacks an auto-completion feature. Because of the above reason, we went all out to find a similar &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/27\/goto-quickly-navigate-to-aliased-directories-with-auto-completion-support\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Goto \u2013 Quickly Navigate to Aliased Directories with Auto-Completion Support&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12469","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12469","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12469"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12469\/revisions"}],"predecessor-version":[{"id":12470,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12469\/revisions\/12470"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}