vimrc: Make Terminal-spawning helpers and mappings

On Mac systems with MacPorts-installed Bash and Vim, the :ter[minal]
command doesn't pick up /etc/bashrc (aka /private/etc/bashrc) in my
login shell (Bash installed via MacPorts), so I've created helpers to
make it easier to spawn terminals.  These helpers and their stubby
siblings for non-Mac platforms are mapped to F1 and Shift+F1,
respectively.  I figure if I *really* need :help, I can just type :help.
It isn't hard.  Usually I trigger the :help <F1> mapping by mistake
anyways.

Note:
~~~~~
The helpers aren't perfect (you have to close the buffer manually after
Bash exits).
This commit is contained in:
Andrea Rogers 2023-11-15 13:01:49 -06:00
commit 52978bca4c

25
.vimrc
View file

@ -209,11 +209,28 @@ if has("autocmd")
filetype plugin indent on
endif
" Mac-specific stuffs
if has('macunix')
" Hacks for MacPorts Bash to actually work.
function! Terminal()
execute 'ter bash --rcfile /etc/bashrc -i'
endfunction
function! VertTerminal()
execute 'vert ter bash --rcfile /etc/bashrc -i'
endfunction
else
function! Terminal()
execute 'ter'
endfunction
function! VertTerminal()
execute 'vert ter'
endfunction
endif
" Super special mappings
" map <F5> :w!<cr>:!perl %<cr>
" map <F6> :w!<cr>:!python %<cr>
" map <F7> :w!<cr>:!bash %<cr>
map <F2> :!git blame %<cr>
map <F1> :call Terminal()<cr>
map <S-F1> :call VertTerminal()<cr>
map <F2> :!git grep -n '<cword>' $(git rev-parse --show-toplevel)<cr>
map <F3> :!git blame %<cr>
map <F5> :w!<cr>:!xelatex %<cr>
map <F9> :w!<cr>:!md-previewer %<cr>
map <F12> :mksession!<cr>