Hacker News new | ask | show | jobs
by hifi 4682 days ago
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.