1
0
mirror of https://git.decapod.one/brethil/dotfiles synced 2024-11-23 12:01:30 +01:00

zsh: vimscratch: add filetype arg

Allows setting filetype for vimscratch command.

Usage: `<command> | vimscratch [filetype]`.

For example:

```bash
curl https://myip.wtf/json | vimscratch json
```
Will open the output of the curl command as a json
temporary file in vim.
This commit is contained in:
bretello 2023-10-25 11:45:54 +02:00
parent f4e960be35
commit 41eb8f1a5f

View File

@ -6,5 +6,13 @@ vimscratch() {
if [ ! -t 0 ] ; then
stdin_arg="-"
fi
vim -c "set buftype=nofile" $@ $stdin_arg
set +x
if [[ -n "$1" ]]; then
filetype=$1
shift
vim -c "set buftype=nofile" -c "set filetype=$filetype" $@ $stdin_arg
else
vim -c "set buftype=nofile" $filetype_arg $@ $stdin_arg
fi
}