Ticket #23239: patch-contrib-cdargs-bash.sh.diff

File patch-contrib-cdargs-bash.sh.diff, 2.1 KB (added by jan@…, 15 years ago)

patch file for adding zsh compatibility to cdargs

  • contrib/cdargs-bash.sh

    old new  
    1111CDARGS_SORT=0   # set to 1 if you want mark to sort the list
    1212CDARGS_NODUPS=1 # set to 1 if you want mark to delete dups
    1313
     14# Support ZSH via its BASH completion emulation
     15if [ -n "$ZSH_VERSION" ]; then
     16    autoload bashcompinit
     17    bashcompinit
     18fi
     19
     20
    1421# --------------------------------------------- #
    1522# Run the cdargs program to get the target      #
    1623# directory to be used in the various context   #
     
    142149# @access public                                #
    143150# @return void                                  #
    144151# --------------------------------------------- #
    145 function cdb () 
    146 { 
     152function cdb ()
     153{
    147154    local dir
    148155
    149156    _cdargs_get_dir "$1" && cd "$dir" && echo `pwd`;
     
    161168# @access public                                #
    162169# @return void                                  #
    163170# --------------------------------------------- #
    164 function mark () 
    165 { 
     171function mark ()
     172{
    166173    local tmpfile
    167174
    168175    # first clear any bookmarks with this same alias, if file exists
    169     if [[ "$CDARGS_NODUPS" && -e "$HOME/.cdargs" ]]; then
     176    if [ "$CDARGS_NODUPS" ] && [ -e "$HOME/.cdargs" ]; then
    170177        tmpfile=`echo ${TEMP:-${TMPDIR:-/tmp}} | sed -e "s/\\/$//"`
    171178        tmpfile=$tmpfile/cdargs.$USER.$$.$RANDOM
    172179        grep -v "^$1 " "$HOME/.cdargs" > $tmpfile && 'mv' -f $tmpfile "$HOME/.cdargs";
    173180    fi
    174181    # add the alias to the list of bookmarks
    175     cdargs --add=":$1:`pwd`"; 
     182    cdargs --add=":$1:`pwd`";
    176183    # sort the resulting list
    177184    if [ "$CDARGS_SORT" ]; then
    178185        sort -o "$HOME/.cdargs" "$HOME/.cdargs";
    179186    fi
    180187}
    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
    183190# carreer and will always be aliased to less...
    184191# alias m='mark'
    185192
     
    198205function ca ()
    199206{
    200207    # add the alias to the list of bookmarks
    201     cdargs --add=":$1:`pwd`"; 
     208    cdargs --add=":$1:`pwd`";
    202209}
    203210
    204211# --------------------------------------------- #