-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add command-line editing for bash, fish, zsh
closes #245
- Loading branch information
1 parent
08960ad
commit 9922f3d
Showing
9 changed files
with
169 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [[ "$1" == *bash-fc* ]]; then | ||
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) | ||
"$script_dir/edit_command_line.sh" "$@" | ||
else | ||
"${KITTY_SCROLLBACK_VISUAL:-nvim}" "$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/sh | ||
|
||
if [ -z "$1" ]; then | ||
printf 'missing input file\n' | ||
exit 2 | ||
fi | ||
|
||
# set input_file to the last argument | ||
# the last argument is used because in the case of zsh, commands maybe be passed before the filename e.g., (-c) | ||
for input_file; do true; done | ||
|
||
# after exiting this script and before it has been read by kitty-scrollback.nvim | ||
# the contents of the original input_file may be altered | ||
# avoid this by copying the input_file to a new file that will be referenced | ||
ksb_input_dir=$(mktemp -d) | ||
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 \ | ||
--env "KITTY_SCROLLBACK_NVIM_EDIT_INPUT=$ksb_input_file" | ||
|
||
# small delay before to avoid adding an extra prompt after | ||
# this command has exited and before kitty-scrollback.nvim | ||
# has had time to get the scrollback buffer from kitty | ||
sleep 1 | ||
|
||
# exit non-zero so that the command is not executed in bash | ||
exit 1 |