Jumplist.sh

Tag: REFERENCE
Edit

Bash Jumping scripts

Oftentimes, I find myself switching between a lot of different projects at work. I've sat down and put together the following list of scripts to reduce on the amount of cd-ing that I do.

Also, it should be noted that these scripts are currently tuned to work with paths with spaces in them, a thing that bashmarks currently does not do.

This doesn't do auto-completion like bashmarks does, but is a decent amount simpler as a bonus.

.jumputils.sh


function jadd {

if [ -z "$1" ] ; then
        echo "Argument requiried for jump name!"
else
    sed "s?^#JUMP-ADD?$1\)\n\tcd \"$PWD\"\n\t\;\;\n#JUMP-ADD?" ~/.jumplist.sh -i.bak
    source ~/.jumplist.sh
fi

}

function jrm {
    #Remove a jump entry
if [ -z "$1" ] ; then
        echo "Argument requiried for jump name!"
else
    sed "/$1)/,/;;/d" ~/.jumplist.sh -i.bak
fi
}

function jl {
    # List the current jump entries in jumplist.sh
           gawk '
    /function j \{/ { SHOW=1 }
    /}/ && SHOW { SHOW=0 }
    SHOW && match($0,/(\w+)\)/,res) { name=res[1] } 
    SHOW && match($0,/cd ".+\/([^\/]+)"/, res) { foldername=res[1] } 
    SHOW &&/;;/ { print name, " -> ", foldername}' ~/.jumplist.sh

}

.jumplist.sh


source ~/.jumputils.sh

function j {

case $1 in
project) 
    cd "/c/Path/To/Project"
    ;;
#JUMP-ADD
esac

}

You can then source ~/.jumplist.sh in your .bashrc, and add/remove directories as needed via jadd and jrm