mirror of
https://github.com/xzeldon/dotfiles-wsl2.git
synced 2025-07-17 21:16:39 +03:00
initial commit
This commit is contained in:
3
wsl/.config/fish/functions/__git.branch_has_wip.fish
Normal file
3
wsl/.config/fish/functions/__git.branch_has_wip.fish
Normal file
@ -0,0 +1,3 @@
|
||||
function __git.branch_has_wip -d "Returns 0 if branch has --wip--, otherwise 1"
|
||||
git log -n 1 2>/dev/null | grep -qc "\-\-wip\-\-"
|
||||
end
|
6
wsl/.config/fish/functions/__git.current_branch.fish
Normal file
6
wsl/.config/fish/functions/__git.current_branch.fish
Normal file
@ -0,0 +1,6 @@
|
||||
function __git.current_branch -d "Output git's current branch name"
|
||||
begin
|
||||
git symbolic-ref HEAD; or \
|
||||
git rev-parse --short HEAD; or return
|
||||
end 2>/dev/null | sed -e 's|^refs/heads/||'
|
||||
end
|
11
wsl/.config/fish/functions/__git.default_branch.fish
Normal file
11
wsl/.config/fish/functions/__git.default_branch.fish
Normal file
@ -0,0 +1,11 @@
|
||||
function __git.default_branch -d "Use init.defaultBranch if it's set and exists, otherwise use main if it exists. Falls back to master"
|
||||
command git rev-parse --git-dir &>/dev/null; or return
|
||||
if set -l default_branch (command git config --get init.defaultBranch)
|
||||
and command git show-ref -q --verify refs/heads/{$default_branch}
|
||||
echo $default_branch
|
||||
else if command git show-ref -q --verify refs/heads/main
|
||||
echo main
|
||||
else
|
||||
echo master
|
||||
end
|
||||
end
|
7
wsl/.config/fish/functions/__git.destroy.fish
Normal file
7
wsl/.config/fish/functions/__git.destroy.fish
Normal file
@ -0,0 +1,7 @@
|
||||
function __git.destroy
|
||||
for ab in $__git_plugin_abbreviations
|
||||
abbr -e $ab
|
||||
end
|
||||
set -Ue __git_plugin_abbreviations
|
||||
set -Ue __git_plugin_initialized
|
||||
end
|
201
wsl/.config/fish/functions/__git.init.fish
Normal file
201
wsl/.config/fish/functions/__git.init.fish
Normal file
@ -0,0 +1,201 @@
|
||||
function __git.init
|
||||
function __git.create_abbr -d "Create Git plugin abbreviation"
|
||||
set -l name $argv[1]
|
||||
set -l body $argv[2..-1]
|
||||
|
||||
# TODO: global scope abbr will be default in fish 3.6.0
|
||||
abbr -a -g $name $body
|
||||
end
|
||||
|
||||
# Provide a smooth transition from universal to global abbreviations by
|
||||
# deleting the old univeral ones. Can be removed after fish 3.6 is in
|
||||
# wide-spread use, i.e. 2024. __git.destroy should also be removed
|
||||
# at the same time.
|
||||
if set -q __git_plugin_initialized
|
||||
__git.destroy
|
||||
end
|
||||
|
||||
# git abbreviations
|
||||
__git.create_abbr g git
|
||||
__git.create_abbr ga git add
|
||||
__git.create_abbr gaa git add --all
|
||||
__git.create_abbr gau git add --update
|
||||
__git.create_abbr gapa git add --patch
|
||||
__git.create_abbr gap git apply
|
||||
__git.create_abbr gb git branch -vv
|
||||
__git.create_abbr gba git branch -a -v
|
||||
__git.create_abbr gban git branch -a -v --no-merged
|
||||
__git.create_abbr gbd git branch -d
|
||||
__git.create_abbr gbD git branch -D
|
||||
__git.create_abbr ggsup git branch --set-upstream-to=origin/\(__git.current_branch\)
|
||||
__git.create_abbr gbl git blame -b -w
|
||||
__git.create_abbr gbs git bisect
|
||||
__git.create_abbr gbsb git bisect bad
|
||||
__git.create_abbr gbsg git bisect good
|
||||
__git.create_abbr gbsr git bisect reset
|
||||
__git.create_abbr gbss git bisect start
|
||||
__git.create_abbr gc git commit -v
|
||||
__git.create_abbr gc! git commit -v --amend
|
||||
__git.create_abbr gcn! git commit -v --no-edit --amend
|
||||
__git.create_abbr gca git commit -v -a
|
||||
__git.create_abbr gca! git commit -v -a --amend
|
||||
__git.create_abbr gcan! git commit -v -a --no-edit --amend
|
||||
__git.create_abbr gcv git commit -v --no-verify
|
||||
__git.create_abbr gcav git commit -a -v --no-verify
|
||||
__git.create_abbr gcav! git commit -a -v --no-verify --amend
|
||||
__git.create_abbr gcm git commit -m
|
||||
__git.create_abbr gcam git commit -a -m
|
||||
__git.create_abbr gcs git commit -S
|
||||
__git.create_abbr gscam git commit -S -a -m
|
||||
__git.create_abbr gcfx git commit --fixup
|
||||
__git.create_abbr gcf git config --list
|
||||
__git.create_abbr gcl git clone
|
||||
__git.create_abbr gclean git clean -di
|
||||
__git.create_abbr gclean! git clean -dfx
|
||||
__git.create_abbr gclean!! "git reset --hard; and git clean -dfx"
|
||||
__git.create_abbr gcount git shortlog -sn
|
||||
__git.create_abbr gcp git cherry-pick
|
||||
__git.create_abbr gcpa git cherry-pick --abort
|
||||
__git.create_abbr gcpc git cherry-pick --continue
|
||||
__git.create_abbr gd git diff
|
||||
__git.create_abbr gdca git diff --cached
|
||||
__git.create_abbr gds git diff --stat
|
||||
__git.create_abbr gdsc git diff --stat --cached
|
||||
__git.create_abbr gdt git diff-tree --no-commit-id --name-only -r
|
||||
__git.create_abbr gdw git diff --word-diff
|
||||
__git.create_abbr gdwc git diff --word-diff --cached
|
||||
__git.create_abbr gdto git difftool
|
||||
__git.create_abbr gdg git diff --no-ext-diff
|
||||
__git.create_abbr gignore git update-index --assume-unchanged
|
||||
__git.create_abbr gf git fetch
|
||||
__git.create_abbr gfa git fetch --all --prune
|
||||
__git.create_abbr gfm "git fetch origin (__git.default_branch) --prune; and git merge FETCH_HEAD"
|
||||
__git.create_abbr gfo git fetch origin
|
||||
__git.create_abbr gl git pull
|
||||
__git.create_abbr ggl git pull origin \(__git.current_branch\)
|
||||
__git.create_abbr gll git pull origin
|
||||
__git.create_abbr glr git pull --rebase
|
||||
__git.create_abbr glg git log --stat
|
||||
__git.create_abbr glgg git log --graph
|
||||
__git.create_abbr glgga git log --graph --decorate --all
|
||||
__git.create_abbr glo git log --oneline --decorate --color
|
||||
__git.create_abbr glog git log --oneline --decorate --color --graph
|
||||
__git.create_abbr gloga git log --oneline --decorate --color --graph --all
|
||||
__git.create_abbr glom git log --oneline --decorate --color \(__git.default_branch\)..
|
||||
__git.create_abbr glod git log --oneline --decorate --color develop..
|
||||
__git.create_abbr gloo "git log --pretty=format:'%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s' --date=short"
|
||||
__git.create_abbr gm git merge
|
||||
__git.create_abbr gmt git mergetool --no-prompt
|
||||
__git.create_abbr gmom git merge origin/\(__git.default_branch\)
|
||||
__git.create_abbr gp git push
|
||||
__git.create_abbr gp! git push --force-with-lease
|
||||
__git.create_abbr gpo git push origin
|
||||
__git.create_abbr gpo! git push --force-with-lease origin
|
||||
__git.create_abbr gpv git push --no-verify
|
||||
__git.create_abbr gpv! git push --no-verify --force-with-lease
|
||||
__git.create_abbr ggp git push origin \(__git.current_branch\)
|
||||
__git.create_abbr ggp! git push origin \(__git.current_branch\) --force-with-lease
|
||||
__git.create_abbr gpu git push origin \(__git.current_branch\) --set-upstream
|
||||
__git.create_abbr gpoat "git push origin --all; and git push origin --tags"
|
||||
__git.create_abbr ggpnp "git pull origin (__git.current_branch); and git push origin (__git.current_branch)"
|
||||
__git.create_abbr gr git remote -vv
|
||||
__git.create_abbr gra git remote add
|
||||
__git.create_abbr grb git rebase
|
||||
__git.create_abbr grba git rebase --abort
|
||||
__git.create_abbr grbc git rebase --continue
|
||||
__git.create_abbr grbi git rebase --interactive
|
||||
__git.create_abbr grbm git rebase \(__git.default_branch\)
|
||||
__git.create_abbr grbmi git rebase \(__git.default_branch\) --interactive
|
||||
__git.create_abbr grbmia git rebase \(__git.default_branch\) --interactive --autosquash
|
||||
__git.create_abbr grbom "git fetch origin (__git.default_branch); and git rebase FETCH_HEAD"
|
||||
__git.create_abbr grbomi "git fetch origin (__git.default_branch); and git rebase FETCH_HEAD --interactive"
|
||||
__git.create_abbr grbomia "git fetch origin (__git.default_branch); and git rebase FETCH_HEAD --interactive --autosquash"
|
||||
__git.create_abbr grbd git rebase develop
|
||||
__git.create_abbr grbdi git rebase develop --interactive
|
||||
__git.create_abbr grbdia git rebase develop --interactive --autosquash
|
||||
__git.create_abbr grbs git rebase --skip
|
||||
__git.create_abbr ggu git pull --rebase origin \(__git.current_branch\)
|
||||
__git.create_abbr grev git revert
|
||||
__git.create_abbr grh git reset
|
||||
__git.create_abbr grhh git reset --hard
|
||||
__git.create_abbr grhpa git reset --patch
|
||||
__git.create_abbr grm git rm
|
||||
__git.create_abbr grmc git rm --cached
|
||||
__git.create_abbr grmv git remote rename
|
||||
__git.create_abbr grpo git remote prune origin
|
||||
__git.create_abbr grrm git remote remove
|
||||
__git.create_abbr grs git restore
|
||||
__git.create_abbr grset git remote set-url
|
||||
__git.create_abbr grss git restore --source
|
||||
__git.create_abbr grst git restore --staged
|
||||
__git.create_abbr grup git remote update
|
||||
__git.create_abbr grv git remote -v
|
||||
__git.create_abbr gsh git show
|
||||
__git.create_abbr gsd git svn dcommit
|
||||
__git.create_abbr gsr git svn rebase
|
||||
__git.create_abbr gsb git status -sb
|
||||
__git.create_abbr gss git status -s
|
||||
__git.create_abbr gst git status
|
||||
__git.create_abbr gsta git stash
|
||||
__git.create_abbr gstd git stash drop
|
||||
__git.create_abbr gstl git stash list
|
||||
__git.create_abbr gstp git stash pop
|
||||
__git.create_abbr gsts git stash show --text
|
||||
__git.create_abbr gsu git submodule update
|
||||
__git.create_abbr gsur git submodule update --recursive
|
||||
__git.create_abbr gsuri git submodule update --recursive --init
|
||||
__git.create_abbr gts git tag -s
|
||||
__git.create_abbr gtv git tag | sort -V
|
||||
__git.create_abbr gsw git switch
|
||||
__git.create_abbr gswc git switch --create
|
||||
__git.create_abbr gunignore git update-index --no-assume-unchanged
|
||||
__git.create_abbr gup git pull --rebase
|
||||
__git.create_abbr gupv git pull --rebase -v
|
||||
__git.create_abbr gupa git pull --rebase --autostash
|
||||
__git.create_abbr gupav git pull --rebase --autostash -v
|
||||
__git.create_abbr gwch git whatchanged -p --abbrev-commit --pretty=medium
|
||||
|
||||
# git checkout abbreviations
|
||||
__git.create_abbr gco git checkout
|
||||
__git.create_abbr gcb git checkout -b
|
||||
__git.create_abbr gcod git checkout develop
|
||||
__git.create_abbr gcom git checkout \(__git.default_branch\)
|
||||
|
||||
# git flow abbreviations
|
||||
__git.create_abbr gfb git flow bugfix
|
||||
__git.create_abbr gff git flow feature
|
||||
__git.create_abbr gfr git flow release
|
||||
__git.create_abbr gfh git flow hotfix
|
||||
__git.create_abbr gfs git flow support
|
||||
|
||||
__git.create_abbr gfbs git flow bugfix start
|
||||
__git.create_abbr gffs git flow feature start
|
||||
__git.create_abbr gfrs git flow release start
|
||||
__git.create_abbr gfhs git flow hotfix start
|
||||
__git.create_abbr gfss git flow support start
|
||||
|
||||
__git.create_abbr gfbt git flow bugfix track
|
||||
__git.create_abbr gfft git flow feature track
|
||||
__git.create_abbr gfrt git flow release track
|
||||
__git.create_abbr gfht git flow hotfix track
|
||||
__git.create_abbr gfst git flow support track
|
||||
|
||||
__git.create_abbr gfp git flow publish
|
||||
|
||||
# git worktree abbreviations
|
||||
__git.create_abbr gwt git worktree
|
||||
__git.create_abbr gwta git worktree add
|
||||
__git.create_abbr gwtls git worktree list
|
||||
__git.create_abbr gwtlo git worktree lock
|
||||
__git.create_abbr gwtmv git worktree move
|
||||
__git.create_abbr gwtpr git worktree prune
|
||||
__git.create_abbr gwtrm git worktree remove
|
||||
__git.create_abbr gwtulo git worktree unlock
|
||||
|
||||
# GitLab push options
|
||||
__git.create_abbr gmr git push origin \(__git.current_branch\) --set-upstream -o merge_request.create
|
||||
__git.create_abbr gmwps git push origin \(__git.current_branch\) --set-upstream -o merge_request.create -o merge_request.merge_when_pipeline_succeeds
|
||||
|
||||
# Cleanup declared functions
|
||||
functions -e __git.create_abbr
|
||||
end
|
240
wsl/.config/fish/functions/fisher.fish
Normal file
240
wsl/.config/fish/functions/fisher.fish
Normal file
@ -0,0 +1,240 @@
|
||||
function fisher --argument-names cmd --description "A plugin manager for Fish"
|
||||
set --query fisher_path || set --local fisher_path $__fish_config_dir
|
||||
set --local fisher_version 4.4.5
|
||||
set --local fish_plugins $__fish_config_dir/fish_plugins
|
||||
|
||||
switch "$cmd"
|
||||
case -v --version
|
||||
echo "fisher, version $fisher_version"
|
||||
case "" -h --help
|
||||
echo "Usage: fisher install <plugins...> Install plugins"
|
||||
echo " fisher remove <plugins...> Remove installed plugins"
|
||||
echo " fisher update <plugins...> Update installed plugins"
|
||||
echo " fisher update Update all installed plugins"
|
||||
echo " fisher list [<regex>] List installed plugins matching regex"
|
||||
echo "Options:"
|
||||
echo " -v, --version Print version"
|
||||
echo " -h, --help Print this help message"
|
||||
echo "Variables:"
|
||||
echo " \$fisher_path Plugin installation path. Default: $__fish_config_dir" | string replace --regex -- $HOME \~
|
||||
case ls list
|
||||
string match --entire --regex -- "$argv[2]" $_fisher_plugins
|
||||
case install update remove
|
||||
isatty || read --local --null --array stdin && set --append argv $stdin
|
||||
|
||||
set --local install_plugins
|
||||
set --local update_plugins
|
||||
set --local remove_plugins
|
||||
set --local arg_plugins $argv[2..-1]
|
||||
set --local old_plugins $_fisher_plugins
|
||||
set --local new_plugins
|
||||
|
||||
test -e $fish_plugins && set --local file_plugins (string match --regex -- '^[^\s]+$' <$fish_plugins | string replace -- \~ ~)
|
||||
|
||||
if ! set --query argv[2]
|
||||
if test "$cmd" != update
|
||||
echo "fisher: Not enough arguments for command: \"$cmd\"" >&2 && return 1
|
||||
else if ! set --query file_plugins
|
||||
echo "fisher: \"$fish_plugins\" file not found: \"$cmd\"" >&2 && return 1
|
||||
end
|
||||
set arg_plugins $file_plugins
|
||||
end
|
||||
|
||||
for plugin in $arg_plugins
|
||||
set plugin (test -e "$plugin" && realpath $plugin || string lower -- $plugin)
|
||||
contains -- "$plugin" $new_plugins || set --append new_plugins $plugin
|
||||
end
|
||||
|
||||
if set --query argv[2]
|
||||
for plugin in $new_plugins
|
||||
if contains -- "$plugin" $old_plugins
|
||||
test "$cmd" = remove &&
|
||||
set --append remove_plugins $plugin ||
|
||||
set --append update_plugins $plugin
|
||||
else if test "$cmd" = install
|
||||
set --append install_plugins $plugin
|
||||
else
|
||||
echo "fisher: Plugin not installed: \"$plugin\"" >&2 && return 1
|
||||
end
|
||||
end
|
||||
else
|
||||
for plugin in $new_plugins
|
||||
contains -- "$plugin" $old_plugins &&
|
||||
set --append update_plugins $plugin ||
|
||||
set --append install_plugins $plugin
|
||||
end
|
||||
|
||||
for plugin in $old_plugins
|
||||
contains -- "$plugin" $new_plugins || set --append remove_plugins $plugin
|
||||
end
|
||||
end
|
||||
|
||||
set --local pid_list
|
||||
set --local source_plugins
|
||||
set --local fetch_plugins $update_plugins $install_plugins
|
||||
set --local fish_path (status fish-path)
|
||||
|
||||
echo (set_color --bold)fisher $cmd version $fisher_version(set_color normal)
|
||||
|
||||
for plugin in $fetch_plugins
|
||||
set --local source (command mktemp -d)
|
||||
set --append source_plugins $source
|
||||
|
||||
command mkdir -p $source/{completions,conf.d,themes,functions}
|
||||
|
||||
$fish_path --command "
|
||||
if test -e $plugin
|
||||
command cp -Rf $plugin/* $source
|
||||
else
|
||||
set temp (command mktemp -d)
|
||||
set repo (string split -- \@ $plugin) || set repo[2] HEAD
|
||||
|
||||
if set path (string replace --regex -- '^(https://)?gitlab.com/' '' \$repo[1])
|
||||
set name (string split -- / \$path)[-1]
|
||||
set url https://gitlab.com/\$path/-/archive/\$repo[2]/\$name-\$repo[2].tar.gz
|
||||
else
|
||||
set url https://api.github.com/repos/\$repo[1]/tarball/\$repo[2]
|
||||
end
|
||||
|
||||
echo Fetching (set_color --underline)\$url(set_color normal)
|
||||
|
||||
if command curl -q --silent -L \$url | command tar -xzC \$temp -f - 2>/dev/null
|
||||
command cp -Rf \$temp/*/* $source
|
||||
else
|
||||
echo fisher: Invalid plugin name or host unavailable: \\\"$plugin\\\" >&2
|
||||
command rm -rf $source
|
||||
end
|
||||
|
||||
command rm -rf \$temp
|
||||
end
|
||||
|
||||
set files $source/* && string match --quiet --regex -- .+\.fish\\\$ \$files
|
||||
" &
|
||||
|
||||
set --append pid_list (jobs --last --pid)
|
||||
end
|
||||
|
||||
wait $pid_list 2>/dev/null
|
||||
|
||||
for plugin in $fetch_plugins
|
||||
if set --local source $source_plugins[(contains --index -- "$plugin" $fetch_plugins)] && test ! -e $source
|
||||
if set --local index (contains --index -- "$plugin" $install_plugins)
|
||||
set --erase install_plugins[$index]
|
||||
else
|
||||
set --erase update_plugins[(contains --index -- "$plugin" $update_plugins)]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for plugin in $update_plugins $remove_plugins
|
||||
if set --local index (contains --index -- "$plugin" $_fisher_plugins)
|
||||
set --local plugin_files_var _fisher_(string escape --style=var -- $plugin)_files
|
||||
|
||||
if contains -- "$plugin" $remove_plugins
|
||||
for name in (string replace --filter --regex -- '.+/conf\.d/([^/]+)\.fish$' '$1' $$plugin_files_var)
|
||||
emit {$name}_uninstall
|
||||
end
|
||||
printf "%s\n" Removing\ (set_color red --bold)$plugin(set_color normal) " "$$plugin_files_var | string replace -- \~ ~
|
||||
set --erase _fisher_plugins[$index]
|
||||
end
|
||||
|
||||
command rm -rf (string replace -- \~ ~ $$plugin_files_var)
|
||||
|
||||
functions --erase (string replace --filter --regex -- '.+/functions/([^/]+)\.fish$' '$1' $$plugin_files_var)
|
||||
|
||||
for name in (string replace --filter --regex -- '.+/completions/([^/]+)\.fish$' '$1' $$plugin_files_var)
|
||||
complete --erase --command $name
|
||||
end
|
||||
|
||||
set --erase $plugin_files_var
|
||||
end
|
||||
end
|
||||
|
||||
if set --query update_plugins[1] || set --query install_plugins[1]
|
||||
command mkdir -p $fisher_path/{functions,themes,conf.d,completions}
|
||||
end
|
||||
|
||||
for plugin in $update_plugins $install_plugins
|
||||
set --local source $source_plugins[(contains --index -- "$plugin" $fetch_plugins)]
|
||||
set --local files $source/{functions,themes,conf.d,completions}/*
|
||||
|
||||
if set --local index (contains --index -- $plugin $install_plugins)
|
||||
set --local user_files $fisher_path/{functions,themes,conf.d,completions}/*
|
||||
set --local conflict_files
|
||||
|
||||
for file in (string replace -- $source/ $fisher_path/ $files)
|
||||
contains -- $file $user_files && set --append conflict_files $file
|
||||
end
|
||||
|
||||
if set --query conflict_files[1] && set --erase install_plugins[$index]
|
||||
echo -s "fisher: Cannot install \"$plugin\": please remove or move conflicting files first:" \n" "$conflict_files >&2
|
||||
continue
|
||||
end
|
||||
end
|
||||
|
||||
for file in (string replace -- $source/ "" $files)
|
||||
command cp -RLf $source/$file $fisher_path/$file
|
||||
end
|
||||
|
||||
set --local plugin_files_var _fisher_(string escape --style=var -- $plugin)_files
|
||||
|
||||
set --query files[1] && set --universal $plugin_files_var (string replace -- $source $fisher_path $files | string replace -- ~ \~)
|
||||
|
||||
contains -- $plugin $_fisher_plugins || set --universal --append _fisher_plugins $plugin
|
||||
contains -- $plugin $install_plugins && set --local event install || set --local event update
|
||||
|
||||
printf "%s\n" Installing\ (set_color --bold)$plugin(set_color normal) " "$$plugin_files_var | string replace -- \~ ~
|
||||
|
||||
for file in (string match --regex -- '.+/[^/]+\.fish$' $$plugin_files_var | string replace -- \~ ~)
|
||||
source $file
|
||||
if set --local name (string replace --regex -- '.+conf\.d/([^/]+)\.fish$' '$1' $file)
|
||||
emit {$name}_$event
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
command rm -rf $source_plugins
|
||||
|
||||
if set --query _fisher_plugins[1]
|
||||
set --local commit_plugins
|
||||
|
||||
for plugin in $file_plugins
|
||||
contains -- (string lower -- $plugin) (string lower -- $_fisher_plugins) && set --append commit_plugins $plugin
|
||||
end
|
||||
|
||||
for plugin in $_fisher_plugins
|
||||
contains -- (string lower -- $plugin) (string lower -- $commit_plugins) || set --append commit_plugins $plugin
|
||||
end
|
||||
|
||||
string replace --regex -- $HOME \~ $commit_plugins >$fish_plugins
|
||||
else
|
||||
set --erase _fisher_plugins
|
||||
command rm -f $fish_plugins
|
||||
end
|
||||
|
||||
set --local total (count $install_plugins) (count $update_plugins) (count $remove_plugins)
|
||||
|
||||
test "$total" != "0 0 0" && echo (string join ", " (
|
||||
test $total[1] = 0 || echo "Installed $total[1]") (
|
||||
test $total[2] = 0 || echo "Updated $total[2]") (
|
||||
test $total[3] = 0 || echo "Removed $total[3]")
|
||||
) plugin/s
|
||||
case \*
|
||||
echo "fisher: Unknown command: \"$cmd\"" >&2 && return 1
|
||||
end
|
||||
end
|
||||
|
||||
if ! set --query _fisher_upgraded_to_4_4
|
||||
set --universal _fisher_upgraded_to_4_4
|
||||
if functions --query _fisher_list
|
||||
set --query XDG_DATA_HOME[1] || set --local XDG_DATA_HOME ~/.local/share
|
||||
command rm -rf $XDG_DATA_HOME/fisher
|
||||
functions --erase _fisher_{list,plugin_parse}
|
||||
fisher update >/dev/null 2>/dev/null
|
||||
else
|
||||
for var in (set --names | string match --entire --regex '^_fisher_.+_files$')
|
||||
set $var (string replace -- ~ \~ $$var)
|
||||
end
|
||||
functions --erase _fisher_fish_postexec
|
||||
end
|
||||
end
|
5
wsl/.config/fish/functions/gbage.fish
Normal file
5
wsl/.config/fish/functions/gbage.fish
Normal file
@ -0,0 +1,5 @@
|
||||
function gbage -d "List local branches and display their age"
|
||||
git for-each-ref --sort=committerdate refs/heads/ \
|
||||
--format="%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))"
|
||||
end
|
||||
|
15
wsl/.config/fish/functions/gbda.fish
Normal file
15
wsl/.config/fish/functions/gbda.fish
Normal file
@ -0,0 +1,15 @@
|
||||
function gbda -d "Delete all branches merged in current HEAD, including squashed"
|
||||
git branch --merged | \
|
||||
# *: current branch, +: current branch on worktree.
|
||||
command grep -vE '^\*|^\+|^\s*(master|main|develop)\s*$' | \
|
||||
command xargs -r -n 1 git branch -d
|
||||
|
||||
set -l default_branch (__git.default_branch)
|
||||
git for-each-ref refs/heads/ "--format=%(refname:short)" | \
|
||||
while read branch
|
||||
set -l merge_base (git merge-base $default_branch $branch)
|
||||
if string match -q -- '-*' (git cherry $default_branch (git commit-tree (git rev-parse $branch\^{tree}) -p $merge_base -m _))
|
||||
git branch -D $branch
|
||||
end
|
||||
end
|
||||
end
|
3
wsl/.config/fish/functions/gdv.fish
Normal file
3
wsl/.config/fish/functions/gdv.fish
Normal file
@ -0,0 +1,3 @@
|
||||
function gdv -w "git diff -w" -d "Pipe `git diff` to `view` command"
|
||||
git diff -w $argv | view -
|
||||
end
|
3
wsl/.config/fish/functions/gignored.fish
Normal file
3
wsl/.config/fish/functions/gignored.fish
Normal file
@ -0,0 +1,3 @@
|
||||
function gignored -w 'grep "^[[:lower:]]"' -d "list temporarily ignored files"
|
||||
git ls-files -v | grep "^[[:lower:]]" $argv
|
||||
end
|
5
wsl/.config/fish/functions/glp.fish
Normal file
5
wsl/.config/fish/functions/glp.fish
Normal file
@ -0,0 +1,5 @@
|
||||
function glp -d "git log at requested pretty level" -a format
|
||||
set -q format[1]; and git log --pretty=$format
|
||||
end
|
||||
|
||||
complete -c glp -x -a "(complete -C 'git log --pretty=' | sed 's/^--pretty=//')"
|
11
wsl/.config/fish/functions/grename.fish
Normal file
11
wsl/.config/fish/functions/grename.fish
Normal file
@ -0,0 +1,11 @@
|
||||
function grename -d "Rename 'old' branch to 'new', including in origin remote" -a old new
|
||||
if test (count $argv) -ne 2
|
||||
echo "Usage: "(status -u)" old_branch new_branch"
|
||||
return 1
|
||||
end
|
||||
git branch -m $old $new
|
||||
git push origin :$old
|
||||
and git push --set-upstream origin $new
|
||||
end
|
||||
|
||||
complete -c grename -x -a "(complete -C 'git branch ')"
|
3
wsl/.config/fish/functions/grt.fish
Normal file
3
wsl/.config/fish/functions/grt.fish
Normal file
@ -0,0 +1,3 @@
|
||||
function grt -d "cd into the top of the current repository or submodule"
|
||||
cd (git rev-parse --show-toplevel; or echo ".")
|
||||
end
|
21
wsl/.config/fish/functions/gtest.fish
Normal file
21
wsl/.config/fish/functions/gtest.fish
Normal file
@ -0,0 +1,21 @@
|
||||
# gtest: test a command against git staged changes.
|
||||
#
|
||||
# example usage:
|
||||
# gtest make test
|
||||
function gtest -d "test command on staged changes only"
|
||||
# Stash working dir, keeping index changes.
|
||||
git stash push -q --keep-index --include-untracked; or return
|
||||
|
||||
# Run test command against index changes only.
|
||||
command $argv
|
||||
set cmdstatus $status
|
||||
|
||||
# Return working dir and index to original state.
|
||||
# Note: reset + restore is required to prevent merge conflicts
|
||||
# when popping the stash.
|
||||
git reset -q
|
||||
git restore .
|
||||
git stash pop -q --index; or return $status
|
||||
|
||||
return $cmdstatus
|
||||
end
|
3
wsl/.config/fish/functions/gtl.fish
Normal file
3
wsl/.config/fish/functions/gtl.fish
Normal file
@ -0,0 +1,3 @@
|
||||
function gtl -d "List tags matching prefix" -a prefix
|
||||
git tag --sort=-v:refname -n -l $prefix\*
|
||||
end
|
7
wsl/.config/fish/functions/gunwip.fish
Normal file
7
wsl/.config/fish/functions/gunwip.fish
Normal file
@ -0,0 +1,7 @@
|
||||
# Work In Progress (wip)
|
||||
# These features allow to pause a branch development and switch to another one
|
||||
# When you want to go back to work, just unwip it
|
||||
#
|
||||
function gunwip -d "git uncommit the work-in-progress branch"
|
||||
git log -n 1 | grep -q -c "\--wip--"; and git reset HEAD~1
|
||||
end
|
7
wsl/.config/fish/functions/gwip.fish
Normal file
7
wsl/.config/fish/functions/gwip.fish
Normal file
@ -0,0 +1,7 @@
|
||||
# Work In Progress (wip)
|
||||
# These features allow to pause a branch development and switch to another one
|
||||
# When you want to go back to work, just unwip it
|
||||
#
|
||||
function gwip -d "git commit a work-in-progress branch"
|
||||
git add -A; git rm (git ls-files --deleted) 2> /dev/null; git commit -m "--wip--" --no-verify
|
||||
end
|
Reference in New Issue
Block a user