Live data from Hacker News

Quickly navigate your filesystem from the command line

jeroenjanssens.com

21–30 of 148 posts

Re: Quickly navigate your filesystem from the command line

#21
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 :-|

Re: Quickly navigate your filesystem from the command line

#24

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

I was in the process of doing this myself and though "I wonder if it's already been posted in the comments". Thank you!

Re: Quickly navigate your filesystem from the command line

#25

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

I was in the process of doing this myself and though "I wonder if it's already been posted in the comments". Thank you!

I just signed in to post almost exactly this function!

Re: Quickly navigate your filesystem from the command line

#26
post #15

A handy alias I use: alias ..='cd ..' Moving up the file tree has never been easier!

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.

I believe this is set by default in oh-my-zsh as well.

Re: Quickly navigate your filesystem from the command line

#28

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

thanks! I tried: apt-get install ranger

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

Re: Quickly navigate your filesystem from the command line

#29
post #7

You might want to check out z: https://github.com/rupa/z

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?

Re: Quickly navigate your filesystem from the command line

#30
post #28

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

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