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

--cwd=current doesn't work properly with nnn #3024

Closed
Kratacoa opened this issue Oct 12, 2020 · 4 comments
Closed

--cwd=current doesn't work properly with nnn #3024

Kratacoa opened this issue Oct 12, 2020 · 4 comments
Labels

Comments

@Kratacoa
Copy link

Describe the bug
When I navigate to a directory in nnn, exit it with ! and open another window with launch --cwd=current, it opens inside home directory. Actually, after doing such an action, even if i cd outside, it keeps opening inside the home directory.

Environment details
Void Linux, musl version

kitty 0.19.1 created by Kovid Goyal
Linux proof_assistant 5.8.14_1 #1 SMP Wed Oct 7 14:31:57 UTC 2020 x86_64
Void \r (\n) (\l)
Loaded config files: /home/splop/.config/kitty/kitty.conf
Running under: X11

Config options different from defaults:
active_tab_font_style (True, False)
allow_remote_control  y
background            Color(red=253, green=246, blue=227)
color0                Color(red=228, green=228, blue=228)
color1                Color(red=215, green=0, blue=0)
color10               Color(red=88, green=88, blue=88)
color11               Color(red=98, green=98, blue=98)
color12               Color(red=128, green=128, blue=128)
color13               Color(red=95, green=95, blue=175)
color14               Color(red=138, green=138, blue=138)
color15               Color(red=28, green=28, blue=28)
color2                Color(red=95, green=135, blue=0)
color3                Color(red=175, green=135, blue=0)
color4                Color(red=0, green=135, blue=255)
color5                Color(red=175, green=0, blue=95)
color6                Color(red=0, green=175, blue=175)
color7                Color(red=38, green=38, blue=38)
color8                Color(red=255, green=255, blue=215)
color9                Color(red=215, green=95, blue=0)
cursor                Color(red=82, green=103, blue=111)
enabled_layouts       ['tall', 'fat', 'grid', 'horizontal', 'splits', 'stack', 'vertical']
font_size             12.0
foreground            Color(red=82, green=103, blue=111)
selection_background  Color(red=233, green=226, blue=203)
selection_foreground  Color(red=252, green=244, blue=220)
tab_bar_style         powerline
tab_title_template    {index}: {title}
Added shortcuts:
	 control+alt+1 KeyAction(func='goto_tab', args=(1,))
	 control+alt+2 KeyAction(func='goto_tab', args=(2,))
	 control+alt+3 KeyAction(func='goto_tab', args=(3,))
	 control+alt+4 KeyAction(func='goto_tab', args=(4,))
	 control+alt+5 KeyAction(func='goto_tab', args=(5,))
	 control+alt+6 KeyAction(func='goto_tab', args=(6,))
	 control+alt+7 KeyAction(func='goto_tab', args=(7,))
	 control+alt+8 KeyAction(func='goto_tab', args=(8,))
	 control+alt+9 KeyAction(func='goto_tab', args=(9,))
Changed shortcuts:
	 shift+control+enter KeyAction(func='launch', args=['--cwd=current'])

Additional context
My kitty configuration

@Kratacoa Kratacoa added the bug label Oct 12, 2020
@kovidgoyal
Copy link
Owner

I dont use nnn so I have no idea what ! does. But cwd works by using the
current directory of the active foreground child process associated with
the terminal device in the active window. Presumably, whatever nnn is
doing for ! is not setting the shell as the active process for the
terminal device. If they fix that it will work fine. Contrast it with
how ctrl-z works in vim, they can probably look at how vim implements it
for tips.

@Kratacoa
Copy link
Author

Thanks.
I've relayed the issue to them.

@jarun
Copy link

jarun commented Sep 29, 2021

@kovidgoyal can you check if OSC-7 can be supported?
nnn supports it in the latest release.
More details: jarun/nnn#1147

@kovidgoyal
Copy link
Owner

I'm afraid I'm not a fan of osc 7, sorry. Just imagine if a shell sets it and then runs a program like vim that does not set it but that program cds to another directory. Then the terminal that implements OSC 7 will open the wrong directory. Basically once one program uses it, all programs have to use it, and that is never going to happen.

Then there are the issues with remote hosts, where you have to use hostname to detect and ignore OSC 7 from remote hosts, which is fragile.

When you relinquish the tty to another process such as a spawned shell you should mark that process as the foreground process for the tty. And mark yourself as the foreground when you resume control. This is how shells do it. See for example: https://unix.stackexchange.com/questions/403530/who-changes-the-foreground-process-group-of-a-terminal?noredirect=1&lq=1

It is important to note that after making another process group the foreground you must not write to the tty or change its attributes until that process is dead, otherwise you will get a SIGTTOU which will cause a hang: https://www.gnu.org/software/libc/manual/html_node/Job-Control-Signals.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants