Ticket #23239: patch-contrib-cdargs-bash.sh.diff
File patch-contrib-cdargs-bash.sh.diff, 2.1 KB (added by jan@…, 15 years ago) |
---|
-
contrib/cdargs-bash.sh
old new 11 11 CDARGS_SORT=0 # set to 1 if you want mark to sort the list 12 12 CDARGS_NODUPS=1 # set to 1 if you want mark to delete dups 13 13 14 # Support ZSH via its BASH completion emulation 15 if [ -n "$ZSH_VERSION" ]; then 16 autoload bashcompinit 17 bashcompinit 18 fi 19 20 14 21 # --------------------------------------------- # 15 22 # Run the cdargs program to get the target # 16 23 # directory to be used in the various context # … … 142 149 # @access public # 143 150 # @return void # 144 151 # --------------------------------------------- # 145 function cdb () 146 { 152 function cdb () 153 { 147 154 local dir 148 155 149 156 _cdargs_get_dir "$1" && cd "$dir" && echo `pwd`; … … 161 168 # @access public # 162 169 # @return void # 163 170 # --------------------------------------------- # 164 function mark () 165 { 171 function mark () 172 { 166 173 local tmpfile 167 174 168 175 # first clear any bookmarks with this same alias, if file exists 169 if [ [ "$CDARGS_NODUPS" && -e "$HOME/.cdargs" ]]; then176 if [ "$CDARGS_NODUPS" ] && [ -e "$HOME/.cdargs" ]; then 170 177 tmpfile=`echo ${TEMP:-${TMPDIR:-/tmp}} | sed -e "s/\\/$//"` 171 178 tmpfile=$tmpfile/cdargs.$USER.$$.$RANDOM 172 179 grep -v "^$1 " "$HOME/.cdargs" > $tmpfile && 'mv' -f $tmpfile "$HOME/.cdargs"; 173 180 fi 174 181 # add the alias to the list of bookmarks 175 cdargs --add=":$1:`pwd`"; 182 cdargs --add=":$1:`pwd`"; 176 183 # sort the resulting list 177 184 if [ "$CDARGS_SORT" ]; then 178 185 sort -o "$HOME/.cdargs" "$HOME/.cdargs"; 179 186 fi 180 187 } 181 # Oh, no! Not overwrite 'm' for stefan! This was 182 # the very first alias I ever wrote in my un*x 188 # Oh, no! Not overwrite 'm' for stefan! This was 189 # the very first alias I ever wrote in my un*x 183 190 # carreer and will always be aliased to less... 184 191 # alias m='mark' 185 192 … … 198 205 function ca () 199 206 { 200 207 # add the alias to the list of bookmarks 201 cdargs --add=":$1:`pwd`"; 208 cdargs --add=":$1:`pwd`"; 202 209 } 203 210 204 211 # --------------------------------------------- #