diff options
| author | Alex Leferry 2 <alexherbo2@gmail.com> | 2019-03-17 12:50:57 +0100 |
|---|---|---|
| committer | Alex Leferry 2 <alexherbo2@gmail.com> | 2019-03-17 15:28:20 +0100 |
| commit | f2d2201d808c1c263aa9b4d4fefd75afda383f08 (patch) | |
| tree | 95ee4056da767a1ce18ccd813034e12dca7c2526 /rc | |
| parent | 0db8dff4e403d007edebd82dc7b21190a862401c (diff) | |
Add [e]dit and [b]uffer commands
Diffstat (limited to 'rc')
| l--------- | rc/aliases/b | 1 | ||||
| l--------- | rc/aliases/e | 1 | ||||
| -rwxr-xr-x | rc/commands/buffer | 20 | ||||
| -rwxr-xr-x | rc/commands/edit (renamed from rc/connect.sh) | 2 | ||||
| -rw-r--r-- | rc/connect.kak | 21 |
5 files changed, 28 insertions, 17 deletions
diff --git a/rc/aliases/b b/rc/aliases/b new file mode 120000 index 0000000..daf79f2 --- /dev/null +++ b/rc/aliases/b @@ -0,0 +1 @@ +../commands/buffer
\ No newline at end of file diff --git a/rc/aliases/e b/rc/aliases/e new file mode 120000 index 0000000..1cb50b6 --- /dev/null +++ b/rc/aliases/e @@ -0,0 +1 @@ +../commands/edit
\ No newline at end of file diff --git a/rc/commands/buffer b/rc/commands/buffer new file mode 100755 index 0000000..58c06dd --- /dev/null +++ b/rc/commands/buffer @@ -0,0 +1,20 @@ +#!/bin/sh + +main() { + [ $# = 0 ] && list || edit "$@" +} + +list() { + eval "set -- $KAKOUNE_BUFFERS" + printf '%s\n' "$@" +} + +edit() { + commands= + for buffer do + commands="buffer $buffer; $commands" + done + printf 'evaluate-commands -client "%s" "%s"' "$KAKOUNE_CLIENT" "$commands" | kak -p "$KAKOUNE_SESSION" +} + +main "$@" diff --git a/rc/connect.sh b/rc/commands/edit index 3ef0e9c..593c90b 100755 --- a/rc/connect.sh +++ b/rc/commands/edit @@ -38,7 +38,7 @@ if test "$KAKOUNE_SESSION" -a "$KAKOUNE_CLIENT"; then ;; esac fi - for file in "$@"; do + for file do commands="edit $(realpath "$file"); $commands" done printf 'evaluate-commands -client "%s" "%s"' "$KAKOUNE_CLIENT" "$commands" | kak -p "$KAKOUNE_SESSION" diff --git a/rc/connect.kak b/rc/connect.kak index 56af067..6904d2c 100644 --- a/rc/connect.kak +++ b/rc/connect.kak @@ -1,20 +1,11 @@ declare-option -docstring 'Shell program to be used as default entry-point' str connect_shell %sh(echo ${SHELL:-sh}) -declare-option -hidden str connect_editor %sh(printf '%s/connect.sh' "${kak_source%/*}") -declare-option -hidden str connect_cache %sh(printf '%s/kak/connect' "${XDG_CACHE_HOME:-~/.cache}") +declare-option -hidden str connect_source %sh(printf '%s' "${kak_source%/*}") -define-command -hidden connect-configure %{ - nop %sh{ - bin=$kak_opt_connect_cache/bin - mkdir -p "$bin" - cp "$kak_opt_connect_editor" "$bin/connect" - } -} - -define-command connect-shell -params 1.. -shell-completion -docstring 'Run a shell with connect and EDITOR connected to the current client' %{ - nop %sh(PATH=$kak_opt_connect_cache/bin:$PATH EDITOR=connect KAKOUNE_SESSION=$kak_session KAKOUNE_CLIENT=$kak_client $@) +define-command connect-shell -params 1.. -shell-completion -docstring 'Run a shell with [e]dit, [b]uffer and EDITOR connected to the current client' %{ + nop %sh(PATH=$kak_opt_connect_source/commands:$kak_opt_connect_source/aliases:$PATH EDITOR=edit KAKOUNE_SESSION=$kak_session KAKOUNE_CLIENT=$kak_client KAKOUNE_BUFFERS=$kak_buflist $@) } -define-command connect-terminal -params .. -shell-completion -docstring 'Create a new terminal with connect and EDITOR connected to the current client' %{ +define-command connect-terminal -params .. -shell-completion -docstring 'Create a new terminal with [e]dit, [b]uffer and EDITOR connected to the current client' %{ evaluate-commands %sh{ if test $# = 0; then printf 'connect-terminal- %%opt(connect_shell)' @@ -25,9 +16,7 @@ define-command connect-terminal -params .. -shell-completion -docstring 'Create } define-command -hidden connect-terminal- -params .. %{ - terminal sh -c "PATH=%opt(connect_cache)/bin:$PATH EDITOR=connect KAKOUNE_SESSION=%val(session) KAKOUNE_CLIENT=%val(client) %arg(@)" + terminal sh -c "PATH=%opt(connect_source)/commands:%opt(connect_source)/aliases:$PATH EDITOR=edit KAKOUNE_SESSION=%val(session) KAKOUNE_CLIENT=%val(client) KAKOUNE_BUFFERS=""%val(buflist)"" %arg(@)" } alias global connect connect-terminal - -connect-configure |
