From: shawn wilson <ag4ve.us@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: function to run vim
Date: Wed, 13 Nov 2013 06:18:57 -0500 [thread overview]
Message-ID: <CAH_OBicAK=-Kkz9b8T9oDZAgvb+DWToUMSVh2oN2fx_WBioRgQ@mail.gmail.com> (raw)
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
}
next reply other threads:[~2013-11-13 11:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-13 11:18 shawn wilson [this message]
2013-11-13 17:13 ` Bart Schaefer
2013-11-14 1:24 ` shawn wilson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAH_OBicAK=-Kkz9b8T9oDZAgvb+DWToUMSVh2oN2fx_WBioRgQ@mail.gmail.com' \
--to=ag4ve.us@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).