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

kitten hints linenum, with relative path, opens file in working directory of kitty process #3352

Closed
kbd opened this issue Feb 26, 2021 · 6 comments
Labels

Comments

@kbd
Copy link

kbd commented Feb 26, 2021

First, for comparison, this works for Python tracebacks because Python tracebacks include the full path:

map kitty_mod+p>p kitten hints --type=linenum --regex='File "(?P<path>.*?)", line (?P<line>\d+)' --linenum-action=background -- /usr/local/bin/code -g {path}:{line}

Now, I'm doing some Zig programming, and here's part of a traceback:

$ zig run repo_status.zig
./repo_status.zig:429:78: error: expected 5 argument(s), found 1
                var temp = std.mem.concat(A, u8, .{f.token, std.fmt.formatInt(num)});

The config I'm using for this is:

map kitty_mod+p>n kitten hints --type=linenum --linenum-action=background -- /usr/local/bin/code -g {path}:{line}

This works correctly to open vscode and passes ./repo_status.zig:429 for the filename. This would be ok, except that the current working directory is the working directory of the kitty process, not my current working directory in my shell.

This can be seen with:

map kitty_mod+p>f kitten hints --type=linenum --linenum-action=background -- /Users/kbd/bin/argv -g {path}:{line}

That's the same as the hint that opened vscode, but it opens argv which is just a debug program I wrote that prints out arguments it's given as well as its working directory. When I launch kitty from another terminal, and then use that hint, kitty prints out:

$ kitty
CWD: /Users/kbd
['/Users/kbd/bin/argv', '-g', './repo_status.zig:489']

So, the working directory used is wherever kitty was launched from, not wherever I am in my shell within kitty.

Is there any way to make this work and ensure that the working directory the hint is launched from is the working directory in my shell? Could we get a --cwd=current equivalent option for hints? Thanks for your help, and for kitty!

@kbd kbd added the bug label Feb 26, 2021
kbd added a commit to kbd/setup that referenced this issue Feb 27, 2021
- pass more options to pager, such as smart-case search
- add a kitty linenum hint to open vscode

The linenum hint to open vscode is broken because kitty launches
vscode from the working directory of the kitty process, not the
working directory of the shell within kitty.

Opened issue:
kovidgoyal/kitty#3352
@kovidgoyal
Copy link
Owner

Update kitty. IIRC kittens were change to run in the cwd of the child
process a while ago, see line 936 of boss.py

@kbd
Copy link
Author

kbd commented Feb 27, 2021

Apologies for not stating the version I'm using, but I should be using the most recent release:

Screen Shot 2021-02-26 at 7 33 19 PM

@kovidgoyal
Copy link
Owner

Works fine for me with the following kitten:

cat ~/.config/kitty/mykitten.py
def main(args):
    import os
    print(111111111, args, os.getcwd())
    input('press enter')

kitty -o 'map f1 kitten mykitten.py'

However, from re-reading your original bug report, I think what you are
asking for, is for the hints kitten to convert relative paths to
absolute ones before calling the editor, based on the cwd of the kitten.

@kbd
Copy link
Author

kbd commented Feb 27, 2021

for the hints kitten to convert relative paths to absolute ones before calling the editor, based on the cwd of the kitten.

Rather, to launch the kitten in the cwd of the shell, so that relative paths resolve properly.

@kbd
Copy link
Author

kbd commented Feb 27, 2021

Tried that kitten, it does print the cwd that my shell is in. So why doesn't the 'hints' kitten launch the program in the correct cwd?

kovidgoyal added a commit that referenced this issue Feb 27, 2021
@kovidgoyal kovidgoyal reopened this Feb 27, 2021
@kovidgoyal
Copy link
Owner

now fixed

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

2 participants