Live data from Hacker News

Better Bash History (2012)

sanctum.geek.nz

81–85 of 85 posts

Re: Better Bash History (2012)

#81
post #50
post #20

Earlier quoted context omitted.

I also recommend FZF. Really very handy for doing CTRL-R searches. I also use it for doing interactive git rebases. I have an alias for doing a fuzzy rebase interactive (frbi): frbi = !git rebase -i $(git log --pretty=oneline --color=always | fzf --ansi | cut -d ' ' -f1)^

This is a great idea, thanks for it! I've done similar things with using fzf to git add, git diff, and so on, but I hadn't thought of using it to pick a commit to rebase from. I made a few changes so I figured I'd post them back here in case you're interested: pick-commit = # equivalent to your git log... cut... rif = "!f() { rev=$(git pick-commit); [[ $rev ]] && git ri $rev~; }; f" "rif" = "rebase interactive fzf/fu…

Can't edit this anymore.

    pick-status-files = "!f() { git status -z | xargs -0n1 | cut -c4- | fzi --print0 | xargs -0to git "$@"; }; f"
can just be:

    pick-status-files = !git status -z | xargs -0n1 | cut -c4- | fzi --print0 | xargs -0t git
I'd recently converted it from a standalone script so I just converted it verbatim into a function.

Re: Better Bash History (2012)

#82

Earlier quoted context omitted.

I can almost see the appeal, when you think of decorating it. Consider a table with five columns: * uid * pwd * cmd * exit-code * datetime Now you can `SELECT pwd,cmd WHERE exit-code != 0` to see all failed-commands.

I see your "decorated" sql table, and I raise you my text file with five columns, that you can grep and sed and awk as if there was no tomorrow. cat history.txt | awk '$4 != 0'

"As if there was no tomorrow" - exactly, because once you add another column suddenly $4 points to something completely different and you have to rewrite everything.

Not to mention $4 is completely arbitrary and it's impossible to tell without prior knowledge which field it's referencing.

The original query `SELECT pwd, cmd WHERE exit-code != 0` is both descriptive and won't break with future updates.

Re: Better Bash History (2012)

#83

Earlier quoted context omitted.

autocompletion in fish takes into account the directory where you are at, so it will autocomplete commands ran in the same directory before other commands.

If that's what's being referred to, it sounds like dual_base meant to reply to aaronharnly? As mentioned, my setup isn't based on working directory.

Oh, I see. I interpreted "context" as current working directory. I took a look at your .bashrc but I couldn't detemine any sort of partitioned history. Are you saying that you have something like a virtual environment (as in Python) and the bash command history is separated according to the environment?

Re: Better Bash History (2012)

#84

Earlier quoted context omitted.

If that's what's being referred to, it sounds like dual_base meant to reply to aaronharnly? As mentioned, my setup isn't based on working directory.

Oh, I see. I interpreted "context" as current working directory. I took a look at your .bashrc but I couldn't detemine any sort of partitioned history. Are you saying that you have something like a virtual environment (as in Python) and the bash command history is separated according to the environment?

I split up my bashrc, pulling in different "component" files: https://github.com/dlthomas/config-files/blob/master/.bashrc...

The history file is set here: https://github.com/dlthomas/config-files/blob/master/.bash.d...

Re: Better Bash History (2012)

#85
post #30

I have a global bash history, having set up bash/zsh to [immediately share without any annoying race conditions.][2] I use FZF mapped to CTRL+R to search through my history. The unique thing is that I use a [python script (in my dotfiles)][1] to clean the history in a more advanced way than is possible with HISTIGNORE. The script removes duplicates, leaving the most recent copy and removes lines matching several rege…

If one is only interested to remove duplicates (your script does more) I've found this one liner in a StackExchange post: awk '!x[$0]++' ~/.zsh_history

Note that this only keeps the first copy, not the most recent copy. To make it so that it only keeps the most recent, you would need to run this through `tac` twice.
Post reply on HN