chezmoi init
This commit is contained in:
commit
530d6d7195
1176 changed files with 111325 additions and 0 deletions
82
dot_oh-my-zsh/plugins/vim-interaction/README.md
Normal file
82
dot_oh-my-zsh/plugins/vim-interaction/README.md
Normal file
|
@ -0,0 +1,82 @@
|
|||
# Vim Interaction #
|
||||
|
||||
The idea for this script is to give you some decent interaction with a running
|
||||
GVim session. Normally you'll be running around your filesystem doing any
|
||||
number of amazing things and you'll need to load some files into GVim for
|
||||
editing, inspecting, destruction, or other bits of mayhem. This script lets you
|
||||
do that.
|
||||
|
||||
## Usage
|
||||
|
||||
The plugin presents a function called `callvim` whose usage is:
|
||||
|
||||
usage: callvim [-b cmd] [-a cmd] [file ... fileN]
|
||||
|
||||
-b cmd Run this command in GVIM before editing the first file
|
||||
-a cmd Run this command in GVIM after editing the first file
|
||||
file The file to edit
|
||||
... fileN The other files to add to the argslist
|
||||
|
||||
## Aliases ##
|
||||
|
||||
There are a few aliases presented as well:
|
||||
|
||||
* `v` A shorthand for `callvim`
|
||||
* `vvsp` Edits the passed in file but first makes a vertical split
|
||||
* `vhsp` Edits the passed in file but first makes a horizontal split
|
||||
|
||||
## Post Callout ##
|
||||
|
||||
At the end of the `callvim` function we invoke the `postCallVim` function if it
|
||||
exists. If you're using MacVim, for example, you could define a function that
|
||||
brings window focus to it after the file is loaded:
|
||||
|
||||
function postCallVim
|
||||
{
|
||||
osascript -e 'tell application "MacVim" to activate'
|
||||
}
|
||||
|
||||
This'll be different depending on your OS / Window Manager.
|
||||
|
||||
## Examples ##
|
||||
|
||||
This will load `/tmp/myfile.scala` into the running GVim session:
|
||||
|
||||
> v /tmp/myfile.scala
|
||||
|
||||
This will load it after first doing a vertical split:
|
||||
|
||||
> vvsp /tmp/myfile.scala
|
||||
or
|
||||
> v -b':vsp' /tmp/myfile.scala
|
||||
|
||||
This will load it after doing a horizontal split, then moving to the bottom of
|
||||
the file:
|
||||
|
||||
> vhsp -aG /tmp/myfile.scala
|
||||
or
|
||||
> v -b':sp' -aG /tmp/myfile.scala
|
||||
|
||||
This will load the file and then copy the first line to the end (Why you would
|
||||
ever want to do this... I dunno):
|
||||
|
||||
> v -a':1t$' /tmp/myfile.scala
|
||||
|
||||
And this will load all of the `*.txt` files into the args list:
|
||||
|
||||
> v *.txt
|
||||
|
||||
If you want to load files into areas that are already split, use one of the
|
||||
aliases for that:
|
||||
|
||||
# Do a ':wincmd h' first
|
||||
> vh /tmp/myfile.scala
|
||||
|
||||
# Do a ':wincmd j' first
|
||||
> vj /tmp/myfile.scala
|
||||
|
||||
# Do a ':wincmd k' first
|
||||
> vk /tmp/myfile.scala
|
||||
|
||||
# Do a ':wincmd l' first
|
||||
> vl /tmp/myfile.scala
|
|
@ -0,0 +1,69 @@
|
|||
#
|
||||
# See README.md
|
||||
#
|
||||
# Derek Wyatt (derek@{myfirstnamemylastname}.org
|
||||
#
|
||||
|
||||
function callvim {
|
||||
if [[ $# == 0 ]]; then
|
||||
cat <<EOH
|
||||
usage: callvim [-b cmd] [-a cmd] [-n name] [file ... fileN]
|
||||
|
||||
-b cmd Run this command in GVIM before editing the first file
|
||||
-a cmd Run this command in GVIM after editing the first file
|
||||
-n name Name of the GVIM server to connect to
|
||||
file The file to edit
|
||||
... fileN The other files to add to the argslist
|
||||
EOH
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Look up the newest instance or start one
|
||||
local name="$(gvim --serverlist | tail -n 1)"
|
||||
[[ -n "$name" ]] || {
|
||||
# run gvim or exit if it fails
|
||||
gvim || return $?
|
||||
|
||||
# wait for gvim instance to fully load
|
||||
while name=$(gvim --serverlist) && [[ -z "$name" ]]; do
|
||||
sleep 0.1
|
||||
done
|
||||
}
|
||||
|
||||
local before="<esc>" files after cmd
|
||||
|
||||
while getopts ":b:a:n:" option
|
||||
do
|
||||
case $option in
|
||||
a) after="$OPTARG"
|
||||
;;
|
||||
b) before="$OPTARG"
|
||||
;;
|
||||
n) name="$OPTARG"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
|
||||
# If before or after commands begin with : and don't end with <cr>, append it
|
||||
[[ ${after} = :* && ${after} != *\<cr\> ]] && after+="<cr>"
|
||||
[[ ${before} = :* && ${before} != *\<cr\> ]] && before+="<cr>"
|
||||
# Open files passed (:A means abs path resolving symlinks, :q means quoting special chars)
|
||||
[[ $# -gt 0 ]] && files=':args! '"${@:A:q}<cr>"
|
||||
# Pass the built vim command to gvim
|
||||
cmd="$before$files$after"
|
||||
|
||||
# Run the gvim command
|
||||
gvim --servername "$name" --remote-send "$cmd" || return $?
|
||||
|
||||
# Run postCallVim if defined (maybe to bring focus to gvim, see README)
|
||||
(( ! $+functions[postCallVim] )) || postCallVim
|
||||
}
|
||||
|
||||
alias v=callvim
|
||||
alias vvsp="callvim -b':vsp'"
|
||||
alias vhsp="callvim -b':sp'"
|
||||
alias vk="callvim -b':wincmd k'"
|
||||
alias vj="callvim -b':wincmd j'"
|
||||
alias vl="callvim -b':wincmd l'"
|
||||
alias vh="callvim -b':wincmd h'"
|
Loading…
Add table
Add a link
Reference in a new issue