Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

function to run vim



A while I made a function so that I could keep one vim session (gvim
really) and that running 'vim file' would open the file in a new tab
in that session. Recently, it has stopped working.and I'm not sure
why. I get this:
vim --servername SWILSON --remote-tab  file
vimfunc:71: command not found: vim --servername SWILSON --remote-tab  file

which is just ${=cmd} which should run the command?


vimfunc () {
    local cmd
    local servername
    local remote
    local misc
    local version

    local username=$(echo $USER | tr "[:lower:]" "[:upper:]")

    local opt_ex="^-"

    while [ $# -gt 0 ] ; do
        case "$1" in
            --servername)
                if [[ $2 =~ $opt_ex ]] ; then
                    echo "Servername option without a parameter. Doing nothing."
                    return
                else
                    servername="$2"
                    shift
                fi
                ;;
            --remote*)
                if [ -z $remote ] ; then
                    if [[ $2 =~ $opt_ex ]] ; then
                        remote="$1"
                    else
                        remote="$1 $2"
                        shift
                    fi
                else
                    # I'll deal with this properly if it is reasonable
to take multiple --remote* things
                    echo "Should not call two remote options at once.
Doing nothing."
                    return
                fi
                ;;
            --version*)
                version="1"
                ;;
            *)
                misc="$misc $1"
                ;;
        esac
        shift
    done

    cmd="vim"

    if [ ! -z $servername ] ; then
        cmd="$cmd --servername $servername"
    else
        cmd="$cmd --servername $username"
    fi

    if [ -z $misc ] && [ -z $remote ] ; then
        # list version if we asked for that
        if [ ! -z version ] ; then
            cmd="$cmd --version"
        fi

        ${=cmd}
        return
    fi

    if [ ! -z $remote ] ; then
        cmd="$cmd $remote $misc"
    else
        cmd="$cmd --remote-tab $misc"
    fi

    echo $cmd
    ${=cmd}
    return
}



Messages sorted by: Reverse Date, Date, Thread, Author