3 ms·
cool! I'm a command-line junkie as well. So, I've been doing something similar for quite a while. Here's what I have done : function ccb () {
by anjanb 13y ago
cool!
I'm a command-line junkie as well.
So, I've been doing something similar for quite a while.
Here's what I have done :
function ccb ()
{
FOO=`pwd`;
echo >> ~/shortcuts.sh;
echo alias $1=\'pushd $FOO\' >> ~/shortcuts.sh;
echo >> ~/shortcuts.sh;
. ~/shortcuts.sh
}
simple but quite effective.
Now, all I have to do is type ccb and give a shortcut name to register a shortcut. Then whenever i want to jump to that directory, I just have to type the shortcut.
Eg :
foo@bar deeply-nested-dir# ccb deepd
foo@bar deeply-nested-dir# cd
foo@bar ~# deepd
foo@bar deeply-nested-dir#
My method lacks the a) delete shortcut and b) list shortcut features that the above solution gives, though.
- IanCal 13y agoHN uses markdown, stick 4 spaces before each line in your code blocks to get them to indent properly, and drop the <br> function ccb () { FOO=`pwd`; echo >> ~/shortcuts.sh; echo alias $1=\'pushd $FOO\' >> ~/shortcuts.sh; echo >> ~/shortcuts.sh; . ~/shortcuts.sh }
- anjanb 13y agothanks for letting me know -- I've edited my comment.
- noisy_boy 13y agoSo interesting since I've been using pratically the SAME idea for over an year now :D Shows how we arrive at nice solutions independently. PS: I assume you are calling shortcuts.sh in your .profile - that way aliases are available across sessions.
- anjanb 13y agoyes. I call shortcuts.sh from my .bashrc