Skip to content

Instantly share code, notes, and snippets.

@konradkonrad
Forked from schmir/.sh
Created January 31, 2019 11:30

Revisions

  1. @schmir schmir created this gist Jan 31, 2019.
    33 changes: 33 additions & 0 deletions .sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    # When Tab is pressed on an empty(!) command line, the contents of the
    # directory are printed (`ls`) instead of a menu list of all
    # executables:

    function my-hg-report() {
    tip=$(hg tip 2> /dev/null) || return
    echo
    hg --config pager.pager= status
    echo
    hg --config pager.pager= log --limit 5 --style compact
    }

    function my-git-report() {
    ref=$(git symbolic-ref HEAD 2> /dev/null) || return
    echo "------------------------------------------------------------"
    git status
    echo "------------------------------------------------------------"
    git log --pretty=tformat:"%ae %ci%C(bold)%d%Creset%n%h: %s%n" -3 --color |cat
    echo
    }

    function complete-or-list() {
    if [[ $#BUFFER == 0 ]]; then
    echo
    ls -F
    my-git-report || my-hg-report
    zle reset-prompt
    else
    zle expand-or-complete
    fi
    }
    zle -N complete-or-list
    bindkey '^I' complete-or-list