News for hackers. Stuff that matters.
Re:Cd Is Wasting Your Time by btown on Wednesday March 28, 2018 @01:45AM (#16695647)
I use code based on http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-f... and the discussion thread https://news.ycombinator.com/item?id=6229001 - no need for Python or something extra to install, similar semantics, just put this in .bash_profile:

    export MARKPATH=$HOME/.marks
    function j {
        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" | tail -n +2 | sed 's/  / /g' | cut -d' ' -f9- | awk -F ' -> ' '{printf "%-10s -> %s\n", $1, $2}'
    }
    function _jump {
      local cur=${COMP_WORDS[COMP_CWORD]}
      local marks=$(find $MARKPATH -type l | awk -F '/' '{print $NF}')
      COMPREPLY=($(compgen -W '${marks[@]}' -- "$cur"))
      return 0
    }
    complete -o default -o nospace -F _jump j
With multiple projects and codebases going on at once, it's an invaluable tool.

There are no comments on this comment yet.