blob: bb1fb02e72c4cdca36728eb307be097171e6a592 [file] [log] [blame]
Daniel Engele56c71a2011-03-14 20:36:25 -04001# Directory stack navigation:
2#
3# Add to stack with: pu /path/to/directory
4# Delete current dir from stack with: po
5# Show stack with: d
6# Jump to location by number.
7
Erich Smith55e77de2012-05-11 23:27:03 -04008cite about-plugin
Erich Smith08e439c2012-05-13 08:37:31 -04009about-plugin 'directory stack navigation'
Erich Smith55e77de2012-05-11 23:27:03 -040010
Daniel Engele56c71a2011-03-14 20:36:25 -040011# Show directory stack
12alias d="dirs -v -l"
13
14# Change to location in stack bu number
15alias 1="pushd"
16alias 2="pushd +2"
17alias 3="pushd +3"
18alias 4="pushd +4"
19alias 5="pushd +5"
20alias 6="pushd +6"
21alias 7="pushd +7"
22alias 8="pushd +8"
23alias 9="pushd +9"
24
25# Clone this location
26alias pc="pushd \`pwd\`"
27
28# Push new location
29alias pu="pushd"
30
31# Pop current location
32alias po="popd"
33
34function dirs-help() {
Erich Smith08e439c2012-05-13 08:37:31 -040035 about 'directory navigation alias usage'
36 group 'dirs'
Erich Smith55e77de2012-05-11 23:27:03 -040037
Daniel Engele56c71a2011-03-14 20:36:25 -040038 echo "Directory Navigation Alias Usage"
39 echo
40 echo "Use the power of directory stacking to move"
41 echo "between several locations with ease."
42 echo
43 echo "d : Show directory stack."
44 echo "po : Remove current location from stack."
45 echo "pc : Adds current location to stack."
46 echo "pu <dir>: Adds given location to stack."
47 echo "1 : Chance to stack location 1."
48 echo "2 : Chance to stack location 2."
49 echo "3 : Chance to stack location 3."
50 echo "4 : Chance to stack location 4."
51 echo "5 : Chance to stack location 5."
52 echo "6 : Chance to stack location 6."
53 echo "7 : Chance to stack location 7."
54 echo "8 : Chance to stack location 8."
55 echo "9 : Chance to stack location 9."
56}
Yakkala Yagnesh Raghavac6e096e2011-08-06 00:14:15 +090057
58
59# ADD BOOKMARKing functionality
60# usage:
61
62if [ ! -f ~/.dirs ]; then # if doesn't exist, create it
63 touch ~/.dirs
64else
65 source ~/.dirs
66fi
67
68alias L='cat ~/.dirs'
69
70G () { # goes to distination dir otherwise , stay in the dir
Erich Smith08e439c2012-05-13 08:37:31 -040071 about 'goes to destination dir'
72 param '1: directory'
Erich Smith55e77de2012-05-11 23:27:03 -040073 example '$ G ..'
Erich Smith08e439c2012-05-13 08:37:31 -040074 group 'dirs'
Erich Smith55e77de2012-05-11 23:27:03 -040075
Yakkala Yagnesh Raghavac6e096e2011-08-06 00:14:15 +090076 cd ${1:-$(pwd)} ;
77}
78
79S () { # SAVE a BOOKMARK
Erich Smith08e439c2012-05-13 08:37:31 -040080 about 'save a bookmark'
81 group 'dirs'
Erich Smith55e77de2012-05-11 23:27:03 -040082
Yakkala Yagnesh Raghavadcdfd662011-08-06 01:01:17 +090083 sed "/$@/d" ~/.dirs > ~/.dirs1;
Yakkala Yagnesh Raghavac6e096e2011-08-06 00:14:15 +090084 \mv ~/.dirs1 ~/.dirs;
85 echo "$@"=\"`pwd`\" >> ~/.dirs;
86 source ~/.dirs ;
87}
88
89R () { # remove a BOOKMARK
Erich Smith08e439c2012-05-13 08:37:31 -040090 about 'remove a bookmark'
91 group 'dirs'
Erich Smith55e77de2012-05-11 23:27:03 -040092
Yakkala Yagnesh Raghavadcdfd662011-08-06 01:01:17 +090093 sed "/$@/d" ~/.dirs > ~/.dirs1;
Yakkala Yagnesh Raghavac6e096e2011-08-06 00:14:15 +090094 \mv ~/.dirs1 ~/.dirs;
95}
96
97alias U='source ~/.dirs' # Update BOOKMARK stack
98# set the bash option so that no '$' is required when using the above facility
99shopt -s cdable_vars