1 ### why the heck something like this in not on by default? ###
4 function N_avigush_help
() {
7 # [l | list] : list dirs
9 # [s | switch] [args] : push current, then 'cd args'
10 # [g | go] <num> : go to <num> directory from list
11 # [n | navigate] <num> : push current, then 'N g <num>'
12 # better be in range with that <num>
13 # [e | erase] <num> : remove <num>th dir from list
14 # [c | clear] : clear current list completely
16 # [d | dump] [file] : dump dirs to <file> or ~/.avigush
17 # [r | restore] [file] : restore from <file> or ~/.avigush
22 function N_avigush_list
() {
23 dirs -l -p -v |
egrep -v "^.*0[[:blank:]]+/"
26 # switch to dir saving current
27 function N_avigush_switch
() {
28 pushd .
> /dev
/null
; cd "$@" ;
31 # go to Nth dir in stack
32 function N_avigush_go
() {
33 # Zsh knows not the 'dirs +/-N' but 'cd +/-N'
34 cd $
(N l |
egrep "^.*$1[[:blank:]]+/" |
sed 's|^[^/]*||')
37 # go to Nth while pushing current for later... n as in navigate
38 function N_avigush_navigate
() {
39 pushd .
> /dev
/null
; N g $
(($1+1)) ;
43 function N_avigush_erase
() {
48 function N_avigush_clear
() {
52 # save to default or some file
53 function N_avigush_dump
() {
54 local FILE
=${1:-$HOME/.avigush}
55 echo "# dump($FILE)" ;
57 sed 's,^[^/]*,,g' 2>/dev
/null
> "$FILE" &&
62 # restore from file, bash sucks monkey ballz... forealz!
63 function N_avigush_restore
() {
65 local FILE
=${1:-$HOME/.avigush}
67 echo "# file($FILE) not readable" ; return ;
69 echo "# load($FILE)" ;
70 IFS
=$
'\n' ; for d
in `cat $FILE` ; do
75 done && echo "# done" ||
82 h|
help) N_avigush_help
;;
83 l|list
) N_avigush_list
;;
84 s|switch
) shift ; N_avigush_switch
"$@" ;;
85 g|go
) shift ; N_avigush_go
"$@" ;;
86 n|navigate
) shift ; N_avigush_navigate
"$@" ;;
87 e|erase
) shift ; N_avigush_erase
"$@" ;;
88 c|
clear) N_avigush_clear
;;
89 d|dump
) shift ; N_avigush_dump
"$@" ;;
90 r|restore
) shift ; N_avigush_restore
"$@" ;;
95 # BIGFATNOTE: unlimited number of dirs regex might cut smth off.