3 ms·
I once made a pretty dashboard: press `enter` on an empty terminal buffer to display a short git log, overview of files, and git diff stats, all colorized and i
by pseudo_meta 3y ago
I once made a pretty dashboard: press `enter` on an empty terminal buffer to display a short git log, overview of files, and git diff stats, all colorized and iconized. https://github.com/chrisgrieser/zsh-magic-dashboard https://github.com/chrisgrieser/zsh-magic-dashboard
Otherwise, I have a bunch of small utilities in my dotfiles. One of my favorites is this one for interactive staging/unstaging of files with git. Thanks to `fzf`, implemented with only ~15 loc.
```bash
function ga {
local dir="$PWD"
cd "$(git rev-parse --show-toplevel)" || return 1
local check_staged='if git diff --cached --name-only | grep -q "^"{2..}"$" ; '
local add_or_unadd='then git restore --stage -- {2..} ; else git add -- {2..} ; fi'
local file_diff='{ git diff --color=always -- {2..} ; git diff --staged --color=always -- {2..} }'
local git_status_cmd="git -c core.quotePath=false -c status.color=always status --short --untracked-files"
selection=$(
eval "$git_status_cmd" | fzf \
--ansi --nth=2.. --track \
--preview="$file_diff | delta --file-style=omit" \
--bind="enter:reload($check_staged $add_or_unadd ; $git_status_cmd)"
)
cd "$dir" || return 1
return 0 # no exiting 130
}
```