mirror of
https://git.decapod.one/brethil/dotfiles
synced 2024-11-24 20:41:31 +01:00
functions: add vimscratch
use `vimscratch` to open a scratch vim buffer. If run in a pipe, it uses `stdin` as input: ```bash <command> | vimscratch ```
This commit is contained in:
parent
4b73ed209f
commit
fbc6934f8f
12
functions/vim.zsh
Normal file
12
functions/vim.zsh
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# open vim with a scratch window that can be discarded on exit.
|
||||||
|
vimscratch() {
|
||||||
|
local args
|
||||||
|
# if running in a pipe, use stdin (-) as arg.
|
||||||
|
# -t checks if the given FD is a terminal
|
||||||
|
if [ -t 0 ] ; then
|
||||||
|
args="$@"
|
||||||
|
else
|
||||||
|
args="-"
|
||||||
|
fi
|
||||||
|
vim -c "set buftype=nofile" "$args"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user