Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

So when using arrow up/down to cycle through prior commands, is there any way I can limit those to the commands used from the current directory? This would make my life 10 times easier...

share|improve this question

migrated from stackoverflow.com Jun 20 '13 at 21:46

This question came from our site for professional and enthusiast programmers.

3 Answers 3

You should take a look at https://github.com/tymm/directory-history

It's a plugin for zsh and does exactly what you want.

Remarks/Bug reports/Stars/... are appreciated.

share|improve this answer

No. There's no such thing as a per-directory history in any of the shells I know. Your best bets are modifying some of the open sourced shells or hacking into hooks provided by zsh when running the cd command to load a new history. I'm pretty sure some zsh guru would find this a worthwile challenge.

share|improve this answer
    
Thanks, zsh looks promising for this, but I've never messed with it myself. Hopefully someone has an idea... –  Brade Jun 20 '13 at 14:46

zsh allows you to modify the entries that are stored in your history, it is easy to add a comment with the directory where you ran the command (see here http://stackoverflow.com/questions/2824051/saving-current-directory-to-zsh-history).

You just need to write a custom history search widget/function that will filter results based on $PWD.

share|improve this answer
    
Put in bash or zsh history absolute path to files I am working on gives an example of how to do this in bash. –  Scott Jun 22 '13 at 3:33
    
Thanks, I'll try to mess around w/ this when I have time (which isn't now sadly). In the meantime, if someone can provide a ready-made answer, great =D –  Brade Jun 24 '13 at 15:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.