A simple persistent DIRSTACK in bash
No Comments Yet so far
Leave a comment
January 3, 2008, 15:57
Filed under: Uncategorized
Filed under: Uncategorized
Here’s a simple way to use a persistent DIRSTACK in bash:
a script in your path called dhs saves your current DIRSTACK:
#!/bin/bash
dirs -l -p > /home/username/.drsk/pwdirs
And another one called dh to loads a dirstack from a file in ~/.drsk/, you may like to use different different dirstacks for separate projects:
#!/bin/bash
for i in `cat ~/.drsk/$1`;
do pushd $i > /dev/null 2>&1
done;
pushd +$( expr ${#DIRSTACK[@]} – 1 ) > /dev/null 2>&1
popd > /dev/null 2>&1
echo “DIRSTACK restored from ~/.drsk/$1″
dirs -v -l
and in your ~/.bashrc you can add:
source dh pwdirs
to load the default. When you adjust your working dirstack you can call `. dhs`to save it and each new terminal you open will use the same one.
Leave a Comment
No Comments Yet so far
Leave a comment
Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>