Cover V05, I04
Article
Listing 1
Listing 2
Listing 3
Listing 4
Listing 5
Listing 6

apr96.tar


Listing 4: .bashrc

# aliases for pushd
# create the number you need

alias pd='pushd'
alias pd2='pushd +2'
alias pd3='pushd +3'
alias pd4='pushd +4'
alias pd5='pushd +5'
alias pd6='pushd +6'
alias pd7='pushd +7'
alias pd8='pushd +8'
alias pd9='pushd +9'
alias pd10='pushd +10'
alias pd11='pushd +11'
alias pd12='pushd +12'
alias pd13='pushd +13'
alias pd14='pushd +14'
alias pd15='pushd +15'
alias pd16='pushd +16'
alias pd17='pushd +17'
alias pd18='pushd +18'
alias pd19='pushd +19'

alias ds=dirs

# save the dirstack
alias sd="dirs > ~/.bash_dirs"

# set a variable to the current dir
function dset() {
eval $1=$PWD
}

# long listing of dirstack
function dl() {

declare -i dir_num

# start with the top of the stack = 0
dir_num=0

# loop over the current dirstack and print each one
# with its stack number
for dir in `dirs` ; do
echo -e " $dir_num	$dir"
let dir_num+=1;
done
}

# get the saved dirstack

function gd() {

local dir_file
local dir_list
local dir
declare -i dir_cnt

dir_file='~/.dirstack'

# check that the dir file exists
if [ ! -e $dir_file ] ; then
echo $dir_file does not exist
return
fi

# read in the dir stack
read dir_list < ~/.bash_dirs

# set the argument list and get its count
set $dir_list
dir_cnt=$#

dir=`index $dir_cnt $dir_list`
eval "dir=$dir"

if [ -d $dir ] ; then
builtin cd $dir
fi

let dir_cnt-=1

while [ $dir_cnt -gt 0 ] ; do

dir=`index $dir_cnt $dir_list`
eval "dir=$dir"

if [ -d $dir ] ; then
builtin pushd $dir >/dev/null
fi
let dir_cnt-=1
done
}

function index (){

declare -i word_ind

word_ind=$1
shift

eval echo "\${$word_ind}"

}