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

feat: add command-line editing for bash, fish, zsh #253

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mikesmithgh
Copy link
Owner

@mikesmithgh mikesmithgh commented May 31, 2024

closes #245

TODO:

  • documentation
  • tests
  • demo

@@ -71,8 +71,15 @@ end
M.open_paste_window = function(start_insert)
vim.cmd.stopinsert()

if vim.env.KITTY_SCROLLBACK_NVIM_EDIT_INPUT then
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider adding a mode env var that can be used in the future for other special cases

ksb_input_file="$ksb_input_dir/input.ksb_editcommand"
cp "$input_file" "$ksb_input_file"

kitty @ kitten /Users/mike/gitrepos/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded your path here

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works after patching it manually though

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for pointing this out! I just removed the hardcoded path. Could you try with latest?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works 👍

@IndianBoy42
Copy link

related feature we might want is being able to scroll the scrollback buffer, or more generally a way to go to the scrollback buffer and keep the prompt window open at the same time, and then go back to the prompt window.

@IndianBoy42
Copy link

oh I just noticed the prompt window buffer filetype is bash, in this case we can use the correct filetype based on the shell. i think in general we can figure out what shell is running using kitten @ ls right?

@mikesmithgh
Copy link
Owner Author

mikesmithgh commented May 31, 2024

oh I just noticed the prompt window buffer filetype is bash, in this case we can use the correct filetype based on the shell. i think in general we can figure out what shell is running using kitten @ ls right?

good catch. so it pulls it from vim.o.shell https://github.com/mikesmithgh/kitty-scrollback.nvim/blob/main/lua/kitty-scrollback/windows.lua#L104

I think that may just be what your SHELL environment variable is set to? What results do you get for echo $SHELL.

There is an option to override this in kitty-scrollback.nvim opts.paste_window.filetype. But, I agree this looks like a bug even without this functionality. If I am in bash and then go to fish and open kitty-scrollback.nvim it has the wrong shell. I opened the issue #254 for this.

@mikesmithgh
Copy link
Owner Author

mikesmithgh commented May 31, 2024

related feature we might want is being able to scroll the scrollback buffer, or more generally a way to go to the scrollback buffer and keep the prompt window open at the same time, and then go back to the prompt window.

interesting, yeah I'd have to think about this.

I suppose I could have the ability to not autoclose the floating paste window or an option to open a regular window instead of a floating window. Then you can just navigate back and forth. I opened #255 for this feature.

@mikesmithgh
Copy link
Owner Author

@IndianBoy42 thanks for the feedback! I like the ideas

@mikesmithgh
Copy link
Owner Author

oh I just noticed the prompt window buffer filetype is bash, in this case we can use the correct filetype based on the shell. i think in general we can figure out what shell is running using kitten @ ls right?

good catch. so it pulls it from vim.o.shell https://github.com/mikesmithgh/kitty-scrollback.nvim/blob/main/lua/kitty-scrollback/windows.lua#L104

I think that may just be what your SHELL environment variable is set to? What results do you get for echo $SHELL.

There is an option to override this in kitty-scrollback.nvim opts.paste_window.filetype. But, I agree this looks like a bug even without this functionality. If I am in bash and then go to fish and open kitty-scrollback.nvim it has the wrong shell. I opened the issue #254 for this.

@IndianBoy42 FYI I just pushed a fix for this. It should pull the filetype from the shell that is configured in Kitty now.

@IndianBoy42
Copy link

IndianBoy42 commented Jun 1, 2024

oh I just noticed the prompt window buffer filetype is bash, in this case we can use the correct filetype based on the shell. i think in general we can figure out what shell is running using kitten @ ls right?

good catch. so it pulls it from vim.o.shell https://github.com/mikesmithgh/kitty-scrollback.nvim/blob/main/lua/kitty-scrollback/windows.lua#L104

I think that may just be what your SHELL environment variable is set to? What results do you get for echo $SHELL.

Oh I just remembered about this, I manually set shell=bash because sometimes plugins assume that shell is posix compatible, or bash compatible and try to use it to run scripts. So if set shell=fish they error out. Using vim.env.SHELL or kitty's shell detection makes sense. it works now though so all good 👍

@mikesmithgh mikesmithgh force-pushed the feat-command-line-editing-mode branch from 31d9a1e to 41b0ab4 Compare June 7, 2024 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: make the current cmdline editable in place
2 participants