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 -- 7 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 -- 7 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 -- 7 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 -- 6 months 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/

5. anonymous -- 4 months ago

Truly, I am dazzled with the Multidisciplinary Approach that has been offered by the Kate Jeffers in that service. Reading best essay service review is advised. Like Kate Jeffers, I figure we ought to follow a multidisciplinary approach as opposed to adhering to the equivalent customary one.

6. Mike Rooney -- 3 months ago

Pretty cool post. It’s really very nice and useful post. Keep it up!!<a href="https://www.celebsmoviejackets.com/riverdale-southside-serpents-leather-jacket">Riverdale Leather Jackets</a>

7. stephanstark11@gmail.com -- 5 weeks ago

Thankfully! This is absolutely astonishing and delightful post. This post is much similar to the Avengers Jacket article. I’m pleased to share the appreciated information.

8. stephanstark11@gmail.com -- 5 weeks ago

The writer makes a great and articulate point in this article and comparable to the Fallout 76 Jacket article. I really inspired and appreciate him.

9. Mason Robert -- 5 weeks ago

How does this function _listcd works? I have checked all the other methods manually but it is not working. As the No 1 Content Writers, we also do have to work on multiple tasks at times and sometimes we just forget to save our documents. I hope, this code will also work in my case.

10. anonymous -- 3 weeks ago

Its a great pleasure reading your post.Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great work. Look for instagram at https://www.storiesig2.com/

Add New Comment