Skip to content
Snippets Groups Projects
Select Git revision
  • a4290b5f70952a7d41a4509d627e55264a6e23df
  • master default
2 results

part-r-00036

Blame
  • watch.plugin.zsh 810 B
    # ------------------------------------------------------------------------------
    # Description
    # -----------
    #
    # watch will be inserted before the command
    #
    # ------------------------------------------------------------------------------
    # Authors
    # -------
    #
    # * Connard <baptiste.gc@student-cs.fr>
    #
    # ------------------------------------------------------------------------------
    
    watch-command-line() {
        [[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)"
        if [[ $BUFFER == watch\ * ]]; then
            if [[ ${#LBUFFER} -le 4 ]]; then
                RBUFFER="${BUFFER#watch }"
                LBUFFER=""
            else
                LBUFFER="${LBUFFER#watch }"
            fi
        else
            LBUFFER="watch $LBUFFER"
        fi
    }
    
    zle -N watch-command-line
    
    # Defined shortcut keys: [Alt] [Esc]
    bindkey '^\e' watch-command-line