feat: add git and history utility functions

- Add branch, fc, and gitup functions
- Update README documentation for new functions and abbreviations
- Remove obsolete push-vim function
This commit is contained in:
2026-04-29 17:23:13 -04:00
parent dc212ec704
commit 6722deea3c
6 changed files with 77 additions and 9 deletions
+10 -1
View File
@@ -193,6 +193,8 @@ rm -f file.txt # Falls through to standard rm -f
| Function | Description |
|---|---|
| `branch` | Switch to or create a git branch |
| `gitup` | Fetch updates and show git status |
| `git-clean` | Fetch, prune, update current branch, delete orphaned local branches |
| `git-clean --force` | Same but force-deletes unmerged orphaned branches |
| `clone` | `clone-in-kitty` wrapper |
@@ -257,6 +259,7 @@ rm -f file.txt # Falls through to standard rm -f
|---|---|
| `edit` / `e` | Open in Neovim |
| `view` | Open in Neovim read-only mode |
| `fc` | Edit and execute the last command (Bash-style `fc`) |
| `nvimup` | Update Neovim headlessly |
| `nlazyup` | Sync Lazy.nvim plugins headlessly |
@@ -338,6 +341,7 @@ Abbreviations expand in-place as you type, keeping your history clean.
| Abbr | Expands To |
|---|---|
| `cm` / `cz` | `chezmoi` |
| `cmcd` | `chezmoi cd` |
| `cme` | `chezmoi edit` |
| `cmad` | `chezmoi add` |
| `cmap` | `chezmoi apply` |
@@ -387,7 +391,11 @@ Named context shortcuts (e.g. `dcr`, `dck`) live in `~/.config/.user-dots/fish/l
| `ssc` | `sudo systemctl` |
| `scu` | `systemctl --user` |
| `st` | `systemctl status` |
| `scs` | `systemctl start` |
| `scr` | `systemctl restart` |
| `ssct` | `sudo systemctl status` |
| `sscs` | `sudo systemctl start` |
| `sscr` | `sudo systemctl restart` |
### Beads (bd)
@@ -395,7 +403,8 @@ Named context shortcuts (e.g. `dcr`, `dck`) live in `~/.config/.user-dots/fish/l
|---|---|
| `bl` | `bd list` |
| `bs` | `bd sync` |
| `bc` | `bd create --title` |
| `bC` | `bd create --title` |
| `bsh` | `bd show` |
| `lb` | `lazybeads` |
---
+1 -1
View File
@@ -218,7 +218,7 @@ abbr -a dcls 'docker context ls'
### Beads ###
abbr -a bl 'bd list'
abbr -a bs 'bd sync'
abbr -a bc 'bd create --title'
abbr -a bC 'bd create --title'
abbr -a bsh 'bd show'
abbr -a lb lazybeads
+14
View File
@@ -0,0 +1,14 @@
function branch --description 'Switch to or create a git branch'
if not git rev-parse --is-inside-work-tree >/dev/null 2>&1
echo "Not a git repo."
return 1
end
# Check if the branch already exists locally
if git show-ref --verify --quiet refs/heads/$argv[1]
git checkout $argv
else
# If it doesn't exist, create it
git checkout -b $argv
end
end
+37
View File
@@ -0,0 +1,37 @@
function fc --description "Edit and execute the last command (Bash-style fc)"
set -l tmpfile (mktemp /tmp/fish_fc.XXXXXX).fish
if count $argv >/dev/null
# Search for a specific previous command
builtin history search --max=1 "$argv" | sed 's/^[0-9-]* [0-9:]* //' >$tmpfile
else
# Grab the last 2 commands, then take the 2nd one (the one before 'fc')
# This avoids the --skip flag entirely
builtin history --max=2 | sed 's/^[0-9-]* [0-9:]* //' | sed -n 2p >$tmpfile
end
# Set editor with fallback
set -l editor $EDITOR
if test -z "$editor"
set editor vi
end
# Only open editor if we actually got a command
if test -s $tmpfile
$editor $tmpfile
# Final check if user cleared the file in the editor
if test -s $tmpfile
set -l command (cat $tmpfile)
rm $tmpfile
commandline -r "$command"
commandline -f execute
else
rm $tmpfile
echo "fc: Aborted (empty file)"
end
else
rm $tmpfile
echo "fc: Could not retrieve history"
end
end
+15
View File
@@ -0,0 +1,15 @@
function gitup --description 'Fetch updates and show git status'
# Check if we are even in a git repository
if not git rev-parse --is-inside-work-tree >/dev/null 2>&1
echo "Check your map! You aren't in a git repository."
return 1
end
if count $argv >/dev/null
git fetch $argv
else
git fetch
end
and git status
end
-7
View File
@@ -1,7 +0,0 @@
# Copyright (C) 2026 Rootiest
# SPDX-License-Identifier: AGPL-3.0-or-later
function push-vim --wraps=/home/rootiest/projects/propogate-vim/send.sh --description 'alias push-vim=/home/rootiest/projects/propogate-vim/send.sh'
/home/rootiest/projects/propogate-vim/send.sh $argv
end