kamyar / hst

history search & picker in ncurses - also can pick other things

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hst (the Picker)

HST is history search & picker in ncurses - also can pick other things

asciicast

Though it can search and pick other things as well. Such as git branch | git checkout

asciicast

You can also use it in multi select mode. Useful for select & copying some files etc.

asciicast

Install

Mac Os X:

sudo pip install hst

Linux:

sudo pip install hst

Virtualenv

pip install hst

Usage

hst will grab your history by default.

hst

if you select something and press enter it will execute that command. If you press F6 it will open the command in editor ($EDITOR), any other key will be used to filter/search the results. hst will make your history lines unique and will favor the most used in search.

for example if you are using git commit 100 times a day and git push only once, when you type git, git commit will be in the first place.

you can also open a file in hst as an input, say you have a list of hosts and select one and ping

hst -i hosts.txt -e "ping"

you can also pipe in some input and wrap it with something.

git branch | hst -e "git checkout"

you can give a separator, for example, copy some python file, {} will be replaced with file.

find . -name '*.py' | hst -e 'cp {} /tmp/'

Contribute

All contributions are welcomed.

When you clone the repo, to check your changes and try, you can do this. Please don't send pull requests without testing.

git clone git://repoaddress/hst
cd hst
virtualenv env && source env/bin/activate
python setup.py develop
ln -s `which hst` /usr/local/bin/hst

now you can use your development version of hst in other terminal tabs etc.

please note that hst uses a single thread, and you shouldn't lock it for a long time, so if you do something like enhancing search results etc. you need to test it with a big file. some people's history is over 40k lines - eg. me.

License

Its MIT license.

Why

Because i live in the terminal, and hate trying to type something i've already typed. I've tried many things in the past and none of them worked well for me.

  • cmd+R im never used to it (YMMV). it doesnt show what i am about select, just one line. most of the times, when i search for ssh, i want to see the most used ssh ones not the last ones. to find what i ssh'd i almost type all of the command. in hst i can just type ssh and see them - most used on the top.

  • even if i could use cmd+R, it doesn't work for say git branches, or cd. hst is handy, you can pipe in any output.

  • others: couldn't find a similar project

Similar & Notable Projects

$(history | cut -c 8- | sort | uniq | peco)

and it nearly works like hst. fzf doesn't find "ssh ubuntu@app1.someproject...." when i type in "ssh app1 ubuntu" finds some curl commands, but peco does a good job on finding. only you have to type in a few more things in peco since it doesn't favor the most used commands.

anyways, ymmv with other tools.

Missing Features - TODO's

  • need some viewport kind of logic, say you hit pagedown, it should scroll down.
  • piping out the selected line doesn't work
  • can't do fuzzy match eg: "cord" works for "cordova" but not "crd". it takes too long on long list of lines.
  • multiple selection
  • pipe in with scores, eg. boost current branch when piping git branch etc.

How

uses Python and Curses library

Disclaimer

Its as is, if your hard disk is wiped out because of hst, i'm not responsible.

About

history search & picker in ncurses - also can pick other things


Languages

Language:Python 96.8%Language:Shell 3.2%