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
+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