This commit is contained in:
Kovid Goyal 2022-06-28 11:42:37 +05:30
commit 295fbe42ad
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
19 changed files with 60 additions and 54 deletions

View File

@ -274,8 +274,8 @@ Edit files in new kitty windows even over SSH
edit-in-kitty myfile.txt
edit-in-kitty --type tab --title "Editing My File" myfile.txt
# open file.txt at line 75 (works with vim, emacs, nano, micro)
edit-in-kitty +75 file.txt
# open myfile.txt at line 75 (works with vim, neovim, emacs, nano, micro)
edit-in-kitty +75 myfile.txt
The :command:`edit-in-kitty` command allows you to seamlessly edit files
in your default :opt:`editor` in new kitty windows. This works even over

0
kittens/diff/collect.py Executable file → Normal file
View File

0
kittens/diff/main.py Executable file → Normal file
View File

0
kittens/diff/options/definition.py Executable file → Normal file
View File

0
kittens/diff/options/utils.py Executable file → Normal file
View File

0
kittens/icat/main.py Executable file → Normal file
View File

View File

@ -181,15 +181,15 @@ the same as for the :ac:`toggle_marker` action (see :doc:`/marks`).
--os-window-class
Set the *WM_CLASS* property on X11 and the application id property on Wayland
for the newly created OS window when using :option:`--type=os-window
Set the :italic:`WM_CLASS` property on X11 and the application id property on
Wayland for the newly created OS window when using :option:`--type=os-window
<launch --type>`. Defaults to whatever is used by the parent kitty process,
which in turn defaults to :code:`kitty`.
--os-window-name
Set the *WM_NAME* property on X11 for the newly created OS Window when using
:option:`--type=os-window <launch --type>`. Defaults to
Set the :italic:`WM_NAME` property on X11 for the newly created OS Window when
using :option:`--type=os-window <launch --type>`. Defaults to
:option:`--os-window-class <launch --os-window-class>`.
@ -220,8 +220,8 @@ effect if :option:`--logo` is specified. See :opt:`window_logo_position`.
type=list
Change colors in the newly launched window. You can either specify a path to a
:file:`.conf` file with the same syntax as :file:`kitty.conf` to read the colors
from, or specify them individually, for example: ``--color background=white``
``--color foreground=red``
from, or specify them individually, for example: :code:`--color background=white
--color foreground=red`.
--watcher -w

View File

@ -87,7 +87,7 @@ For numeric fields: :code:`id`, :code:`pid`, :code:`num` and :code:`recent`, the
a number, not a regular expression.
The field :code:`num` refers to the window position in the current tab, starting from zero and counting clockwise (this
is the same as the order in which the windows are reported by the :italic:`ls` command).
is the same as the order in which the windows are reported by the :ref:`kitty @ ls <at_ls>` command).
The window id of the current window is available as the :envvar:`KITTY_WINDOW_ID` environment variable.
@ -95,7 +95,7 @@ The field :code:`recent` refers to recently active windows in the currently acti
active window, one being the previously active window and so on.
When using the :code:`env` field to match on environment variables, you can specify only the environment variable name
or a name and value, for example, :italic:`env:MY_ENV_VAR=2`.
or a name and value, for example, :code:`env:MY_ENV_VAR=2`.
The field :code:`state` matches on the state of the window. Supported states are:
:code:`active`, :code:`focused`, :code:`needs_attention`, :code:`parent_active` and :code:`parent_focused`.
@ -128,7 +128,7 @@ The :code:`recent` number matches recently active tabs in the currently active O
active tab, one the previously active tab and so on.
When using the :code:`env` field to match on environment variables, you can specify only the environment variable name
or a name and value, for example, :italic:`env:MY_ENV_VAR=2`. Tabs containing any window with the specified environment
or a name and value, for example, :code:`env:MY_ENV_VAR=2`. Tabs containing any window with the specified environment
variables are matched.
The field :code:`state` matches on the state of the tab. Supported states are:

View File

@ -24,7 +24,7 @@ class CloseTab(RemoteCommand):
desc = '''\
Close an arbitrary set of tabs. The :code:`--match` option can be used to
specify complex sets of tabs to close. For example, to close all non-focused
tabs in the currently focused OS window, use:
tabs in the currently focused OS window, use::
kitty @ close-tab --match "not state:focused and state:parent_focused"
'''

View File

@ -51,8 +51,8 @@ class Launch(RemoteCommand):
desc = (
'Prints out the id of the newly opened window. Any command line arguments'
' are assumed to be the command line used to run in the new window, if none'
' are provided, the default shell is run. For example:'
' :code:`kitty @ launch --title=Email mutt`.'
' are provided, the default shell is run. For example:\n'
':code:`kitty @ launch --title=Email mutt`'
)
options_spec = MATCH_TAB_OPTION + '\n\n' + '''\
--no-response

View File

@ -28,7 +28,7 @@ class NewWindow(RemoteCommand):
short_desc = 'Open new window'
desc = (
'DEPRECATED: Use the launch command instead.\n\n'
'DEPRECATED: Use the :ref:`launch <at_launch>` command instead.\n\n'
'Open a new window in the specified tab. If you use the :option:`kitty @ new-window --match` option'
' the first matching tab is used. Otherwise the currently active tab is used.'
' Prints out the id of the newly opened window'

View File

@ -27,7 +27,7 @@ class ScrollWindow(RemoteCommand):
desc = (
'Scroll the specified windows, if no window is specified, scroll the window this command is run inside.'
' :italic:`SCROLL_AMOUNT` can be either the keywords :code:`start` or :code:`end` or an'
' argument of the form <number>[unit][+-]. For example, :code:`30` will scroll down 30 lines and :code:`2p-`'
' argument of the form :italic:`<number>[unit][+-]`. For example, :code:`30` will scroll down 30 lines and :code:`2p-`'
' will scroll up 2 pages. :code:`3u` will *unscroll* by 3 lines, which means that 3 lines will move from the'
' scrollback buffer onto the top of the screen.'
)

View File

@ -93,7 +93,7 @@ Do not send text to the active window, even if it is one of the matched windows.
--stdin
type=bool-set
Read the text to be sent from :italic:`stdin`. Note that in this case the text is sent as is,
not interpreted for escapes. If stdin is a terminal, you can press :kbd:`Ctrl-D` to end reading.
not interpreted for escapes. If stdin is a terminal, you can press :kbd:`Ctrl+D` to end reading.
--from-file

View File

@ -672,7 +672,7 @@ def get_editor(opts: Optional[Options] = None, path_to_edit: str = '', line_numb
ans = shlex.split(opts.editor)
if path_to_edit:
if line_number:
eq = os.path.basename(ans[-1]).lower()
eq = os.path.basename(ans[0]).lower()
if eq in ('code', 'code.exe'):
path_to_edit += f':{line_number}'
ans.append('--goto')

View File

@ -1,7 +1,6 @@
function __ksi_completions
set --local ct (commandline --current-token)
set --local tokens (commandline --tokenize --cut-at-cursor --current-process)
set tokens[1] "clone-in-kitty"
printf "%s\n" $tokens $ct | command kitty +complete fish2
end

View File

@ -1,7 +1,6 @@
function __ksi_completions
set --local ct (commandline --current-token)
set --local tokens (commandline --tokenize --cut-at-cursor --current-process)
set tokens[1] "edit-in-kitty"
printf "%s\n" $tokens $ct | command kitty +complete fish2
end

View File

@ -165,7 +165,6 @@ function __ksi_transmit_data -d "Transmit data to kitty using chunked DCS escape
set chunk_num (math $chunk_num + 1)
end
printf \eP@kitty-%s\|\e\\ "$argv[2]"
end
function clone-in-kitty -d "Clone the current fish session into a new kitty window"
@ -187,8 +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"
set data (string join "," -- $data | tr -d "\t\n\r ")
__ksi_transmit_data "$data" "clone"
__ksi_transmit_data (string join "," -- $data | tr -d "\t\n\r ") "clone"
end
function edit-in-kitty -d "Edit the specified file in a new kitty overlay using your preferred editor, even over SSH"
@ -217,62 +215,73 @@ function edit-in-kitty -d "Edit the specified file in a new kitty overlay using
return 1
end
if test ! -f "$ed_filename"
builtin echo "$ed_filename is not a file" > /dev/stderr
echo "$ed_filename is not a file" > /dev/stderr
return 1
end
set --local stat_result (command stat -L --format '%d:%i:%s' "$ed_filename" 2> /dev/null)
if test "$status" -ne "0"
set stat_result (command stat -L -f '%d:%i:%z' "$ed_filename" 2> /dev/null)
set --local stat_result (stat -L --format '%d:%i:%s' "$ed_filename" 2> /dev/null)
if test "$status" -ne 0
set stat_result (stat -L -f '%d:%i:%z' "$ed_filename" 2> /dev/null)
end
if test -z "$stat_result"
if test "$status" -ne 0 || test -z "$stat_result"
echo "Failed to stat the file: $ed_filename" > /dev/stderr
return 1
end
set --append data "file_inode=$stat_result"
set --local file_size (string match -rg '\d+:\d+:(\d+)' "$stat_result")
test "$file_size" -gt (math "8 * 1024 * 1024") && begin; echo "File is too large for performant editing"; return 1; end;
set --local file_data (command base64 < "$ed_filename")
if test "$file_size" -gt (math "8 * 1024 * 1024")
echo "File is too large for performant editing" > /dev/stderr
return 1
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"
set --erase data
echo "Waiting for editing to be completed..."
set --global __ksi_waiting_for_edit "y"
set --erase data
function __ksi_react_to_interrupt -s SIGINT
function __ksi_react_to_interrupt --on-signal SIGINT
functions --erase __ksi_react_to_interrupt
if test "$__ksi_waiting_for_edit" = "y"
set --erase __ksi_waiting_for_edit
set --erase __ksi_waiting_for_edit
__ksi_transmit_data "abort_signaled=interrupt" "edit"
end
end
while true
set --local started "n"
while true
command stty "-echo"; set --local line (command head -n1 < /dev/tty);
stty "-echo"
set --local line (head -n1 < /dev/tty)
test -z "$line" && break
if test "$started" = "y"
test "$line" = "UPDATE" && break;
if test "$line" = "DONE"
set started "done"; break;
if test "$started" = "y"
test "$line" = "UPDATE" && break
if test "$line" = "DONE"
set started "done"
break
end
printf "%s\n" "$line" > /dev/stderr;
return 1;
printf "%s\n" "$line" > /dev/stderr
set --erase __ksi_waiting_for_edit
functions --erase __ksi_react_to_interrupt
return 1
else
test "$line" = "KITTY_DATA_START" && set started "y"
end
end
test "$started" = "n" && continue;
test "$started" = "n" && continue
set --local data ""
while true
command stty "-echo"; set --local line (command head -n1 < /dev/tty);
stty "-echo"
set --local line (head -n1 < /dev/tty)
test -z "$line" && break
test "$line" = "KITTY_DATA_END" && break;
test "$line" = "KITTY_DATA_END" && break
set data "$data$line"
end
if test -n "$data" -a "$started" != "done"
if test -n "$data" -a "$started" != "done"
echo "Updating $ed_filename..."
printf "%s" "$data" | command base64 -d > "$ed_filename"
printf "%s" "$data" | base64 -d > "$ed_filename"
end
test "$started" = "done" && break;
test "$started" = "done" && break
end
set --erase __ksi_waiting_for_edit
set --erase __ksi_waiting_for_edit
functions --erase __ksi_react_to_interrupt
end

View File

@ -202,11 +202,11 @@ prepare_for_exec() {
/*) ;;
*)
if ! command -v "$login_shell" > /dev/null 2> /dev/null; then
for i in /opt/homebrew/bin /opt/homebrew/sbin /usr/local/bin /usr/bin /bin /usr/sbin /sbin
for i in /opt/homebrew/bin /opt/homebrew/sbin /opt/local/bin /opt/local/sbin /usr/local/bin /usr/bin /bin /usr/sbin /sbin
do
if [ -x "$i/$login_shell" ]; then
login_shell="$i/$login_shell"
break;
break
fi
done
fi

View File

@ -254,7 +254,7 @@ _ksi_deferred_init() {
# OpenSSH's sshd creates entries in utmp for every login so use those
[[ "$(builtin command who -m 2> /dev/null)" =~ "\([a-fA-F.:0-9]+\)$" ]] && is_ssh_session="y"
fi
if [[ "$is_ssh_session" == "y" ]]; then
# show the hostname via %m for SSH sessions
functions[_ksi_precmd]+="
@ -408,7 +408,7 @@ clone-in-kitty() {
while :; do
case "$1" in
"") break;;
-h|--help)
-h|--help)
builtin printf "%s\n\n%s\n" "Clone the current zsh session into a new kitty window." "For usage instructions see: https://sw.kovidgoyal.net/kitty/shell-integration/#clone-shell"
return
;;
@ -428,7 +428,6 @@ clone-in-kitty() {
_ksi_transmit_data "$data" "clone" "save_history"
}
edit-in-kitty() {
builtin local data=""
builtin local ed_filename=""
@ -437,7 +436,7 @@ edit-in-kitty() {
while :; do
case "$1" in
"") break;;
-h|--help)
-h|--help)
builtin printf "%s\n\n%s\n\n%s\n" "$usage" "Edit the specified file in a kitty overlay window. Works over SSH as well." "For usage instructions see: https://sw.kovidgoyal.net/kitty/shell-integration/#edit-file"
return
;;
@ -463,7 +462,7 @@ edit-in-kitty() {
[ "${stat_result[size]}" -gt $((8 * 1024 * 1024)) ] && { builtin echo "File is too large for performant editing"; return 1; }
data="$data,file_inode=${stat_result[device]}:${stat_result[inode]}:${stat_result[size]}"
data="$data,file_data=$(builtin command base64 < "$ed_filename")"
_ksi_transmit_data "$data" "edit"
_ksi_transmit_data "$data" "edit"
data=""
builtin echo "Waiting for editing to be completed..."
builtin local started="n"