
Quickly navigate your filesystem from the command line - jeroenjanssens
http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html
======
modernerd
I had to modify Jeroen's code to get the `marks` shortcut working under Mac OS
10.8:

    
    
        export MARKPATH=$HOME/.marks
        function jump {
            cd -P $MARKPATH/$1 2> /dev/null || echo "No such mark: $1"
        }
        function mark {
            mkdir -p $MARKPATH; ln -s $(pwd) $MARKPATH/$1
        }
        function unmark {
            rm -i $MARKPATH/$1
        }
        function marks {
            ls -l $MARKPATH | sed 's/  / /g' | cut -d' ' -f9- && echo
        }

~~~
guygurari
Here is another version of 'marks' for Mac OS that aligns the arrows. It also
works when 'ls' is aliased.

    
    
        function marks {
            \ls -l $MARKPATH | tail -n +2 | sed 's/  / /g' | cut -d' ' -f9- | awk -F ' -> ' '{printf "%-10s -> %s\n", $1, $2}'
        }

~~~
0x09
If you are on a system with BSD stat like OS X you can get the same with

    
    
      function marks {
        (cd $MARKPATH && stat -f"%-10SN%SY" *)
      }
    

Even better with column

    
    
      (t="$(printf "\t")"; cd $MARKPATH && stat -f"%N$t%SY" * | column -ts"$t")

------
microcolonel
I set my version up with a -f on the unmark rm so that I don't need to be
prompted to remove it. Also added some basic completion for both jump and
unmark

    
    
      export MARKPATH=$HOME/.marks
      function jump { 
          cd -P $MARKPATH/$1 2>/dev/null || echo "No such mark: $1"
      }
      function mark { 
          mkdir -p $MARKPATH; ln -s $(pwd) $MARKPATH/$1
      }
      function unmark { 
          rm -if $MARKPATH/$1 
      }
      function marks {
          ls -l $MARKPATH | sed 's/  / /g' | cut -d' ' -f9- | sed 's/ -/\t-/g' && echo
      }
    
      _completemarks() {
          local curw=${COMP_WORDS[COMP_CWORD]}
          local wordlist=$(find $MARKPATH -type l -printf "%f\n")
          COMPREPLY=($(compgen -W '${wordlist[@]}' -- "$curw"))
          return 0
      }
    
      complete -F _completemarks jump unmark

~~~
coherentpony
The purpose of the -i flag is to prompt the user before deleting. Mixing the
-i and -f flags is a little moot.

Try removing the -i option to obtain what you want.

~~~
microcolonel
Didn't catch that, it was a quick hack of an edit, thanks.

------
nkuttler
To have completion with bash you can use this:

    
    
      function _jump {
          local cur=${COMP_WORDS[COMP_CWORD]}
          local marks=$(find $MARKPATH -type l -printf "%f\n")
          COMPREPLY=($(compgen -W '${marks[@]}' -- "$cur"))
          return 0
      }
      complete -o default -o nospace -F _jump jump
    

Bash completion really needs better docs :-|

~~~
christiangenco
Hmmm, this doesn't seem to work in `zsh`. Typing `jump <tab>` suggests
everything in the current directory (folders and files).

Does anyone here know offhand how autocompletion in `zsh` works?

