From fa670e1f5ddafb780f4f2e2d56c97675dd2ecf6a Mon Sep 17 00:00:00 2001 From: pagedown Date: Tue, 26 Jul 2022 13:20:41 +0800 Subject: [PATCH 1/4] ... --- docs/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 14d155348..588e6834d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -76,7 +76,7 @@ Detailed list of changes - Bash integration: Fix declare not creating global variables in .bashrc (:iss:`5254`) -- :command`kitty @ scroll-window` allow scrolling by fractions of a screen +- :command:`kitty @ scroll-window` allow scrolling by fractions of a screen (:iss:`5294`) - remote files kitten: Fix working with files whose names have characters that From 4e1cd0590bfaeb5c237d3b51f98269ab9ab8a761 Mon Sep 17 00:00:00 2001 From: pagedown Date: Tue, 26 Jul 2022 13:20:50 +0800 Subject: [PATCH 2/4] Use builtin to call read in zsh integration and bash integration --- shell-integration/bash/kitty.bash | 18 +++++++++--------- shell-integration/zsh/kitty-integration | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/shell-integration/bash/kitty.bash b/shell-integration/bash/kitty.bash index 5360518cb..cd600ad55 100644 --- a/shell-integration/bash/kitty.bash +++ b/shell-integration/bash/kitty.bash @@ -162,7 +162,7 @@ _ksi_main() { # in particular this means cwd reporting will not happen for a # command like cd /test && cat. PS0 is evaluated before cd is run. if [[ "${_ksi_prompt[last_reported_cwd]}" != "$PWD" ]]; then - _ksi_prompt[last_reported_cwd]="$PWD"; + _ksi_prompt[last_reported_cwd]="$PWD" builtin printf "\e]7;kitty-shell-cwd://%s%s\a" "$HOSTNAME" "$PWD" fi fi @@ -392,27 +392,27 @@ edit-in-kitty() { builtin trap -- "builtin command stty '$old_tty_settings'; _ksi_transmit_data 'abort_signaled=interrupt' 'edit'; builtin exit 1;" SIGINT SIGTERM while :; do started="n" - while IFS= read -r line; do + while IFS= builtin read -r line; do if [ "$started" = "y" ]; then - [ "$line" = "UPDATE" ] && break; + [ "$line" = "UPDATE" ] && break [ "$line" = "DONE" ] && { started="done"; break; } - builtin printf "%s\n" "$line" > /dev/stderr; - return 1; + builtin printf "%s\n" "$line" > /dev/stderr + return 1 else [ "$line" = "KITTY_DATA_START" ] && started="y" fi done - [ "$started" = "n" ] && continue; + [ "$started" = "n" ] && continue data="" - while IFS= read -r line; do - [ "$line" = "KITTY_DATA_END" ] && break; + while IFS= builtin read -r line; do + [ "$line" = "KITTY_DATA_END" ] && break data="$data$line" done [ -n "$data" -a "$started" != "done" ] && { builtin echo "Updating $ed_filename..." builtin printf "%s" "$data" | builtin command base64 -d > "$ed_filename" } - [ "$started" = "done" ] && break; + [ "$started" = "done" ] && break done } $(_ksi_wait_for_complete > /dev/tty) diff --git a/shell-integration/zsh/kitty-integration b/shell-integration/zsh/kitty-integration index ef17b4545..23430260d 100644 --- a/shell-integration/zsh/kitty-integration +++ b/shell-integration/zsh/kitty-integration @@ -474,26 +474,26 @@ edit-in-kitty() { builtin trap "builtin command stty '$old_tty_settings'; _ksi_transmit_data 'abort_signaled=interrupt' 'edit'; return 1;" INT TERM while :; do started="n" - while IFS= read -r line; do + while IFS= builtin read -r line; do if [ "$started" = "y" ]; then [ "$line" = "UPDATE" ] && break; [ "$line" = "DONE" ] && { started="done"; break; } - builtin printf "%s\n" "$line" > /dev/stderr; - return 1; + builtin printf "%s\n" "$line" > /dev/stderr + return 1 else [ "$line" = "KITTY_DATA_START" ] && started="y" fi done - [ "$started" = "n" ] && continue; + [ "$started" = "n" ] && continue data="" - while IFS= read -r line; do - [ "$line" = "KITTY_DATA_END" ] && break; + while IFS= builtin read -r line; do + [ "$line" = "KITTY_DATA_END" ] && break data="$data$line" done [ -n "$data" -a "$started" != "done" ] && { builtin echo "Updating $ed_filename..." builtin printf "%s" "$data" | builtin command base64 -d > "$ed_filename" } - [ "$started" = "done" ] && break; + [ "$started" = "done" ] && break done } From 1eef58438272f9bca68d914896914af7ba33ea24 Mon Sep 17 00:00:00 2001 From: pagedown Date: Tue, 26 Jul 2022 13:21:36 +0800 Subject: [PATCH 3/4] Replace tr with string built-in in fish integration --- .../fish/vendor_conf.d/kitty-shell-integration.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish b/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish index 4a45bf32f..d1510eedd 100644 --- a/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish +++ b/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish @@ -186,7 +186,7 @@ function clone-in-kitty -d "Clone the current fish session into a new kitty wind set --local b64_envs (string join0 -- $envs | base64) set --local b64_cwd (printf "%s" "$PWD" | base64) set --prepend data "shell=fish" "pid=$fish_pid" "cwd=$b64_cwd" "env=$b64_envs" - __ksi_transmit_data (string join "," -- $data | tr -d "\t\n\r ") "clone" + __ksi_transmit_data (string join "," -- $data | string replace --regex --all "\s" "") "clone" end function edit-in-kitty -d "Edit the specified file in a new kitty overlay using your preferred editor, even over SSH" @@ -234,7 +234,7 @@ function edit-in-kitty -d "Edit the specified file in a new kitty overlay using end set --local file_data (base64 < "$ed_filename") set --append data "file_data=$file_data" - __ksi_transmit_data (string join "," -- $data | tr -d "\t\n\r ") "edit" + __ksi_transmit_data (string join "," -- $data | string replace --regex --all "\s" "") "edit" set --erase data echo "Waiting for editing to be completed..." set --global __ksi_waiting_for_edit "y" From 28ae8c4d2057f0f121e3e3021baa324f7fc756e5 Mon Sep 17 00:00:00 2001 From: pagedown Date: Tue, 26 Jul 2022 13:21:50 +0800 Subject: [PATCH 4/4] Expand ~ when resolving editor path and applying exe_search_path --- docs/changelog.rst | 2 ++ kitty/utils.py | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 588e6834d..095326a13 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -82,6 +82,8 @@ Detailed list of changes - remote files kitten: Fix working with files whose names have characters that need to be quoted in shell scripts (:iss:`5313`) +- Expand ~ in paths configured in :opt:`editor` and :opt:`exe_search_path` (:disc:`5298`) + 0.25.2 [2022-06-07] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/utils.py b/kitty/utils.py index 6fd7ec9e0..45ae70e50 100644 --- a/kitty/utils.py +++ b/kitty/utils.py @@ -670,6 +670,7 @@ def get_editor(opts: Optional[Options] = None, path_to_edit: str = '', line_numb else: import shlex ans = shlex.split(opts.editor) + ans[0] = os.path.expanduser(ans[0]) if path_to_edit: if line_number: eq = os.path.basename(ans[0]).lower() @@ -778,11 +779,11 @@ def which(name: str, only_system: bool = False) -> Optional[str]: x = x.strip() if x: if x[0] == '-': - tried_paths.add(x[1:]) + tried_paths.add(os.path.expanduser(x[1:])) elif x[0] == '+': - append_paths.append(x[1:]) + append_paths.append(os.path.expanduser(x[1:])) else: - paths.append(x) + paths.append(os.path.expanduser(x)) ep = os.environ.get('PATH') if ep: paths.extend(ep.split(os.pathsep))