Comment by CraigJPerry
4 years ago
Set a huuuuuuuge shell history https://github.com/craigjperry2/dotfiles/blob/aa77ddcbde63bf... then fzf ctrl+r bindings mean you can recall anything right where you need it.
If you’re going to do this then have an escape hatch for commands you don’t want memorised https://github.com/craigjperry2/dotfiles/blob/aa77ddcbde63bf...
protip: use comments to remind yourself or make commands searchable, e.g.
now when you search history you can do so with plain text:
you could of course take this further by 'tagging' commands if you wish and then grep for that tag later to return longer cheatsheets
I‘ve been doing this ever since I migrated from Windows to Mac in 2015. My bash history has over 40k lines, datestamped. I can recall any command I have typed in my terminal in the past seven years. Extremely helpful whenever I need to repeat anything in the terminal.
# Edit
I sometimes add comments to commands via `# This‘ll do this and that` so that I can find the command by those keywords in the bash history.
This. I've been doing this for a couple of years now, I'm really used to it. I've been "traveling" with my history that is over 70k lines. My dot alias file has only 3 aliases (c=clear, q=exit, gti=git).
Hope there's a project out there that helps parse, rank, or do something with a file like this. There must be interesting information.
Is gti=git for capturing typos or some other reason?
1 reply →
Maybe I'm doing something wrong, but my bash history is missing many of my commands. I assumed it was due to poor handling of multiple open terminal windows and tabs.
Is there something you are doing so the different sessions don't clobber each other?
Your file just reminded me I have "broot" installed..
Its sad how I install all those things, forget about them the next day and cd/ls/vi like a caveman.
The problem is much deeper than you think, OP...
Yep, this is my real problem. Install something that looks cool, then get wrapped up in the day-to-day and never make it muscle memory.
Sounds like I should be focusing on "one new workflow thing a week" and make it a daily habit to practice, or something.
To be honest, its not like the current way is slower - its just not that "cool".
I seem to be using "zoxide" (ie "z prj") to jump to one of my projects after opening a terminal, and mostly stay on that folder for a few days.
Some other things I'll do in Finder, etc.
I also use `history | vim -` to search through the history in the context of other things I was attempting to do. Say, if I try some command and it does not work, chances are it's not the first time and I have the correct version on the line bellow :)
a good idea, some notes:
1. 10,000 isn't 'huuuuge' for long lived workstations, but 100k ought to be good for a while (bash, but not zsh, allows disabling truncation entirely with SAVEHIST=-1)
2. if using bash, make sure that this init stuff is sourced by both login and non-login shells (from ~/.bash_profile vs ~/.bashrc respectively)
3. specifying a non-default HISTFILE near your SAVEHIST (as shown in that zshrc link) can go a long way toward avoiding an improperly-configured shell truncating your huge history log, eg point 2
History search is the way, especially with fzf. I love using fzf to pick git branches as well, so long as you use intelligible branch names :)
How do you use fzf for git branches? I didn’t know you could do that.
https://github.com/craigjperry2/dotfiles/blob/main/dotfiles/...
1 reply →