zsh-users
 help / color / mirror / code / Atom feed
* function to run vim
@ 2013-11-13 11:18 shawn wilson
  2013-11-13 17:13 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: shawn wilson @ 2013-11-13 11:18 UTC (permalink / raw)
  To: Zsh Users

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
}


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-11-14  1:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-13 11:18 function to run vim shawn wilson
2013-11-13 17:13 ` Bart Schaefer
2013-11-14  1:24   ` shawn wilson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).