~~~
tiziano88
see my comment at the bottom
[https://news.ycombinator.com/item?id=6229468](https://news.ycombinator.com/item?id=6229468)

------
sukaka
Reminds me of z, which I use all the time. Anyone else use z? If you have not
heard of it, get it now
[https://github.com/rupa/z](https://github.com/rupa/z).

z is a wonderful complement to cd. After cd into a folders with z set up, a
file stores all folders navigated to sorted by frecency, then simply jump to a
folder with z [foldernameregex].

~~~
dmd
z is absolutely wonderful. Even my boss has become a convert, and he's been
hacking unix since the 1970s, when he worked at AT&T, and is very set in his
ways.

[Disclaimer: rupa's a good friend of mine]

~~~
grimgrin
I've converted a few people to the z side. And yes, it is wonderful.

[Disclaimer: rupa is a good friend of mine, as well]

~~~
Fuzzwah
I was pretty excited about original link in this HN submission, but now I'm
roughly twice as excited to learn about z. Love it.

[Disclaimer: I don't know rupa at all]

~~~
baohaojun
I have developed a very similar scheme for myself independently (haven't heard
of z before, but thanks). A further idea is another command <code>e</code>,
which is used like: <code>e reg1 reg2...</code>, and it will query z's
database to see if there is a file in z's directory which matches the regs,
and if found, open that file in Emacs. A similar command <code>f</code> will
only print the path, so that <code>firefox $(f reg1 reg2)</code> will open the
found file using firefox.

------
skrebbel
For Windows users I have a closely related shameless plug:

 _cdhere_ navigates your cmd.exe to wherever the current topmost Explorer
window is pointed at.

It's not the same as the OP's trick, of course, but since you're voluntarily
using Windows, I'm going to assume you "live" on the command line less than
the average UNIX user, and more on GUI tools such as good old Explorer.

[https://github.com/eteeselink/cdhere](https://github.com/eteeselink/cdhere)

~~~
Livven
What many people don't seem to know is that the location bar in Explorer (at
least on Windows 8) can act as a run dialog, and it supplies the launched
program with the current folder as a parameter. So simply hit Ctrl+L and type
"cmd" or "powershell" or whatever command from your PATH and hit enter.

~~~
WalterGR
Amazing tip!

FYI: On Windows 7, you need to press Alt+D to get to the location bar. (I
believe that's the case for XP as well.) Ctrl+L doesn't seem to do anything.

~~~
skrebbel
Alt+D is my preferred shortcut anyway, since it has the same effect in e.g.
fullscreen IE10. Consistency is nice.

~~~
WalterGR
Totally. Also works in Chrome and Firefox.

------
networked
You can also use ranger [1] to change directories, especially if you want to
explore the directory tree quickly when you don't know exactly where to jump
to. Install it and add the following to ~/.bashrc:

    
    
         function ranger-cd {
           tempfile='/tmp/chosendir'
           /usr/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}"
           test -f "$tempfile" &&
           if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
             cd -- "$(cat "$tempfile")"
           fi
           rm -f -- "$tempfile"
         }
    
         # This binds Ctrl-O to ranger-cd:
         bind '"\C-o":"ranger-cd\C-m"'
    

(This script comes from the man page for ranger(1).)

Edit: Modified the above script for use with zsh (and multiple users):

    
    
         ranger-cd() {
           tempfile=$(mktemp)
           ranger --choosedir="$tempfile" "${@:-$(pwd)}" < $TTY
           test -f "$tempfile" &&
           if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
             cd -- "$(cat "$tempfile")"
           fi
           rm -f -- "$tempfile"
         }
    
         # This binds Ctrl-O to ranger-cd:
         zle -N ranger-cd
         bindkey '^o' ranger-cd
    

[1] [http://ranger.nongnu.org/](http://ranger.nongnu.org/).

~~~
braum
thanks! I tried: apt-get install ranger

it says it's not available. any idea why ranger is not longer available in
package manager?

~~~
networked
What is your distribution? I've just tried it and it's available in both
Ubuntu 12.04 and Debian 7. The launchpad page says that it should be in later
Ubuntu releases, too. Enable the "universe" repository then run apt-get update
and see if it fixes the problem.

~~~
braum
Debian "Squeeze" 6.0.7 x32

~~~
networked
Looks like it simply never was in Squeeze. Install python2.6 and get the
latest stable release from [http://nongnu.org/ranger/ranger-
stable.tar.gz](http://nongnu.org/ranger/ranger-stable.tar.gz) instead.

------
fau
You might want to check out z:
[https://github.com/rupa/z](https://github.com/rupa/z)

~~~
TheEskimo
[https://github.com/clvv/fasd](https://github.com/clvv/fasd)

I used to use z, but I've since switched to fasd. It's much like z, but also
so much better. In addition to being able to do "z <part of directory>" you
can do "f <part of file>". So, for example, if I've got a rails project I've
worked on a lot recently I know its config.ru is high on frecency, so I'll
just do "vim `f config`" to edit that file. If I want a file that's not so
recent I can always do "vim `f -i config`" to pick from a list of files.

fasd is leaps and bounds above z in functionality, and I've thoroughly enjoyed
using it.

~~~
kinleyd
I put z and fasd through their paces, and out of the box z works very
intuitively. I like it. fasd takes a little more to get used to, but I'm going
to put it through a full try out. Let's see if the additional features make it
worth the while. In either case, thanks all for a great thread.

~~~
kinleyd
fasd is z on steroids. Fantastic tool.

------
mynameisfiber
I found this is a useful addition to his scripts... I can't live without my
tab completion!

    
    
        _jump()
        {
            local cur=${COMP_WORDS[COMP_CWORD]}
            COMPREPLY=( $(compgen -W "$( ls $MARKPATH )" -- $cur) )
        }
        complete -F _jump jump

~~~
sgt
Cleaner than the other variants here that use "find".

------
lazerwalker
I've been using Bashmarks
([https://github.com/huyng/bashmarks](https://github.com/huyng/bashmarks)) for
years, which appears to be basically the same thing but with a less verbose
interface.

~~~
manojlds
And poshmarks for those on Windows -
[https://github.com/manojlds/poshmarks](https://github.com/manojlds/poshmarks)

------
franzb
Here is a fully functional (albeit minimal) Windows version:
[http://appleseedhq.net/stuff/marks-v1.zip](http://appleseedhq.net/stuff/marks-v1.zip).
Tested on Windows 7 (does not require PowerShell).

GitHub: [https://github.com/dictoon/marks](https://github.com/dictoon/marks)

Edit: to install, unzip anywhere and add to your path. Then:

    
    
      C:\Windows> mark win
    
      C:\Windows> marks
      win => C:\Windows
    
      C:\Windows> cd ..
    
      C:\> jump win
    
      C:\Windows> 
    

Marks will be stored in a marks\ subdirectory (relatively to the mark.bat
file).

~~~
newtover
Great! It's a smart idea just to store locations in simple text files. Thank
you.

------
shailesh
Clever!

With fish 2.0, the shell stores a list of "cd" commands issued from a specific
directory, so mostly just typing "cd" yields an auto-completion hint out of
the box.

------
anjanb
cool! I'm a command-line junkie as well. So, I've been doing something similar
for quite a while.

Here's what I have done :

    
    
        function ccb ()
        {
            FOO=`pwd`;    
            echo >> ~/shortcuts.sh;    
            echo alias $1=\'pushd $FOO\' >> ~/shortcuts.sh;    
            echo >> ~/shortcuts.sh;    
            . ~/shortcuts.sh    
        }
    

simple but quite effective.

Now, all I have to do is type ccb and give a shortcut name to register a
shortcut. Then whenever i want to jump to that directory, I just have to type
the shortcut.

Eg :

    
    
        foo@bar deeply-nested-dir# ccb deepd
        foo@bar deeply-nested-dir# cd
        foo@bar ~# deepd
        foo@bar deeply-nested-dir#
    

My method lacks the a) delete shortcut and b) list shortcut features that the
above solution gives, though.

~~~
IanCal
HN uses markdown, stick 4 spaces before each line in your code blocks to get
them to indent properly, and drop the <br>

    
    
        function ccb ()
        { 
            FOO=`pwd`;
            echo >> ~/shortcuts.sh; 
            echo alias $1=\'pushd $FOO\' >> ~/shortcuts.sh;
            echo >> ~/shortcuts.sh;
            . ~/shortcuts.sh
        }

~~~
anjanb
thanks for letting me know -- I've edited my comment.

------
sam152
This is really neat. I have added it to alias.sh for easy inclusion:
[http://alias.sh/filesystem-markers-jump](http://alias.sh/filesystem-markers-
jump)

------
georgecalm
Here's a `fish 2` shell version, that works on the Mac. You can add it as
`~/.config/fish/functions/mark.fish`:

    
    
        set MARKPATH $HOME/.marks
        function jump
          cd $MARKPATH/$argv; or echo "No such mark: $argv"
        end
        function mark
          mkdir -p $MARKPATH; and ln -s (pwd) $MARKPATH/$argv
        end
        function unmark
          rm -i $MARKPATH/$argv
        end
        function marks
          ls -l $MARKPATH | cut -d' ' -f12-; and echo
        end

~~~
TeMPOraL
-f9- for me in cut, but otherwise it works :). Thanks!

------
tiziano88
Cool, simple but very useful!

Bonus: if you want autocompletion for the jump and unmark commands, just add
the following lines (in zsh):

    
    
        function _marks {
          reply=($(ls $MARKPATH))
        }
        compctl -K _marks jump
        compctl -K _marks unmark

------
m-r-r
I don't understand the advantage of using handwritten function instead of the
shell builtins. The `mark` function could be replaced by `alias -g`, `jump`
could be replaced by `cd` and `unmark` could be replaced by `unalias` :

    
    
        % cd ~/Dev/W3/m-r-r.github.io
        % alias -g :blog="$PWD"
        % jekyll build -d /tmp/out/ && cd /tmp/out
        % ./index.html
        % cd :blog
        % pwd
        /home/m-r-r/Dev/W3/m-r-r.github.io
        % alias -g
        :blog='/home/m-r-r/Dev/W3/m-r-r.github.io'
        :dev='/home/m-r-r/Dev'
        :c='/home/m-r-r/Dev/C'
        :python='/home/m-r-r/Dev/Python'
        :vim='/home/m-r-r/.vim'
    

In addition, this method works with any shell command:

    
    
        % pwd
        /tmp/out
        % make -C :blog publish
        % git clone git://git.complang.org/ragel.git `echo :c`/ragel
        % vim `echo :vim`/templates/\*.rl
    

On the other side, the aliases are not saved at exit unless you write a
function to do it:

    
    
        % tail -n 15 ~/.zshrc
        function aliases {
            (
                alias -L -r
                alias -L -g
                alias -L -s
            ) | uniq
        } 
    
        function save-aliases {
            aliases > ~/.zsh_aliases
        }
    
        if [ -f ~/.zsh_aliases ]; then 
            . ~/.zsh_aliases
        fi

------
roob
I also do something similar but slightly different:
[https://github.com/roobert/dotfiles/blob/master/.zsh/robs/fu...](https://github.com/roobert/dotfiles/blob/master/.zsh/robs/functions/bookmarks.zsh)

my method involves storing the bookmarks in a file but loading them into zshs
directory hash. This means the directories are tab completable and if you have
AUTO_CD set then you can change directory with simply: ~dir_name, otherwise:
cd ~dir_name.

~~~
belovedeagle
And with CDABLE_VARS set, you can simply do: dir_name In fact, you don't even
have to use the directory hash for this, you just do, e.g.:
MY_DIR=/path/to/dir; MY_DIR

Frankly, this is far superior to the linked method.

~~~
roob
Except tab completion is annoying since zsh will include commands and
environment variables in its guesses. The linked method simply provides a way
to store the directory hash across sessions.

------
bakul
I've been using the following in some form for over 3 decades! (now in zsh)

    
    
        alias   .=cd
    

In /bin/sh "." sources a script. While this can be common in a script, one
rarely does this interactively so I usurped . for the most common operation!

    
    
        alias   ,=pushd
        alias   ,,=popd
        alias   ,.=dirs
    

Think of cd as a goto, pushd as a call, popd as a return and dirs as a stack
trace!

    
    
        ..() { cd ../$* }
        cdpath=(. .. ~/src ~)
    

Use of cdpath can be confusing so it is best to show part of $PWD in the
prompt:

    
    
        PS1="%* %5. %h%(#.#.:) "
    

This ends the prompt with a # if you are running as superuser.

These aliases/functions are enabled in .zshrc ( _only_ if run interactively --
that is, they are included below the following test):

    
    
        if [[ ! -o interactive ]] ; then return; fi
    

The "benefit" of Jeroen's mark/unmark is that these paths persist (and can be
used from any window running a shell. I have not found much need for that + I
can have different $dirs in different windows. Also, given that my shell
windows (under screen) persist for a very long time, I don't need symlink's
persistence!

Alternatively I define "." to be a function that does arg specific operation
(cd if a dir, acroread if .pdf, vi if text etc.).

------
daGrevis
This is great, but I don't see why this is better than autojump.

* Autojump automatically saves marks,

~~~ cd Downloads # And you are done. ~~~

* You don't have to think about mark names,

~~~ cd Projects/Python # It will be called `python`. ~~~

* You don't need to remember mark names,

~~~ j haskell # If you want `Projects/Haskell`, odds are the mark is auto-
named `haskell`. ~~~

* You can specify only some part of mark name;

~~~ j bar # And you are in `Stuff/foobar`. ~~~

Other than that, this is, as I said before, great! Looking forward to go
through the source code to learn more about Bash.

~~~
hadem
Why on Earth would you want to save every directory you change to?!

------
jonknee
I noticed that 'mark' doesn't work if you have spaces in a directory name
which you can't avoid on the Mac (I tried to mark an interior folder inside
the iPhone Simulator which is inside "~/Library/Application Support/iPhone
Simulator/". Wrapping in quotes seems to do the trick:

    
    
      function mark { 
           mkdir -p $MARKPATH; ln -s "$(pwd)" $MARKPATH/$1
      }

------
_mc
Cool!, I usually want to open a new terminal window and move to the same
directory I am working in, I use these handy aliases :

alias here='pwd | pbcopy'

alias there='cd $(pbpaste)'

So now type `here` in current terminal window and type `there` in new terminal
window to move to same directory!

[This works on Mac on other OS you could use xcopy or equivalent clipboard
copy program]

------
ttomaino
This is a very informative thread for people trying to streamline their daily
shell experience. I'm looking forward to experimenting with the utilities
mentioned here. I spend a significant amount of time in, and moving between
CVS sandboxes. All my sandboxes have the same internal directory structure,
but the root of the path changes. To speed up navigation time I created a tool
to replace directory names with aliases. The aliases are persistent. They can
also be "stacked", which allows you to specify a sandbox as an alias, then
reuse your existing aliases to navigate within the sandbox. Auto-completion in
the shell is an excellent companion as well. More information on
"stacked.aliases", as well as the source can be found here:
[https://github.com/ttomaino/stacked_aliases/wiki](https://github.com/ttomaino/stacked_aliases/wiki).
I include one example to illustrate:

As an example, the following two sandboxes contain the Broadcom Ethernet
driver:

/build/username/sandbox_a/software/vendors/linux/linux-2.6.35.7/drivers/ethernet/broadcom
/build/username/sandbox_b/software/vendors/linux/linux-2.6.35.7/drivers/ethernet/broadcom

Use the add alias command aa <alias name> <directory> to create aliases for
the sandboxes:

aa a /build/username/sandbox_a aa b /build/username/sandbox_b

Then create an alias for the Broadcom directory:

aa brcm software/vendors/linux/linux-2.6.35.7/drivers/ethernet/broadcom

To change to the Broadcom directory in sandbox_a, just stack the appropriate
aliases using the ua command. Stacking is done by stringing the aliases
together with a period delimiter:

ua a.brcm

To change to the Broadcom directory in sandbox_b:

ua b.brcm

------
hifi
Great idea!

I don’t want symlinks to be resolved (/var/www becomes /private/var/www on os
x) so I modified it to store the path in the file:

    
    
      export MARKPATH=$HOME/.marks
    
      function jump {
        mark=$(head -n 1 "$MARKPATH/$1" 2>/dev/null)
    
        if [[ $mark != '' ]]; then
          cd $mark
        else
          echo "No such mark: $1"
        fi
      }
    
      function mark {
        mkdir -p "$MARKPATH"; echo "$(pwd)" > "$MARKPATH/$1"
      }
    
      function unmark {
        rm -i "$MARKPATH/$1"
      }
    
      function marks {
    
        find "$MARKPATH" -type f | while read filename
        do
          printf "%-12s -> %s\n" $(basename ${filename}) $(head -n 1 ${filename})
        done
      }
    

I think the if syntax is zsh so probably won’t work with bash.

------
kelvie
I just do this (in zsh):

    
    
        setopt autopushd pushdminus pushdsilent pushdtohome pushdignoredups
    

Which automatically pushes (unique) directories I've visted into $dirstack.

Then I have an alias:

    
    
        d () {
                local dir
                select dir in $dirstack
                        echo $dir
                        break
                done
                test "x$dir" != x && cd $dir
        }
    

That gives me a list of directories to jump to in my history:

    
    
        ~/src/git/emacs-prelude $ d
        1) /home/kelvie/tmp/typhoon          3) /home/kelvie/src/git              
        2) /home/kelvie/tmp                  4) /home/kelvie                      
        ?#
    

So I just type 1-4 to go back to a directory I've previously been in.

------
davejamesmiller
I'm too lazy to type "jump" so I've modified it to automatically add a Bash
alias for each one as well.

[https://github.com/davejamesmiller/dotfiles/blob/master/.bas...](https://github.com/davejamesmiller/dotfiles/blob/master/.bash/mark.bash)

~~~
nkuttler
Unless I'm missing something you also need a function to create all aliases
when the shell session starts?

~~~
davejamesmiller
That's what the for loop at the bottom does.

~~~
nkuttler
doh!

------
lucaspiller
I have no idea if anyone else does this, but I use tmux a lot for different
projects. I usually have vim in one tab, logs in another, and tests in
another. However, each tab I open I need to cd into the same directory. As
such I came up with this helper for zsh. Every time I change a directory it
records it. When I start a new session (new tmux or iTerm tab) it goes
straight to that directory:

    
    
        # record directory in ~/.lastpwd
        record_pwd() {
          pwd > ~/.lastpwd
        }
        chpwd_functions=(record_pwd)
        
        # go to last directory when opening a new shell
        if [[ -d `cat ~/.lastpwd` ]]; then
          cd `cat ~/.lastpwd`
        fi
    

For other shells that don't have something like chpwd_functions you could just
alias cd.

~~~
phinze
> However, each tab I open I need to cd into the same directory.

As of tmux 1.7, this should be unnecessary. Every tab and split will open in
the working directory of the current pane, and the behavior can be changed
with the `default-path` option.

------
AlexanderDhoore
A handy alias I use:

    
    
        alias ..='cd ..'
    

Moving up the file tree has never been easier!

~~~
hk__2
Put the following in your .bashrc instead:

    
    
        shopt -s autocd
    

If you type a directory in the command-line, it’ll cd into it, e.g.:

    
    
        $ ..   # cd ..
        $ ~    # cd ~
        $ foo  # cd foo
    

I can’t live without this.

~~~
AlexanderDhoore
Very cool, thanks! Although:

On OS X: "-bash: shopt: autocd: invalid shell option name"

Apple and their outdated tools... It gets annoying after a while.

~~~
rangibaby
Install new bash using brew :-) (1)
[http://apple.stackexchange.com/questions/55412/cd-to-a-
direc...](http://apple.stackexchange.com/questions/55412/cd-to-a-directory-by-
typing-its-name)

------
jeroenjanssens
Thank you all for your kind words and helpful suggestions! I shall adapt both
the post and the code accordingly.

Jeroen

~~~
jeroenjanssens
I have just added (1) quotes to the code, (2) a section about tab completion,
and (3) a note for Mac OS X users. Many thanks again; HN is a great community!

Jeroen

------
lamby
I've been doing a very similar thing for a few years: [https://chris-
lamb.co.uk/posts/optimising-directory-navigati...](https://chris-
lamb.co.uk/posts/optimising-directory-navigation-multiple-terminals)

------
verbatim
Interesting idea. I've the bash built-in "pushd" and "popd" for a long time
for similar reasons, but those effectively limit you to treating the history
as a stack rather than an arbitrary list.

~~~
yummysoup
yeah, it can be annoying that the directory stack sequence keeps changing,
which means that sometimes you can't easily re-run commands from your history
if you've pushd since you last ran the command

e.g., a command like "tar cfz bak.tgz ~3 ~2/subdirectory ~1" would mean
something else once you've "pushd +3".

I always find it hard to undo my sequence changes to get the stack in the same
order as before, so usually end up typing "dirs -v" a lot (or its alias) and
renumbering my ~N references.

~~~
Thrysoee
I frequent systems where tcsh, for historical reasons, is the default shell,
and for all its faults it does have some nice pushd settings that make
directory browsing with 'cd +<number>' and 'dirs' very convenient.

I have ported this functionality to Bash:
[http://thrysoee.dk/pushd/](http://thrysoee.dk/pushd/)

------
clumsysmurf
This reminds me of NCD (Norton Change Directory) which then went on to inspire
many tools, like the excellent KCD and WCD. These tools index rather than
create symlinks, though.

------
skriticos2
"Like many others, I spend most of my day behind a computer."

I tend to spend my time in front of one. Is there an advantage to being behind
it?

But jokes aside, I added this to my bashrc, looks useful.

------
BinRoo
I use CDargs [http://www.skamphausen.de/cgi-
bin/ska/CDargs](http://www.skamphausen.de/cgi-bin/ska/CDargs)

------
jijji
Not sure if the author knows or not, but there exists a BASH environment
variable called CDPATH which does the same thing, and is a lot easier to use.

~~~
nodata
[http://hints.macworld.com/article.php?story=2005031814311425](http://hints.macworld.com/article.php?story=2005031814311425)

------
gosukiwi
Watching all the comments, I think the author should create a repo so people
can fork or contribute instead of comment different versions :p

------
ChuckMcM
This is how I know I am old I create a symlinks in my home directory to oft
used locations and get there with cd ~/linkname Has the added bonus of making
my short path be ~/linkname rather than
~/some/very/deep/pocket/in/some/git/repo

------
wvh
Nice idea, reminds me of ncd from a far away, foggy past. I suggest some
escaping on the directory name parameter though. If you're not careful, you're
going to run into trouble with paths that have spaces or risk some nasty
security issues with embedded special characters.

------
nkuttler
That looks clever and useful, I wasn't expecting that. I do maintain a few
aliases to jump around, but this looks more efficient. Not sure though if I'll
like "jump foo" better than simply "foo" that I use now, but maintaining those
aliases is a pita.

------
kodango
I've add a new bash version based on Jeroen's code, it's more easier to use in
a Bash environment.

Welcome to use, thanks for Jeroen's smart work.

[https://github.com/dangoakachan/mark-
directory](https://github.com/dangoakachan/mark-directory)

------
timtadh
I have a similar tool but it also manages shell environment variables,
allowing you to jump around and/or switch working projects. You can check it
out at: [http://github.com/timtadh/swork](http://github.com/timtadh/swork)

~~~
mhitza
Without having me dig through the code, could you tell me in a few lines how
it works? (not usage, but how internally you managed to handle shell
environment vars, "clean after" finishing/switching, etc)

------
parski
I used some of this code to implement a more orthodox utility using flags
instead of different syntax for different commands.

[https://github.com/parski/Wormhole](https://github.com/parski/Wormhole)

It works great! Great blog post.

------
X4
My Z-Shell predicts and auto-completes everything I do often perfectly, thus
typing 2-3chars not only get's me deep into directories, but also do actions I
need. But maybe the idea of folder bookmarks can still be useful, idk.

------
ddoolin
I usually just alias directories I frequent in .bashrc... Easy enough, I
guess.

~~~
cgore
I'll do it all the time in my local shell session, along the following:

    
    
      # I make a point to always have the trailing slash,
      # it makes life easier.
      # Also, tab-complete works with this in Zsh.
      a=/some/really/long/path/that/I/dont/like/typing/
      b=/some/other/really/long/path/too/
      cd $a
      # ... do stuff ...
      cp one two three $b
      cd $b
      # ... do more stuff ...
      cp four five six $a
      cd $b/even/longer/path
    

And so forth. Since it is a normal variable, you can use it anywhere you need
the path.

------
dueyfinster
I've updated the completion code to work on ubuntu and os x:

[http://neil.grogan.ie/2013/08/quickly-
navigate.html](http://neil.grogan.ie/2013/08/quickly-navigate.html)

------
trentmick
[http://code.google.com/p/go-
tool/wiki/GettingStarted](http://code.google.com/p/go-
tool/wiki/GettingStarted) Works on all OSes.

------
jasminaata
Here is one that works with zsh:
[https://github.com/bufordtaylor/swiftcommandline](https://github.com/bufordtaylor/swiftcommandline)

------
straphka
This does look very similar to the setup I am using
([https://github.com/huyng/bashmarks](https://github.com/huyng/bashmarks))

------
th0br0
Or you might just use ZSH (particularly in combination with oh-my-zsh), keep
the marks around as zsh vars and skip all the symbolic linkage.

~~~
tiziano88
this way they would all be lost at the end of each session, and would not be
shared across concurrent sessions, no?

------
nawitus
Caps insensitive auto-complete is pretty handy. Add 'set completion-ignore-
case on' to '/etc/inputrc'.

------
arrowgunz
Try using [https://github.com/rupa/z](https://github.com/rupa/z)

------
srinivasanv
I've been looking for a way to make this less annoying, hanks!

------
mariusmg
I use powershell aliases for this. Works great.

------
nXqd
happy guaranteed [https://github.com/clvv/fasd](https://github.com/clvv/fasd)

------
xal

        brew install fasd
    

Thank me later

------
kodango
when mark name contains space, the auto complete doesn't work, anyone have
solutions?

