Skip to content

Instantly share code, notes, and snippets.

@yonchu
Created November 19, 2012 12:55

Revisions

  1. yonchu created this gist Nov 19, 2012.
    21 changes: 21 additions & 0 deletions edit-command.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/bin/sh
    #
    # Edit command source
    #

    if [ $# -lt 1 ]; then
    echo 'Should specify commands you want to edit' 1>&2
    exit 1
    fi

    cmds=()
    while [ $# -gt 0 ]; do
    cmds+=($(which "$1" 2> /dev/null))
    [ $? -ne 0 ] && echo "Command not found: $1" 1>&2
    shift
    done

    if [ ${#cmds[@]} -lt 1 ]; then
    exit 1
    fi
    exec ${EDITOR:-vim} "${cmds[@]}"