Jumping around in bash shell

I jump around a lot in the terminal between different projects and activities. To avoid endless typing I have created aliases which allows me to quickly perform this task.

By adding the following entries to your .bashrc you will give access to the powerfull tools of jcd scd lcd. First and foremost goto a directory you would like to earmark. Type scd <alias-of-choice> and your entry will be stored. To go back to this directory type jcd <stored-alias> and you arrived at your destination. Tab completion also works to save typing some more.

function jcd {
        cd "$(grep "${1:-blank} /" ~/.jcd | cut -d' ' -f  2-)"
}

function scd {
        ( grep -v "^${1:-blank} /" ~/.jcd; echo ${1:-blank} `pwd` ) > ~/.jcd.new
        mv ~/.jcd.new ~/.jcd
}

function lcd {
        cat ~/.jcd | sed 's/ /\t = /'
}

function _listcd {
        COMPREPLY=()
        cur="${COMP_WORDS[COMP_CWORD]}"
        opts=$(awk '{print $1}' ~/.jcd | grep "^$2")
        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
        return 0
}

complete -F _listcd jcd
complete -F _listcd scd

Comments

1. anonymous -- 2 months ago

These stupid rules tend to mean people have to spend money just to get what they want. This is of course not a smart idea especially for people who may be struggling with financial problems. So, what else is a person supposed to do when they really can't afford to buy anything. By buy tiktok followers

2. Hilary Brown -- 2 months ago

I find this codes helpful for my new project that I am creating now. I am searching for answers in the internet and yet failed but now I am seeing hopes and solutions to my problem. | free classic solitaire download

3. anonymous -- 2 months ago

The volume of the content of websites is increasing for the viewers. Now, what content to see and which to delay is hard question. The procedure of the cheap ahrefs accounts made possible through SEO for the viewer because some sites appear first before others due to this technique and method. https://seotoolsaccess.com/

4. anonymous -- 4 weeks ago

My freind shared your article with me! I visit first time here and i must say that the way of presentation is very good. Thank you so much for sharing such an great information with us. Please coming site https://192168ll.me/

Add New Comment