3 ms·
Currently, I'll append a comment to a frequently used command for easy searching from my history. For a simple example, I can access `git diff -w ; git diff -w
by buu700 5y ago
Currently, I'll append a comment to a frequently used command for easy searching from my history. For a simple example, I can access `git diff -w ; git diff -w --cached # gitdiff` by pressing Ctrl+R and typing `# gitd`.
For commands I use frequently or that are clunky to maintain as one-liners, I'll convert them into functions in my bashrc.
This seems like the best of both worlds in many ways, or at least is a great third option to have.
- silentprog 5y agoInteresting way of aliasing right from where you use it! I actually replaced my default shell history search with fuzzy search using (https://github.com/junegunn/fzf https://github.com/junegunn/fzf), I can highly recommend it!
- buu700 5y agoHuh, apparently I've already starred that. It must have been posted on HN at some point.
- cyberge99 5y agoInteresting, I think there’s a shopt that I’m missing. When I append a comment, it’s not recorded in bash history, as I’d expect.
- buu700 5y agohttps://unix.stackexchange.com/a/17587/14123 https://unix.stackexchange.com/a/17587/14123
- westurner 5y agoFrom https://westurner.github.io/hnlog/#comment-20671184 https://westurner.github.io/hnlog/#comment-20671184 :: > I log shell commands with a script called usrlog.sh that creates [per-]$USER and per-virtualenv tab-delimited [$_USRLOG] logfiles with unique per-terminal-session identifiers [$_TERM_ID] and ISO8601 timestamps; so it's really easy to just grep for the apt/yum/dnf commands that I ran ad-hoc when I should've just taken a second to create an Ansible role with `ansible-galaxy init ansible-role-name ` and referenced that in a consolidated system playbook with a `when` clause. https://westurner.github.io/dotfiles/usrlog.html#usrlog https://westurner.github.io/dotfiles/usrlog.html#usrlog stid \#tutorial; echo "$_TERM_ID" tail -n11 $_USRLOG ut -n11 grep "$_TERM_ID" "$_USRLOG" usrlog_grep "$_TERM_ID" ug "$_TERM_ID" usrlog_grep_parse "$_TERM_ID" ugp "$_TERM_ID" # `type ugp` usrlog.sh: https://github.com/westurner/dotfiles/blob/master/scripts/usrlog.sh https://github.com/westurner/dotfiles/blob/master/scripts/us...