With `bash`, you can show which mode you're in by putting this in your `~/.inputrc`:
show-mode-in-prompt on
It makes your prompt look like this: [foo@bar ~]$ # before turning it on
@[foo@bar ~]$ # after
@[foo@bar ~]$ set -o vi
(ins)[foo@bar ~]$ # and after I press esc:
(cmd)[foo@bar ~]$
Customize these with `emacs-mode-string`, `vi-ins-mode-string`, and `vi-cmd-mode-string`. function preexec() {
lrn_timer=${timer:-$SECONDS}
lrn_command="$1"
}
lrn_timer=0
function precmd() {
[[ -v lrn_timer ]] || return # preexec() doesn't set timer if no command run (e.g. from ^C before running)
timer_show=$(($SECONDS - $lrn_timer))
unset lrn_timer
# 10 is the notification threshold in seconds
if (( ${timer_show} > 10 )); then
terminal-notifier -sound default -message "Exit $? in ${timer_show}s: $lrn_command"
fi
}
(Based on https://gist.github.com/petethepig/2d29e8b7e2ebc808bfe760b63...)What I do in these situations (assuming the job is still in the foreground, and can be interrupted), is suspend the task with ctrl+z and resume with `fg`, chaining it with some other command:
fg; notify-send "done"
This uses the "job control" feature of `bash`, so it requires no extra setup. Your approach has the simple advantage however, that once it's set up, it just works, automatically.I have 5 un-pushed commits. I missed a 1-line change to that first one. I add that one line change to staging (gitui/lazygit/whatever), then I want to `git commit --fixup=COMMIT`. Finding that COMMIT is always a manual process for me for two reasons.
First I have to find the commit to which it applies. This commit is almost always the commit that changed the same line, or added lines around it, or something similar. I guess you could say it's the commit with the closest proximity to the change I'm adding.
Second I have to find the hash of that commit. If I've since done something like an autosquash rebase then it'll have changed. I generally end up using the mouse to do a copy/paste at this point.
Why not skip the fixup commits and just rebase right then, you might ask. Well the commits are signed, and signing requires tapping my yubikey for each commit after that.
I would really like to be able to do something like `git commit --I'm-an-idiot-and-missed-this-so-please-apply-a-fixup-to-the-proper-commit`, and have it do the figuring out for me.
git commit --fixup=':/message regexp'
This will find the youngest commit where the message matches the "message regexp" pattern.
See also: https://git-scm.com/docs/gitrevisionsIf I were to apply this patch, this commit will…
- Simplify FooWidget
- Add optional table support
- Remove trailing whitespace
- Update fizzbuzz to 1.2.0
- Merge branch 'feature/ABC-123-foobar'
- Revert "Add foo to bar"