rupa / z

z - jump around
Do What The F*ck You Want To Public License
16.26k stars 1.17k forks source link

Suggestion: Z is awesome. It would be great to have a similar command for history. #188

Closed thefzsalam closed 7 years ago

thefzsalam commented 8 years ago

Z is a real productivity booster. It would be great to have a similar command h for history. For example, I frequently tweak various config files here and there, especially i3wm's configs. If there existed a similar command, I could type: h vim i3 <tab> to have this autocompleted to h vim ~/.i3/config. Pressing enter would run the command after h. I would like to contribute to this, but don't know where to start.

johnfb commented 8 years ago

if your using bash, the default is ctrl+r to search history. Though it shows the most recent that matches and then lets you scroll through them rather than the most frequent/recent one.

On Thu, Apr 28, 2016 at 7:33 AM, Farzeen notifications@github.com wrote:

Z is a real productivity booster. It would be great to have a similar command h for history. For example, I frequently tweak various config files here and there, especially i3wm's configs. If there existed a similar command, I could type: h vim i3 to have this autocompleted to h vim ~/.i3/config. Pressing enter would run the command after h. I would like to contribute to this, but don't know where to start.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/rupa/z/issues/188

rupa commented 8 years ago

I don't have a need for this, because, in addition to what @johnfb said, I have this in my ~/.inputrc

$if mode=emacs
    # "\e[A" and "\e[B" being whatever your terminal uses for up & down.
    "\e[A": history-search-backward
    "\e[B": history-search-forward
    # (bonus) Two escapes clear command line.
    "\e\e": "\C-a\C-k"
$endif

which makes up and down do history-search like ^R, and is Good Enough For Me.

doubleloop commented 8 years ago

If you are using zsh, I recommend https://github.com/psprint/zsh-navigation-tools for history

balta2ar commented 8 years ago

You might want to look as https://github.com/junegunn/fzf, which integrates with Ctrl-R to allow you fuzzy search through your history. Really awesome, can't live without it.

liloman commented 8 years ago

Hi,

It's amazing how you can spend 2 minutes reading other people troubles and found out that we all have the same kind of unresolved problems. :)

I will start tomorrow in this issue and when it'll be done I'll post it here.

I already have the framework to make easily the bash<->readline communication . I want now dynamic on shell completions (I already made the static shell completions also ;)).

The closer of what @farseenabdulsalam means is dynamic-complete-history but with substring and that it's what I'm going to implement very soon with completions (if it's even possible and nice of course). :trophy:

liloman commented 8 years ago

Done! :dancer:

It was pretty easy I don't think I will try to implement on-fly dynamic autocompletions "soon" cause I don't have much time and I'm more than happy with this. I have bind them to the default shitty C-r/C-s that never used (can't understand why people insist on using them ¿?).

>vi ~/.bashrc
>cp ~/.bashrc /tmp/bashrc1
>...
>mv rc (C-r)
Enter Control-q to reset search
>mv /tmp/bashrc1(C-r)
>mv ~/.bashrc(C-s)
>mv /tmp/bashrc1 /tmp/win

No C, no ncurses, no python just Bash. :)

liloman commented 8 years ago

Sorry for the spam but I wanted to let you know that I have made a library/framework for this stuff with everything explained.

asyncBash

Cheers

rupa commented 7 years ago

interesting discussion but out of scope for this project so ima close this