Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Another trick I learned from an older HN comment is to create a .marks directory in your home directory and then add the following to your .zshrc

  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/ -/ -/g' && echo
  }

  function _marks {
      reply=($(ls $MARKPATH))
  }

  compctl -K _marks jump
  compctl -K _marks unmark
Now to remember a directory you type

  % mark <any_string>
and to jump to that directory you type

  % jump <any_string>
To list all your shortcuts

  % marks
Depending on the version of ls you might have to change the -f9 parameter to -f8 for marks functions


Or just install autojump and be done with it ;-).

https://github.com/joelthelion/autojump


You can use hop to similar end, and it's got support for shortest unique name and tab completion. https://github.com/Cue/hop


I have a minimal take on this: j <project> to jump to any directory below ~/Projects. Supports tab completion, as it should.

https://github.com/mattgreen/dotfiles/blob/master/zsh/jump.z...


I prefer using z, which is purely written in bash.

https://github.com/rupa/z




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: