-
-
Notifications
You must be signed in to change notification settings - Fork 588
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
Key binding to run the command immediately #78
Comments
Shift+Enter maybe? |
looks like Termion might not support multiple modifiers (like Shift+Enter) yet https://github.com/redox-os/termion/blob/dce5e7500fd709987f9bf8f3911e4daa61d0ad14/src/event.rs#L288 |
Also not sure how to actually execute the command - apending '\n' or '\u{15}' doesn't seem to help |
@elle any idea how we might tell the shell to 'don't just echo this, but execute this!'? Adding |
haha my name has an So the only solution I could think of is really gross. We could return the command with a prefix that could never be in a normal shell command (maybe a space/special comment) and then ZSH could check for this. If it exists, ZSH can then execute the command It'll have to be done this way as the subprocess won't be able to access the parent context. Plus, anything returned from Atuin is just inserted into the ZLE buffer, regardless of what it is (even newlines). |
FYI,
into a temporary file, parses it in zsh, then use |
ohhh that's awesome, thanks @yshui! |
Was searching for this issue :) Edit: Just found where to start, maybe I'll implement it in the coming weeks. I also just noticed for me some other Keybindings like |
😃 This was one of the first things I tried to do in interactive mode. I might be interested in implementing this. |
I've started experimenting with this a bit by using stty_orig=$(stty -g)
__atuin_myhistory() {
tput rmkx
# shellcheck disable=SC2048,SC2086
HISTORY="$(RUST_LOG=error atuin search $* -i -- "${READLINE_LINE}" 3>&1 1>&2 2>&3)"
exitcode=$?
tput smkx
if [[ "$exitcode" == "0" ]]; then
echo -e "${PS1@P}${HISTORY}"
_atuin_preexec "${HISTORY}"
local stty_bkup=$(stty -g)
stty "$stty_orig"
eval "${HISTORY}"
_atuin_precmd
stty "$stty_bkup"
else
READLINE_LINE=${HISTORY}
READLINE_POINT=${#READLINE_LINE}
fi
} The It's not super mature yet but it does fix the issue of the new command being a child of atuin. What do people here think about this approach, especially the exit code stuff? Edit: fixed tty configuration during eval (otherwise interactive programs don't work) |
I've played some more with this and now think that the _atuin_search() {
...
exitcode=$?
if [[ -n $output ]]; then
RBUFFER=""
LBUFFER=$output
fi
if [[ "$exitcode" == "0" ]]; then
if [[ -n $output ]]; then
zle accept-line
fi
zle redisplay
else
zle reset-prompt
fi
} The next question is how to best communicate from atuin to the shell. My local version is using exit codes and |
Any chance of this change ever happening? |
Yes |
FWIW https://github.com/dvorka/hstr supports this across multiple shells so there might be something to learn from there also. |
Apparently referencing issues from discussions doesn't link back, but @davidhewitt has a patch that would be an excellent starting place. This has been an open issue for a long while, and a few people have started PRs to get it in. I'm going to open a PR with David's commit as the starting place tonight/tomorrow, unless anybody else really fancies getting it in 😊 https://github.com/atuinsh/atuin/discussions/817#discussioncomment-7323475 |
TLDR of #817:
I really like that approach of @davidhewitt! Should really feel natural. I also like that this is aimed to be the default for new users, but keeping current behavior for existing users. But definitely I will switch as soon as it's available. I'm looking forward for a version featuring this! |
This will be merged for |
@yannickulrich, do you remember any specific issues you ran into with the bash example you laid out in #78 (comment)? We had to disable this feature for bash because we weren't able to make interactive input work, however your stty solutions do seem to fix that problem, but I haven't tested extensively. |
Released in v17 :) (for all shells other than nushell) I think we can close this |
It'd be nice if there were a key binding that somehow ran the selected command immediately instead of simply placing it on the command line. Having to hit enter twice to run a command I don't want to modify is a tad annoying.
The text was updated successfully, but these errors were encountered: