Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When an open action is defined for selected file type, 'kitten hints --type path --program default' attempts to open relative paths in kitty process working directory #3968

wfchandler opened this issue Aug 23, 2021 · 0 comments


Copy link

wfchandler commented Aug 23, 2021

Describe the bug
When attempting to open paths with kitten hints --type path --program default , the launched program has its $PWD set to the current working directory of the main kitty process, rather than the working directory of the shell session from which hints was launched.

If a relative path was selected, either an empty buffer will be opened if the selected path doesn't exist in the starting directory, or the wrong file if it does.

This is very similar to #3352, but with --type path instead of --type linenum.

To Reproduce
Steps to reproduce the behavior:

  1. Set the following open action at the top of ~/.config/kitty/open-actions.conf:
protocol file
ext md
action launch --type=overlay nvim ${FILE_PATH}
  1. Create new kitty process in $HOME
  2. cd to src/kitty
  3. Execute rg -l "Pre-built binaries:", which returns output
  4. Execute kitten hints --type path --program default and select
  5. Default program for this file type launches as expected, but with an empty buffer instead of the contents of This is because ~/ was opened instead of ~/src/kitty/

From what I can tell, cwd is set correctly when passed from hints to boss, but is not forwarded when a matching action is found.

This issue does not occur if no matching open action is found (i.e. when open / xdg-open is called), maybe because cwd is passed in that scenario.

See attached screen recording

Environment details

Config details
kitty 0.23.1 created by Kovid Goyal
Darwin mpb.local 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64
ProductName:	macOS ProductVersion:	11.5 BuildVersion:	20G71
Loaded config files:

Config options different from defaults:
active_tab_title_template     {index - 1}: {title}*{layout_name[:2].upper()}
copy_on_select                clipboard
disable_ligatures             2
enable_audio_bell             False
enabled_layouts               ['splits', 'tall', 'fat', 'grid', 'vertical', 'stack']
font_family                   DejaVu Sans Mono
font_size                     14.0
input_delay                   0
macos_option_as_alt           3
macos_thicken_font            0.75
repaint_delay                 5
scrollback_pager_history_size 20971520
sync_to_monitor               False
tab_activity_symbol           ⚠
tab_bar_margin_width          1.0
tab_bar_style                 separator
tab_title_template            {index - 1}: {title[:8]}*{layout_name[:2].upper()}
visual_bell_duration          0.025
Added shortcuts:
	shift+ctrl+a KeyAction('launch', ('--location=vsplit', '--cwd=current'))
	shift+ctrl+a KeyAction('launch', ('--location=hsplit', '--cwd=current'))
	alt+ctrl+a > , KeyAction('set_tab_title')
	alt+ctrl+a > 0 KeyAction('goto_tab', (1,))
	alt+ctrl+a > 1 KeyAction('goto_tab', (2,))
	alt+ctrl+a > 2 KeyAction('goto_tab', (3,))
	alt+ctrl+a > 3 KeyAction('goto_tab', (4,))
	alt+ctrl+a > 4 KeyAction('goto_tab', (5,))
	alt+ctrl+a > 5 KeyAction('goto_tab', (6,))
	alt+ctrl+a > 6 KeyAction('goto_tab', (7,))
	alt+ctrl+a > 7 KeyAction('goto_tab', (8,))
	alt+ctrl+a > 8 KeyAction('goto_tab', (9,))
	alt+ctrl+a > 9 KeyAction('goto_tab', (0,))
	alt+ctrl+a > c KeyAction('new_tab_with_cwd')
	alt+ctrl+a > n KeyAction('next_tab')
	alt+ctrl+a > p KeyAction('previous_tab')
	cmd+h KeyAction('show_scrollback')
	shift+alt+ctrl+cmd+7 KeyAction('next_layout')
	shift+alt+ctrl+cmd+8 KeyAction('previous_layout')
	shift+alt+ctrl+cmd+b KeyAction('launch', ('--allow-remote-control', 'kitty', '+kitten', 'broadcast'))
	shift+alt+ctrl+cmd+c KeyAction('kitten', ('unicode_input',))
	shift+alt+ctrl+cmd+h KeyAction('resize_window', ('wider', 5))
	shift+alt+ctrl+cmd+i KeyAction('goto_layout', ('tall',))
	shift+alt+ctrl+cmd+j KeyAction('resize_window', ('shorter', 5))
	shift+alt+ctrl+cmd+k KeyAction('resize_window', ('taller', 5))
	shift+alt+ctrl+cmd+l KeyAction('resize_window', ('narrower', 5))
	shift+alt+ctrl+cmd+m KeyAction('detach_window', ('tab-prev',))
	shift+alt+ctrl+cmd+n KeyAction('detach_window', ('new-tab',))
	shift+alt+ctrl+cmd+o KeyAction('goto_layout', ('fat',))
	shift+alt+ctrl+cmd+p KeyAction('goto_layout', ('grid',))
	shift+alt+ctrl+cmd+s KeyAction('kitty_shell', ('window',))
	shift+alt+ctrl+cmd+u KeyAction('goto_layout', ('splits',))
	shift+alt+ctrl+cmd+y KeyAction('move_window_to_top')
	shift+alt+ctrl+cmd+z KeyAction('toggle_layout', ('stack',))
