Skip to content

Instantly share code, notes, and snippets.

@lucacervasio
Last active December 22, 2015 00:59
Show Gist options
  • Select an option

  • Save lucacervasio/6393682 to your computer and use it in GitHub Desktop.

Select an option

Save lucacervasio/6393682 to your computer and use it in GitHub Desktop.

Revisions

  1. lucacervasio revised this gist Aug 30, 2013. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions jump.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@
    # I made some small changes to this: http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html
    # to install run:
    # curl https://gist.github.com/lucacervasio/6393682/raw/ed29372885669a68597701db58f95a50db2d7426/gistfile1.txt >> ~/.bashrc; mkdir ~/.marks
    # to install: curl https://raw.github.com/gist/6393682 >> ~/.bashrc; mkdir ~/.marks


    export MARKPATH=$HOME/.marks
  2. lucacervasio revised this gist Aug 30, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion jump.sh
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ function mark {
    mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$1"
    }
    function unmark {
    rm "$MARKPATH/$1"
    rm -f "$MARKPATH/$1"
    }

    # linux
  3. lucacervasio revised this gist Aug 30, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion jump.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    # I made some small changes to this http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html
    # I made some small changes to this: http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html
    # to install run:
    # curl https://gist.github.com/lucacervasio/6393682/raw/ed29372885669a68597701db58f95a50db2d7426/gistfile1.txt >> ~/.bashrc; mkdir ~/.marks


    export MARKPATH=$HOME/.marks
    function jump {
    cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
  4. lucacervasio renamed this gist Aug 30, 2013. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions gistfile1.txt → jump.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    # I made some small changes to this http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html
    # curl https://gist.github.com/lucacervasio/6393682/raw/ed29372885669a68597701db58f95a50db2d7426/gistfile1.txt >> ~/.bashrc; mkdir ~/.marks

    export MARKPATH=$HOME/.marks
    function jump {
    cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
  5. lucacervasio revised this gist Aug 30, 2013. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ function mark {
    mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$1"
    }
    function unmark {
    rm -i "$MARKPATH/$1"
    rm "$MARKPATH/$1"
    }

    # linux
    @@ -26,4 +26,5 @@ _completemarks() {
    return 0
    }

    complete -F _completemarks jump unmark
    alias j=jump
    complete -F _completemarks jump unmark j
  6. lucacervasio created this gist Aug 30, 2013.
    29 changes: 29 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    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"
    }

    # linux
    function marks {
    ls -l "$MARKPATH" | sed 's/ / /g' | cut -d' ' -f9- | sed 's/ -/\t-/g' && echo
    }

    # osx
    #function marks {
    # \ls -l "$MARKPATH" | tail -n +2 | sed 's/ / /g' | cut -d' ' -f9- | awk -F ' -> ' '{printf "%-10s -> %s\n", $1, $2}'
    #}

    _completemarks() {
    local curw=${COMP_WORDS[COMP_CWORD]}
    local wordlist=$(find $MARKPATH -type l -printf "%f\n")
    COMPREPLY=($(compgen -W '${wordlist[@]}' -- "$curw"))
    return 0
    }

    complete -F _completemarks jump unmark