Giter Club home page Giter Club logo

jog's Introduction

jog

Print the last 10 commands you ran in the current directory

Gif of Fezzik jogging memory

Usage

  1. Add this function to your .zshrc
function zshaddhistory() {
  if [[ "${1}" != ${~HISTORY_IGNORE} ]]; then
	echo "${1%%$'\n'}⋮${PWD}   " >> ~/.zsh_history_ext
  fi
}
  1. Download or copy the jog script from this repo and place it somewhere in your $PATH.

  2. Run touch ~/.zsh_history_ext ; chmod 600 ~/.zsh_history_ext to ensure that only you can read and write your history.

  3. Restart your current terminal sessions for changes to take effect. exec $SHELL

  4. Use jog whenever you find yourself lost and confused.

It's not possible to retroactively store the directory in which a command was run, so this tool will only work from this point forward.

Todo List

Contributions and feature requests are welcome

  • Add support for other shells: bash, fish.
  • Automatically truncate .zsh_history_ext when HISTSIZE is surpassed

jog's People

Contributors

natethinks avatar fearthebadger avatar tecvoc avatar thisisrandy avatar

Stargazers

Matt avatar  avatar Brandon Paiz avatar Feraidoon Mehri avatar Halu avatar WillFleming avatar Eugene Krayni avatar William avatar ebigram avatar JunghanKim avatar Christoph Hujanen avatar Masanori Ogino avatar Le Tuan Hai avatar  avatar SatyrDiamond avatar Adam Siwiec avatar Clark Minor avatar  avatar Carlos Rojas avatar OMID Zamani avatar Steve Baker avatar Stanislas Chevallier avatar  avatar Yuiga Wada avatar ptruser avatar  avatar Faustino avatar Greg Poulos avatar Victor Jolissaint avatar Masked Man avatar Ben Briggs avatar C.J. Winslow avatar Marshall avatar 野声 avatar Claudia Stein avatar Ryan Fortner avatar hammy avatar  avatar bvac avatar Jutaro avatar Chester avatar mak avatar Andrew Southard avatar  avatar  avatar Thomas Gratier avatar Yuske Fukuyama avatar Markus Wilson avatar Mason Payne avatar Peter Cooper avatar Jon Dowdle avatar  avatar David Lee / 이다윗 avatar Blake Watters avatar Edward Ditler avatar Ajithkumar sekar avatar  avatar Marcelo Gonçalves avatar Ethan Yu avatar kan avatar Georges B. avatar Minsoo avatar vulcangz avatar Daniel Huckstep avatar Cuda Chen avatar Shohei Ueda avatar Jose Browne avatar Klaus Hartl avatar Stefan Schattgen avatar Outsider avatar Graham Scott avatar Antoine avatar Dan Champion avatar Morten Amundsen avatar Antoine avatar Leonardo Properzi avatar Frans Twisk avatar Adam Gross avatar Fritz Lin avatar Dilpreet Singh avatar  avatar Sangheon Han avatar Amadeusine avatar Ian Sutherland avatar Stefan Judis avatar Alexey Poimtsev avatar  avatar Olivier Ligot avatar Ariel Allon avatar Tobin Juday avatar  avatar Yves Buschor avatar Markus Geiger avatar Ryan Welch avatar Paweł K avatar Mirko Morello avatar Alex Zhao avatar Stan Sobolev avatar Luca Orengo avatar Rezha Julio avatar

Watchers

 avatar  avatar

jog's Issues

That's cool but can't that just be an alias?

I struggled knowing where to put the script at step 2. ("place it somewhere in your $PATH."), so I ended up doing

alias plop='less ~/.zsh_history_ext | grep -a --color=never "${PWD}   " | cut -f1 -d"|" | tail'

in my .zshrc, it kind of does the job.

you don't need separate jog file ...

... you can just add following to your .zshrc file

function jog {
  grep -v "jog" ~/.zsh_history_ext | grep -a --color=never "${PWD}   " | cut -f1 -d"⋮" | tail
}

function zshaddhistory() {
  echo "${1%%$'\n'}⋮${PWD}   " >> ~/.zsh_history_ext
}

Jog will fail for any history that has a pipe in it.

If I have a historical entry cat test | grep word when you run jog your output would be:

$ jog
cat test

instead of

$ jog
cat test | grep word

suggestion to use a special character for the break.
Something like:

Multi-line command support

$ cd
$ echo '123
456'

$ cat ~/.zsh_history_ext
$ echo '123
456'|/home/user   

$ jog
456'

jog shows just the last line of a multi-line command

What does jog mean?

I don't get where the name comes from. Which is important to remember using new aliases.

How about herestory? Or cwdhist? Something else?

Run command from history?

Thanks for creating this, I love a simple tool (yay for one liners!)

I may be missing something, but it’d be nice to have an easy way to run one of the commands in the history.

This would probably turn this into a not-a-one-liner-anymore, and maybe ZSH already has a way to turn that list into something runnable, but something like this would be cool (for me, at least 😅):

$> jog
1. ls -la
2. make
3. make clean
4. sudo rm -rf /

Type a number to run the command again, any other key to exit: [ ]

Alternatively, the ability to run a command with jog 3 would also be interesting.

Again, thanks for sharing!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.