diff options
| -rw-r--r-- | autoload/+init.kak | 1 | ||||
| -rw-r--r-- | autoload/files.kak | 2 | ||||
| -rw-r--r-- | autoload/git.kak | 4 | ||||
| -rw-r--r-- | autoload/window.kak | 18 |
4 files changed, 20 insertions, 5 deletions
diff --git a/autoload/+init.kak b/autoload/+init.kak index aa105f5..8352000 100644 --- a/autoload/+init.kak +++ b/autoload/+init.kak @@ -77,4 +77,3 @@ map global code <a-c> :casecamel<ret> -docstring 'camelCasing' # Editorconfig hook global BufOpenFile .* %{ try %{ editorconfig-load } } hook global BufNewFile .* %{ try %{ editorconfig-load } } - diff --git a/autoload/files.kak b/autoload/files.kak index b928c33..001ef07 100644 --- a/autoload/files.kak +++ b/autoload/files.kak @@ -3,7 +3,7 @@ def find -docstring "find files" -menu -params 1 \ -shell-script-candidates %{ fd -t f --hidden --color=never -E .git } def file-manager -params .. %{ - connect terminal env "EDITOR=kcr edit" sh -c "DAFFM_PATH_RELATIVE_TO=$PWD daffm -c @kak %arg{@};" + terminal-singleton files env "EDITOR=kcr edit" sh -c "DAFFM_PATH_RELATIVE_TO=$PWD daffm -c @kak %arg{@};" } declare-user-mode buffer diff --git a/autoload/git.kak b/autoload/git.kak index e786fcb..c8426db 100644 --- a/autoload/git.kak +++ b/autoload/git.kak @@ -1,6 +1,4 @@ -define-command gitui -params .. %{ - connect terminal env "GIT_EDITOR=kak -c %val{session}" "EDITOR=kcr edit" "VISUAL=kcr edit" gitu %arg{@} -} +define-command gitui -params .. %{ terminal-singleton git gitu %arg{@} } declare-user-mode git declare-user-mode git-r diff --git a/autoload/window.kak b/autoload/window.kak index 8986914..ba1fab7 100644 --- a/autoload/window.kak +++ b/autoload/window.kak @@ -10,3 +10,21 @@ map global win j ': nop %sh{tmux select-pane -D}<ret>' -docstring 'Jump down' map global win k ': nop %sh{tmux select-pane -U}<ret>' -docstring 'Jump up' map global win l ': nop %sh{tmux select-pane -R}<ret>' -docstring 'Jump right' map global win z ': wq<ret>' + +define-command terminal-singleton -params 2.. -docstring 'terminal-singleton <name> <command> [args...]' %{ + eval %sh{ + name="$1"; shift; + open-term-win() { + printf "terminal -n '$name' env" + printf " 'KAKOUNE_SESSION=$kak_session' 'KAKOUNE_CLIENT=$kak_client'" + printf " 'GIT_EDITOR=kak -c \"$kak_session\"' 'EDITOR=kcr edit' 'VISUAL=kcr edit'" + printf " %q" "$@" + echo "" + } + focus-term-win() { + tmux select-window -t "$name" >/dev/null 2>&1 + } + + focus-term-win || open-term-win "$@"; + } +} |
