diff options
| author | Mathieu Ablasou <alexherbo2@gmail.com> | 2020-11-09 03:35:48 +0100 |
|---|---|---|
| committer | Mathieu Ablasou <alexherbo2@gmail.com> | 2020-11-09 05:28:03 +0100 |
| commit | 8e6114fef45419cf724c6f4fd8eed1c97592f6ff (patch) | |
| tree | 589872e7f92c8189fe80502c04466bca2e71d5b4 | |
| parent | 5ad59e5201d21ac1221be7c373bd25623efe8337 (diff) | |
Add a `detach` command
Make `connect-detach` use the new `connect` command
Closes #35
| -rw-r--r-- | rc/connect.kak | 46 |
1 files changed, 15 insertions, 31 deletions
diff --git a/rc/connect.kak b/rc/connect.kak index 4953a4b..cf745cf 100644 --- a/rc/connect.kak +++ b/rc/connect.kak @@ -51,6 +51,10 @@ provide-module connect %{ connect sh %arg{@} } + define-command connect-detach -params .. -shell-completion -docstring 'Write an attachable program to connect.sh and detach the client' %{ + connect detach %arg{@} + } + define-command connect -params 1.. -command-completion -docstring 'Run the given command as <command> sh -c {connect} -- [arguments]. Example: connect terminal sh' %{ %arg{1} sh -c %{ kak_opt_prelude_path=$1 @@ -59,6 +63,7 @@ provide-module connect %{ kak_opt_connect_environment_paths=$4 kak_session=$5 kak_client=$6 + kak_server_working_directory=$7 . "$kak_opt_connect_root_path/connect/env/default.env" . "$kak_opt_connect_root_path/connect/env/overrides.env" @@ -67,7 +72,9 @@ provide-module connect %{ eval "$kak_opt_connect_environment" - shift 7 + shift 8 + + cd "$kak_server_working_directory" [ "$1" ] && "$@" || "$SHELL" } -- \ @@ -77,6 +84,7 @@ provide-module connect %{ %opt{connect_environment_paths} \ %val{session} \ %val{client} \ + %sh{pwd} \ %arg{@} } @@ -93,37 +101,13 @@ provide-module connect %{ } } - define-command connect-detach -params .. -shell-completion -docstring 'Write an attachable program to connect.sh and detach the client' %{ - echo -to-file "%val{client_env_PWD}/connect.sh" -quoting shell sh -c %{ - rm connect.sh - - kak_opt_prelude_path=$1 - kak_opt_connect_root_path=$2 - kak_opt_connect_environment=$3 - kak_opt_connect_environment_paths=$4 - kak_session=$5 - kak_server_working_directory=$6 - - . "$kak_opt_connect_root_path/connect/env/default.env" - . "$kak_opt_connect_root_path/connect/env/overrides.env" - . "$kak_opt_connect_root_path/connect/env/kakoune.env" - . "$kak_opt_connect_root_path/connect/env/git.env" - - eval "$kak_opt_connect_environment" + define-command detach -params 1.. -shell-completion -docstring 'Write an attachable program to connect.sh and detach the client' %{ + echo -to-file connect.sh -quoting shell %arg{@} - shift 6 - - cd "$kak_server_working_directory" - - [ "$1" ] && "$@" || "$SHELL" - } -- \ - %opt{prelude_path} \ - %opt{connect_root_path} \ - %opt{connect_environment} \ - %opt{connect_environment_paths} \ - %val{session} \ - %sh{pwd} \ - %arg{@} + # Remove connect.sh on source + nop %sh{ + echo 'rm "$0"' >> connect.sh + } # Detach the client quit |
