简体   繁体   中英

Can I get command history within one directory?

In Mac terminal, is there a way to get command history within a specific directory??

I know using history we can get the log of previous commands. But I only want the log within a specific directory. I want to see what I did in this folder previously.

Bash offers no out-of-the-box way for directory-specific history files.

My solution would be to hook into the cd command and change the HISTFILE variable, denoting the current history file. This is left as an exercise for the reader since I myself would be rather annoyed to lose my most recent history with each cd and it is well possible that once you get this function going you'll not want to use it.

What is your actual problem? History too big? Then don't scroll through it, but search it. For example with alias r='fc -e -' you can repeat the last command starting with foo by typing r foo . Or enter vi mode (ESC) and then search with /foo .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM