Live data from Hacker News

Quickly navigate your filesystem from the command line

jeroenjanssens.com

1–10 of 148 posts

Re: Quickly navigate your filesystem from the command line

#4
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.

Re: Quickly navigate your filesystem from the command line

#6
post #4

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 dire…

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

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

Re: Quickly navigate your filesystem from the command line

#8
post #6
post #4

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 dire…

HN uses markdown, stick 4 spaces before each line in your code blocks to get them to indent properly, and drop the function ccb () { FOO=`pwd`; echo >> ~/shortcuts.sh; echo alias $1=\'pushd $FOO\' >> ~/shortcuts.sh; echo >> ~/shortcuts.sh; . ~/shortcuts.sh }

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

Re: Quickly navigate your filesystem from the command line

#10
I also do something similar but slightly different: https://github.com/roobert/dotfiles/blob/master/.zsh/robs/fu...

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.

Post reply on HN