Live data from Hacker News

Quickly navigate your filesystem from the command line

jeroenjanssens.com

31–40 of 148 posts

Re: Quickly navigate your filesystem from the command line

#31

Earlier quoted context omitted.

z is so much more useful because it automatically learns which paths you use most often. There is no need to explicitly mark folders. It just works.

How does it differ from autojump?

I don't know autojump, but from a cursory look: z is written in pure shell, is a single file, no external dependencies. autojump requires python, thus likely has more features.

IMHO, just for jumping around directories, z is good enough.

Re: Quickly navigate your filesystem from the command line

#32
post #15

Earlier quoted context omitted.

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.

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.

Install new bash using brew :-) (1) http://apple.stackexchange.com/questions/55412/cd-to-a-direc...

Re: Quickly navigate your filesystem from the command line

#33

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 }

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}'
    }

Re: Quickly navigate your filesystem from the command line

#34

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

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

Re: Quickly navigate your filesystem from the command line

#36
post #28

Earlier quoted context omitted.

thanks! I tried: apt-get install ranger it says it's not available. any idea why ranger is not longer available in package manager?

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.

Debian "Squeeze" 6.0.7 x32

Re: Quickly navigate your filesystem from the command line

#38
post #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.

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.

Re: Quickly navigate your filesystem from the command line

#39
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…

So interesting since I've been using pratically the SAME idea for over an year now :D Shows how we arrive at nice solutions independently.

PS: I assume you are calling shortcuts.sh in your .profile - that way aliases are available across sessions.

Re: Quickly navigate your filesystem from the command line

#40
post #36

Earlier quoted context omitted.

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.

Debian "Squeeze" 6.0.7 x32

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 instead.
Post reply on HN