BIG REFACTOR; PLEASE BE ADVISED
finally going to commit that zshrc refactor - smolvsdefault on altaria - i3-utils refactor - no need for custom scwrypt executable anymore - time to say goodbye to the old dotwryn.env in favor of the new and improved rc.ds - vim/rc.d refactor + QuickREPL and QuickCommand replacements for \r and \t - going to stop tracking Archives explicitly until new hard drive - tty-colorscheme is now referenced directly - colorscheme/spring-sunset needed to swap primary/secondary colors for focus in i3 since it was confusing - setup config no longer needs to create ~/.config/wryn/env.vim; added some dependencies to arch-linux - switch from dmenu to rofi by default; allow .i3 overrides in colorschemes; tty-colorscheme is now referenced directly
This commit is contained in:
80
vim/rc.d/31.utility-execute.vim
Normal file
80
vim/rc.d/31.utility-execute.vim
Normal file
@@ -0,0 +1,80 @@
|
||||
"
|
||||
" escape-to-shell execution wrapper with great functionality
|
||||
" and an OK-to-bad API (EXTREMELY helpful)
|
||||
"
|
||||
|
||||
let escapeTmuxSession = "vim-exec"
|
||||
let escapeTmuxPaneID = g:escapeTmuxSession . ":0.0"
|
||||
|
||||
let escapeCommandOutputs = ['tmux', 'split-pane-vertical', 'split-pane-horizontal']
|
||||
|
||||
function ExecuteCommand(args = '', output = '', flavor = 'shell', syntax = 'bash')
|
||||
let output = a:output
|
||||
if output == ''
|
||||
let output = GetPrefferredCommandOutput()
|
||||
endif
|
||||
|
||||
let command = GetCommandString(a:args, a:flavor, output)
|
||||
|
||||
if output == 'tmux'
|
||||
silent call EnsureTmuxSession()
|
||||
call system("tmux send-keys -t ".g:escapeTmuxPaneID." '".command."' Enter")
|
||||
silent call system("tmux display-popup -E 'tmux a -t ".g:escapeTmuxSession."' &")
|
||||
elseif output == 'split-pane-horizontal'
|
||||
execute "botright terminal " . command
|
||||
let &l:syntax=a:syntax
|
||||
elseif output == 'split-pane-vertical'
|
||||
execute "botright vertical terminal " . command
|
||||
let &l:syntax=a:syntax
|
||||
else
|
||||
execute "!" . command
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function GetCommandString(args, flavor, output)
|
||||
let command = ''
|
||||
let gitRoot = FindGitRoot()
|
||||
|
||||
if a:flavor == 'shell'
|
||||
let command = a:args
|
||||
|
||||
elseif a:flavor == 'npm'
|
||||
let command = 'npm test ' . a:args
|
||||
if gitRoot != ''
|
||||
let command = 'cd ' . gitRoot . '; ' . command
|
||||
endif
|
||||
|
||||
elseif a:flavor == 'django'
|
||||
let command = './manage.py test --keepdb ' . a:args
|
||||
if gitRoot != ''
|
||||
let command = 'cd ' . gitRoot . '; ' . command
|
||||
endif
|
||||
endif
|
||||
|
||||
if stridx(a:output, 'tmux') != -1
|
||||
let command = command.";"
|
||||
\ . " echo \"-----------------------------\" | lolcat;"
|
||||
\ . " echo \"(ENTER to close, C^c to stay)\";"
|
||||
\ . " read </dev/tty;"
|
||||
\ . " tmux detach-client" " omit final ';'
|
||||
echom command
|
||||
endif
|
||||
|
||||
if stridx(a:output, 'split-pane') == -1
|
||||
let command = "clear; ".command
|
||||
endif
|
||||
|
||||
return command
|
||||
endfunction
|
||||
|
||||
function GetPrefferredCommandOutput()
|
||||
for output in g:escapeCommandOutputs
|
||||
if stridx(output, 'tmux') != -1 && executable('tmux')
|
||||
return output
|
||||
elseif stridx(output, 'split-pane') != -1 && v:version >= 800
|
||||
return output
|
||||
endif
|
||||
endfor
|
||||
|
||||
return 'shell-escape'
|
||||
endfunction
|
Reference in New Issue
Block a user