Fly through your shell history
github.com
github.com
I’ve been using `history | grep` since forever (usually `history | grep foo | tail -n 5` which has been a single-character alias for more than 30 years). Hard to beat. Since history gives you the line number you can just `!12345` — no need to copy/paste, and works through an ssh connection!
I have "history | grep" basically aliased to "h?"
It may be a bit weird to use a question mark as part of a Bash alias that said: sorry for the confusion!
I’ve decided to end sentances with two to try to avoid their ire..
But just to be clear: I didn’t at all write “surprised” as some polite euphemism for “this is dumb”. Clearly people have found it useful for a while and it’s harmless easy for me to collect some empirical data, so I just installed it. Might turn out to be a big win.
$ cat ~/bin/f
#!/bin/bash
if [ "$1" != "" ] ; then
find . -type f | grep -v '\.git' | grep -i "$1"
else
find . -type f | grep -v '\.git'
fi find . -type f -not -path '*/.git/*' -name "*$1*"There is nothing more disappointing than not being able to find the cool command line I used a week ago because the shell I opened briefly and forgot about has overwritten it - maybe that's my poor setup though
Regarding the history problem, there’s likely a flag VSC can pass to Zsh to disable writing to history for that session.
Edit: looks like there are several ways: https://unix.stackexchange.com/questions/692913/temporarily-...
Even if your point was right though, I’d argue that because Bash is still being maintained, any defaults originating from the 80s should be updated. Yes, I know there are low footprint environments out there that still have writable storage in the region of a few megabytes (or even less), but we have other shells for those use cases.
I agree that the default is unfortunate but the points above seem more important.
And bash has already changed numerous features over the years.
I've been using it for the last couple of years. My history file has around a quarter million entries so far.
export HISTCONTROL=ignoreboth:erasedups
Somewhere in your rc files.
If you do, ehe, that's some serious variety of work on the CLI !
mcfly doesn't remove dups and also stores additional info about the executed commands like pwd, timestamp and return code.
export HISTSIZE=65535
shopt -s histappend
PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
I miss it though on other computers and suffer until I set it up on new ones.Why limit yourself to 16bit?
Computers are fast, memory is cheap and 16 bits is not that big. My .bash_history is clocking at 55814 now with dedup on. Granted, it's beeing going for years, but still, no reason to punish yourself.
As you can see, Mr. Anderson, we've been keeping our eye on you for some time now
Checking now it's 104,545 unique commands. It goes back to April 2012.
Note that this is just my laptop; things I've run on my work computer or when ssh'd somewhere else aren't included.
# Undocumented feature which sets the size to "unlimited".
# http://stackoverflow.com/questions/9457233/unlimited-bash-history
export HISTFILESIZE=
export HISTSIZE=
and just depend on exiting my shells to store data long term.> "Numeric values less than zero result in every command being saved on the history list (there is no limit)."
export HISTFILESIZE=-1
export HISTSIZE=-1 promptFunc() {
echo "$(date +%Y-%m-%d--%H-%M-%S) $(hostname) $PWD $(history 1)" \
>> ~/.full_history
}
PROMPT_COMMAND=promptFunc
Or, in zsh: precmd() {
echo "$(date +%Y-%m-%d--%H-%M-%S) $(hostname) $PWD $(history -1)" \
>> ~/.full_history
}I've used mcfly for years and I appreciate the hard work cantino has put into it, but mcfly is currently looking for a maintainer while the maintainer of Atuin has recently committed to doing so full time (https://ellie.wtf/posts/i-quit-my-job-to-work-full-time-on-m...). That may make a difference to some people considering which one to pick.
Both are implemented in Rust and use SQLite as storage, so both should be equally performant in terms of startup latency and storage capacity.
The ctrl+R UI of each is different but that comes down to personal taste.
I’ll clarify in the docs
It didn't ask me to login...
> I tried to run a search locally... but I have to run a PostgreSQL server
PostgreSQL is for the server? You don't need a server. It uses sqlite, verifiable by running
$ sqlite3 ~/.local/share/atuin/history.db $ SELECT * FROM history LIMIT 10;
Did you actually try it? I don't know where you got all this from.
> The key feature of McFly is smart command prioritization powered by a small neural network that runs in real time. The goal is for the command you want to run to always be one of the top suggestions.
Would the internal database of McFly keep often searched for commands from the past, even though they're out of the bash history?
> Non-numeric values and numeric values less than zero inhibit truncation.
One side note -- I made a small tool to integrate the McFly database with the fzf UI, which might be of interest to you [1]. Overall I've been a happy user of McFly for a few years, and it's 100% an upgrade over bash's command history (properly storing commands from multiple terminal windows; collecting working directory + exit status info, etc.)
I personally have a custom shell function inspired by virtualenvwrapper's 'workon' that sets the stage, so to speak, based on its arguments. One of the things it does is export various env variables including HISTFILE.
For me this is a more flexible way to introduce customisation (for instance one of the last thing my function does is look for a project specific function (name of which is env derived) and execute it ...and then it's turtules all the way down )
[1]: https://www.siliconbunny.com/fsn-the-irix-3d-file-system-too...
My assumption is OS package manager would always have more packages compared to Homebrew, and I don't know if Homebrew on Linux even supports GUI packages or not.
Also, I use zsh which filters history when using up/down arrows to whatever you typed. So you can do "git" [up] [up] [up] to cycle through all recent git commands which is super useful.
My shell history has a limit of 25 commands and is not saved after logout. I very rarely find that to be too short. In almost every case, if I want to repeat a command it's either the previous one or no more than a few prior than that.
Anything I need to do repeatedly I put in an alias or script or function.
# history-search-backward / history-search-forward bound to the up and down arrows
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
set show-all-if-ambiguous on
set completion-ignore-case on
Will search through anything matching what you've already entered. Type something like "gr" and scroll up or down to see all your previously used grep commands.
Saw this long ago on here and it's on every machine I use now, can't live without it. Thankyou to whoever originally posted it. # tsch-style history search esc-n/esc-p
bindkey '\ep' history-beginning-search-backward
bindkey '\en' history-beginning-search-forward
If I need substrings or searching for something further back in time I just use `history -99999 | rg`Tried ctrl-r bash style for about a month back when I was switching off of tcsh and hated it.