-
tldr: what about For example, if I typed > [tmux new session]: tmux new-session -s main
1/99
> tmux then press enter, and it runs whatever it is. But sometimes I need to put some variation to my configured command, like :
currently, if the command would be pasted to the current terminal prompt instead of instantly executing, it would give the last chance to put some variation. ps. BTW, is |
Beta Was this translation helpful? Give feedback.
Replies: 14 comments 2 replies
-
Well, maybe add this bash snippet in your It can paste command to termnal prompt instead of instant execution. Works for me. pet-select ()
{
BUFFER=$(pet search --query "$READLINE_LINE");
READLINE_LINE=$BUFFER;
READLINE_POINT=${#BUFFER}
}
bind -x '"\C-x\C-x": pet-select' |
Beta Was this translation helpful? Give feedback.
-
I'm currently use zsh, so basically not working. I want to something like this :
anyway thanks for comments! are you maintainer of pet? |
Beta Was this translation helpful? Give feedback.
-
I'm not a maintainer. I just start using it in a few days. In this video I double hited ctrl-x, to call the pet-select function. Directly called pet-select is useless... As you have already find out. c-x.mp4The P.S. Sorry for the low-quality video, but my screen recording software is broken (caused by Wayland), sigh... |
Beta Was this translation helpful? Give feedback.
-
You can check whether zsh has feature like |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Thank you. Gonna work now, I‘ll try it today later. |
Beta Was this translation helpful? Give feedback.
-
Maybe some of the syntax is not supported? Maybe you can write sth into READLINE_LINE, and check whether it works. If so you can write your own script to support this feature. |
Beta Was this translation helpful? Give feedback.
-
My bash version is 5.0.17. |
Beta Was this translation helpful? Give feedback.
-
I realized this feature is not easy than I thought first... I want sth like "modify command line buffer by function" and honestly i have no idea how it could be without key-binding (I want to call function directly). So I decided to make a just pet-search ()
{
BUFFER=$(pet search --query "$1");
echo $BUFFER | pbcopy
}
+) Oh, I found the way : pet-search ()
{
BUFFER=$(pet search --query "$1");
print -z $BUFFER
} BTW this print looks like zsh-builtin function:
with it, I can make what I needed |
Beta Was this translation helpful? Give feedback.
-
Congratulations! IMO, “make what I needed” is the way terminal tools designed to be —cli is so versatile! (P.S. I don’t like MacBook too ╮( ̄▽ ̄"")╭ but pbcopy is good |
Beta Was this translation helpful? Give feedback.
-
I got what I needed but not sure whether this feature came in |
Beta Was this translation helpful? Give feedback.
-
For anyone arriving here and using
|
Beta Was this translation helpful? Give feedback.
-
...and with a wrapper function you can define a subcommand # ~/.config/fish/functions/pet.fish
function pet
if test (count $argv) -ge 1 -a $argv[1] = "alte"
commandline -i (command pet search $argv[2..-1])
else
command pet $argv
end
end i called it |
Beta Was this translation helpful? Give feedback.
-
You can definitely do this already by using the zsh/bash snippets in the readme that interface with pet search --query ! Then when you call pet through ctrl+s the command won't get executed, only printed to your terminal for you to press Enter. |
Beta Was this translation helpful? Give feedback.
Well, maybe add this bash snippet in your
bashrc
can help you?It can paste command to termnal prompt instead of instant execution. Works for me.