N00bDaan Posted May 21, 2016 Share Posted May 21, 2016 Hi guys 'n girls, As I never can exactly remember all the different commands I'm using in the Terminal, and since I could not find an existing workflow for this, I wrote something small: http://www.packal.org/workflow/search-terminal-history Hopefully it is helpful for others too. Might be useful to set the option HISTFILESIZE=10000000 in your .bash_profile if you want to retain history longer than the default 500 lines. Cheers! paulw 1 Link to comment
JaredWilliams Posted June 26, 2016 Share Posted June 26, 2016 Hey, couldn't find a github link but i made some changes to the file for ZSH. if someone wants to be able to use this with ZSH just replace the file term_hist.py with this: #!/usr/bin/env python # -*- coding: utf-8 -*- import sys import unicodedata import codecs from os.path import expanduser from workflow import Workflow, ICON_WEB, web, ICON_WARNING def main(wf): """Execute the query on bash_history and return results """ args = wf.args query = " ".join(args) home = expanduser("~") results = [] with codecs.open(home+"/.zsh_history", "r", encoding='ISO-8859-2') as f: searchlines = reversed(f.readlines()) for i, line in enumerate(searchlines): if query in line: histstart = line.encode("utf-8","ignore").partition(":0;") results.append(histstart[2]) for i in range(len(results)): wf.add_item(results[i], subtitle="", arg = results[i], valid=True, icon="icon.png") wf.send_feedback() return 0 if __name__ == u"__main__": wf = Workflow() sys.exit(wf.run(main)) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now