Removed shortcuts:
	shift+insert KeyAction('paste_from_selection')
	shift+ctrl++ KeyAction('change_font_size', (True, '+', 2.0))
	shift+ctrl+- KeyAction('change_font_size', (True, '-', 2.0))
	shift+ctrl+0 KeyAction('tenth_window')
	shift+ctrl+1 KeyAction('first_window')
	shift+ctrl+2 KeyAction('second_window')
	shift+ctrl+3 KeyAction('third_window')
	shift+ctrl+4 KeyAction('fourth_window')
	shift+ctrl+5 KeyAction('fifth_window')
	shift+ctrl+6 KeyAction('sixth_window')
	shift+ctrl+7 KeyAction('seventh_window')
	shift+ctrl+8 KeyAction('eighth_window')
	shift+ctrl+9 KeyAction('ninth_window')
	shift+ctrl+= KeyAction('change_font_size', (True, '+', 2.0))
	shift+ctrl+[ KeyAction('previous_window')
	shift+ctrl+] KeyAction('next_window')
	shift+ctrl+` KeyAction('move_window_to_top')
	shift+ctrl+a > 1 KeyAction('set_background_opacity', ('1',))
	shift+ctrl+a > d KeyAction('set_background_opacity', ('default',))
	shift+ctrl+a > l KeyAction('set_background_opacity', ('-0.1',))
	shift+ctrl+a > m KeyAction('set_background_opacity', ('+0.1',))
	shift+ctrl+b KeyAction('move_window_backward')
	shift+ctrl+c KeyAction('copy_to_clipboard')
	shift+ctrl+f KeyAction('move_window_forward')
	shift+ctrl+n KeyAction('new_os_window')
	shift+ctrl+o KeyAction('pass_selection_to_program')
	shift+ctrl+q KeyAction('close_tab')
	shift+ctrl+r KeyAction('start_resizing_window')
	shift+ctrl+s KeyAction('paste_from_selection')
	shift+ctrl+t KeyAction('new_tab')
	shift+ctrl+u KeyAction('kitten', ('unicode_input',))
	shift+ctrl+v KeyAction('paste_from_clipboard')
	shift+ctrl+w KeyAction('close_window')
	shift+ctrl+escape KeyAction('kitty_shell', ('window',))
	shift+ctrl+enter KeyAction('new_window')
	shift+ctrl+backspace KeyAction('change_font_size', (True, None, 0.0))
	shift+ctrl+left KeyAction('previous_tab')
	shift+ctrl+right KeyAction('next_tab')
	shift+ctrl+up KeyAction('scroll_line_up')
	shift+ctrl+down KeyAction('scroll_line_down')
	shift+ctrl+page_up KeyAction('scroll_page_up')
	shift+ctrl+page_down KeyAction('scroll_page_down')
	shift+ctrl+home KeyAction('scroll_home')
	shift+ctrl+end KeyAction('scroll_end')
	shift+ctrl+f2 KeyAction('edit_config_file')
	shift+ctrl+f5 KeyAction('load_config_file')
	shift+ctrl+f6 KeyAction('debug_config')
	shift+ctrl+f10 KeyAction('toggle_maximized')
	shift+ctrl+f11 KeyAction('toggle_fullscreen')
	shift+ctrl+kp_subtract KeyAction('change_font_size', (True, '-', 2.0))
	shift+ctrl+kp_add KeyAction('change_font_size', (True, '+', 2.0))
	shift+alt+ctrl+t KeyAction('set_tab_title')
	cmd++ KeyAction('change_font_size', (True, '+', 2.0))
	cmd+, KeyAction('edit_config_file')
	cmd+- KeyAction('change_font_size', (True, '-', 2.0))
	cmd+= KeyAction('change_font_size', (True, '+', 2.0))
	cmd+r KeyAction('start_resizing_window')
	cmd+up KeyAction('scroll_line_up')
	cmd+down KeyAction('scroll_line_down')
	shift+cmd+- KeyAction('change_font_size', (True, '-', 2.0))
	shift+cmd+= KeyAction('change_font_size', (True, '+', 2.0))
	shift+cmd+[ KeyAction('previous_tab')
	shift+cmd+] KeyAction('next_tab')
	shift+cmd+d KeyAction('close_window')
	shift+cmd+i KeyAction('set_tab_title')
	shift+cmd+w KeyAction('close_os_window')
	alt+cmd+r KeyAction('clear_terminal', ('reset', True))
	alt+cmd+page_up KeyAction('scroll_line_up')
	alt+cmd+page_down KeyAction('scroll_line_down')
	ctrl+cmd+  KeyAction('kitten', ('unicode_input',))
Changed shortcuts:
	shift+ctrl+e KeyAction('kitten', ('hints',))
	shift+ctrl+h KeyAction('neighboring_window', ('left',))
	shift+ctrl+j KeyAction('neighboring_window', ('bottom',))
	shift+ctrl+k KeyAction('neighboring_window', ('top',))
	shift+ctrl+l KeyAction('neighboring_window', ('right',))
	shift+ctrl+p > n KeyAction('kitten', ('hints', '--type linenum --linenum-action=tab /usr/local/bin/nvim +{line} {path}'))
	shift+ctrl+p > shift+f KeyAction('kitten', ('hints', '--type path --program default'))
	cmd+0 KeyAction('goto_tab', (1,))
	cmd+1 KeyAction('goto_tab', (2,))
	cmd+2 KeyAction('goto_tab', (3,))
	cmd+3 KeyAction('goto_tab', (4,))
	cmd+4 KeyAction('goto_tab', (5,))
	cmd+5 KeyAction('goto_tab', (6,))
	cmd+6 KeyAction('goto_tab', (7,))
	cmd+7 KeyAction('goto_tab', (8,))
	cmd+8 KeyAction('goto_tab', (9,))
	cmd+9 KeyAction('goto_tab', (0,))
	cmd+n KeyAction('new_os_window_with_cwd')
	cmd+t KeyAction('new_tab_with_cwd')
	cmd+enter KeyAction('new_window_with_cwd')
	active_tab_background         #546d79   
	active_tab_foreground         #40c4fe   
	background                    #263137   
	color0                        #546d79   
	color1                        #ff5151   
	color10                       #b9f6c9   
	color11                       #ffe47e   
	color12                       #80d7fe   
	color13                       #ff80ab   
	color14                       #a7fdeb   
	color15                       #fefefe   
	color2                        #69f0ad   
	color3                        #ffd73f   
	color4                        #40c4fe   
	color5                        #ff3f80   
	color6                        #64fcda   
	color7                        #fefefe   
	color8                        #b0bec4   
	color9                        #ff8980   
	cursor                        #edeeed   
	foreground                    #eceef0   
	inactive_tab_background       #546d79   
	inactive_tab_foreground       #69f0ad   
	selection_background          #607c8b   
	selection_foreground          #eceef0   
	tab_bar_background            #546d79   

Additional context
Reproducible with kitty --config NONE -o 'map f1 kitten hints --type path --program default'.

I have a mime-types files containing:

text/plain c conf cpp h hpp go ini js lock md py rb rs toml txt yml yaml

and an open-actions.conf with:

# Open any file with a fragment in vim, fragments are generated
# by the hyperlink_grep kitten and nothing else so far.
protocol file
fragment_matches [0-9]+
action launch --type=overlay nvim +${FRAGMENT} ${FILE_PATH}

# Open text files without fragments in the editor
protocol file
mime text/*
action launch --type=overlay nvim ${FILE_PATH}

# Open any image in the full kitty window by clicking on it
protocol file
mime image/*
action launch --type=overlay kitty +kitten icat --hold ${FILE_PATH}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

1 participant