init .config git tracking
This commit is contained in:
commit
114c330966
125 changed files with 4688 additions and 0 deletions
1
config/fish/.gitignore
vendored
Normal file
1
config/fish/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/**/fish_variables
|
||||
7
config/fish/completions/fisher.fish
Normal file
7
config/fish/completions/fisher.fish
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
complete --command fisher --exclusive --long help --description "Print help"
|
||||
complete --command fisher --exclusive --long version --description "Print version"
|
||||
complete --command fisher --exclusive --condition __fish_use_subcommand --arguments install --description "Install plugins"
|
||||
complete --command fisher --exclusive --condition __fish_use_subcommand --arguments update --description "Update installed plugins"
|
||||
complete --command fisher --exclusive --condition __fish_use_subcommand --arguments remove --description "Remove installed plugins"
|
||||
complete --command fisher --exclusive --condition __fish_use_subcommand --arguments list --description "List installed plugins matching regex"
|
||||
complete --command fisher --exclusive --condition "__fish_seen_subcommand_from update remove" --arguments "(fisher list)"
|
||||
8
config/fish/completions/fzf_configure_bindings.fish
Normal file
8
config/fish/completions/fzf_configure_bindings.fish
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
complete fzf_configure_bindings --no-files
|
||||
complete fzf_configure_bindings --long help --short h --description "Print help" --condition "not __fish_seen_argument --help -h"
|
||||
complete fzf_configure_bindings --long directory --description "Change the key binding for Search Directory" --condition "not __fish_seen_argument --directory"
|
||||
complete fzf_configure_bindings --long git_log --description "Change the key binding for Search Git Log" --condition "not __fish_seen_argument --git_log"
|
||||
complete fzf_configure_bindings --long git_status --description "Change the key binding for Search Git Status" --condition "not __fish_seen_argument --git_status"
|
||||
complete fzf_configure_bindings --long history --description "Change the key binding for Search History" --condition "not __fish_seen_argument --history"
|
||||
complete fzf_configure_bindings --long processes --description "Change the key binding for Search Processes" --condition "not __fish_seen_argument --processes"
|
||||
complete fzf_configure_bindings --long variables --description "Change the key binding for Search Variables" --condition "not __fish_seen_argument --variables"
|
||||
13
config/fish/completions/tide.fish
Normal file
13
config/fish/completions/tide.fish
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
complete tide --no-files
|
||||
|
||||
set -l subcommands bug-report configure reload
|
||||
|
||||
complete tide -x -n __fish_use_subcommand -a bug-report -d "Print info for use in bug reports"
|
||||
complete tide -x -n __fish_use_subcommand -a configure -d "Run the configuration wizard"
|
||||
complete tide -x -n __fish_use_subcommand -a reload -d "Reload tide configuration"
|
||||
|
||||
complete tide -x -n "not __fish_seen_subcommand_from $subcommands" -s h -l help -d "Print help message"
|
||||
complete tide -x -n "not __fish_seen_subcommand_from $subcommands" -s v -l version -d "Print tide version"
|
||||
|
||||
complete tide -x -n '__fish_seen_subcommand_from bug-report' -l clean -d "Run clean Fish instance and install Tide"
|
||||
complete tide -x -n '__fish_seen_subcommand_from bug-report' -l verbose -d "Print full Tide configuration"
|
||||
44
config/fish/conf.d/_tide_init.fish
Normal file
44
config/fish/conf.d/_tide_init.fish
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
function _tide_init_install --on-event _tide_init_install
|
||||
set -U VIRTUAL_ENV_DISABLE_PROMPT true
|
||||
|
||||
source (functions --details _tide_sub_configure)
|
||||
_load_config lean
|
||||
_tide_finish
|
||||
|
||||
if status is-interactive
|
||||
tide bug-report --check || sleep 4
|
||||
|
||||
if contains ilancosman/tide (string lower $_fisher_plugins)
|
||||
set_color bryellow
|
||||
echo "ilancosman/tide is a development branch. Please install from a release tag:"
|
||||
_tide_fish_colorize "fisher install ilancosman/tide@v6"
|
||||
sleep 3
|
||||
end
|
||||
|
||||
switch (read --prompt-str="Configure tide prompt? [Y/n] " | string lower)
|
||||
case y ye yes ''
|
||||
tide configure
|
||||
case '*'
|
||||
echo -s \n 'Run ' (_tide_fish_colorize "tide configure") ' to customize your prompt.'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function _tide_init_update --on-event _tide_init_update
|
||||
# Warn users who install from main branch
|
||||
if contains ilancosman/tide (string lower $_fisher_plugins)
|
||||
set_color bryellow
|
||||
echo "ilancosman/tide is a development branch. Please install from a release tag:"
|
||||
_tide_fish_colorize "fisher install ilancosman/tide@v6"
|
||||
sleep 3
|
||||
end
|
||||
|
||||
# Set (disable) the new jobs variable
|
||||
set -q tide_jobs_number_threshold || set -U tide_jobs_number_threshold 1000
|
||||
end
|
||||
|
||||
function _tide_init_uninstall --on-event _tide_init_uninstall
|
||||
set -e VIRTUAL_ENV_DISABLE_PROMPT
|
||||
set -e (set -U --names | string match --entire -r '^_?tide')
|
||||
functions --erase (functions --all | string match --entire -r '^_?tide')
|
||||
end
|
||||
27
config/fish/conf.d/fzf.fish
Normal file
27
config/fish/conf.d/fzf.fish
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# fzf.fish is only meant to be used in interactive mode. If not in interactive mode and not in CI, skip the config to speed up shell startup
|
||||
if not status is-interactive && test "$CI" != true
|
||||
exit
|
||||
end
|
||||
|
||||
# Because of scoping rules, to capture the shell variables exactly as they are, we must read
|
||||
# them before even executing _fzf_search_variables. We use psub to store the
|
||||
# variables' info in temporary files and pass in the filenames as arguments.
|
||||
# This variable is global so that it can be referenced by fzf_configure_bindings and in tests
|
||||
set --global _fzf_search_vars_command '_fzf_search_variables (set --show | psub) (set --names | psub)'
|
||||
|
||||
# Install the default bindings, which are mnemonic and minimally conflict with fish's preset bindings
|
||||
fzf_configure_bindings
|
||||
|
||||
# Doesn't erase autoloaded _fzf_* functions because they are not easily accessible once key bindings are erased
|
||||
function _fzf_uninstall --on-event fzf_uninstall
|
||||
_fzf_uninstall_bindings
|
||||
|
||||
set --erase _fzf_search_vars_command
|
||||
functions --erase _fzf_uninstall _fzf_migration_message _fzf_uninstall_bindings fzf_configure_bindings
|
||||
complete --erase fzf_configure_bindings
|
||||
|
||||
set_color cyan
|
||||
echo "fzf.fish uninstalled."
|
||||
echo "You may need to manually remove fzf_configure_bindings from your config.fish if you were using custom key bindings."
|
||||
set_color normal
|
||||
end
|
||||
10
config/fish/conf.d/git.fish
Normal file
10
config/fish/conf.d/git.fish
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# Remove legacy hooks to prevent errors when upgrading.
|
||||
# This can be removed when we cleanup other universal abbr code.
|
||||
functions -e _git_install _git_update _git_uninstall
|
||||
|
||||
# fisher initialization, protected as omf also tries to run it.
|
||||
set -q fisher_path; or set -l fisher_path $__fish_config_dir
|
||||
if test -f $fisher_path/functions/__git.init.fish
|
||||
source $fisher_path/functions/__git.init.fish
|
||||
__git.init
|
||||
end
|
||||
10
config/fish/config.fish
Normal file
10
config/fish/config.fish
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
if status is-interactive
|
||||
abbr -a reboot 'loginctl reboot'
|
||||
abbr -a shutdown 'loginctl poweroff'
|
||||
abbr -a esync 'sudo emerge --sync'
|
||||
abbr -a enews 'eselect news read'
|
||||
abbr -a sysupdate 'sudo emerge --update --newuse --deep @world'
|
||||
alias ls 'lsd'
|
||||
alias cat 'bat'
|
||||
set -U fish_greeting "$(fortune -s -o)"
|
||||
end
|
||||
4
config/fish/fish_plugins
Normal file
4
config/fish/fish_plugins
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
jorgebucaran/fisher
|
||||
jhillyerd/plugin-git
|
||||
patrickf1/fzf.fish
|
||||
ilancosman/tide@v6
|
||||
3
config/fish/functions/__git.branch_has_wip.fish
Normal file
3
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
config/fish/functions/__git.current_branch.fish
Normal file
6
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
config/fish/functions/__git.default_branch.fish
Normal file
11
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
|
||||
12
config/fish/functions/__git.delete_branches.fish
Normal file
12
config/fish/functions/__git.delete_branches.fish
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function __git.delete_branches -d "Delete multiple branches"
|
||||
argparse f/force -- $argv
|
||||
|
||||
if set -ql _flag_force
|
||||
set -f delete_flag -D
|
||||
else
|
||||
set -f delete_flag -d
|
||||
end
|
||||
for branch in $argv
|
||||
git branch $delete_flag $branch
|
||||
end
|
||||
end
|
||||
7
config/fish/functions/__git.destroy.fish
Normal file
7
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
|
||||
8
config/fish/functions/__git.develop_branch.fish
Normal file
8
config/fish/functions/__git.develop_branch.fish
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
function __git.develop_branch -d "Use develop if it exists. Falls back to dev"
|
||||
command git rev-parse --git-dir &>/dev/null; or return
|
||||
if command git show-ref -q --verify refs/heads/develop
|
||||
echo develop
|
||||
else
|
||||
echo dev
|
||||
end
|
||||
end
|
||||
210
config/fish/functions/__git.init.fish
Normal file
210
config/fish/functions/__git.init.fish
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
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 gma git merge --abort
|
||||
__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 gpr git pull --rebase
|
||||
__git.create_abbr gupv git pull --rebase -v
|
||||
__git.create_abbr gprv git pull --rebase -v
|
||||
__git.create_abbr gupa git pull --rebase --autostash
|
||||
__git.create_abbr gpra git pull --rebase --autostash
|
||||
__git.create_abbr gupav git pull --rebase --autostash -v
|
||||
__git.create_abbr gprav git pull --rebase --autostash -v
|
||||
__git.create_abbr gprom git pull --rebase origin \(__git.default_branch\)
|
||||
__git.create_abbr gpromi git pull --rebase=interactive origin \(__git.default_branch\)
|
||||
__git.create_abbr gprum git pull --rebase upstream \(__git.default_branch\)
|
||||
__git.create_abbr gprumi git pull --rebase=interactive upstream \(__git.default_branch\)
|
||||
__git.create_abbr gwch git log -p --abbrev-commit --pretty=medium --raw --no-merges
|
||||
|
||||
# git checkout abbreviations
|
||||
__git.create_abbr gco git checkout
|
||||
__git.create_abbr gcb git checkout -b
|
||||
__git.create_abbr gcod git checkout \(__git.develop_branch\)
|
||||
__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
|
||||
44
config/fish/functions/_fzf_configure_bindings_help.fish
Normal file
44
config/fish/functions/_fzf_configure_bindings_help.fish
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
function _fzf_configure_bindings_help --description "Prints the help message for fzf_configure_bindings."
|
||||
echo "\
|
||||
USAGE:
|
||||
fzf_configure_bindings [--COMMAND=[KEY_SEQUENCE]...]
|
||||
|
||||
DESCRIPTION
|
||||
fzf_configure_bindings installs key bindings for fzf.fish's commands and erases any bindings it
|
||||
previously installed. It installs bindings for both default and insert modes. fzf.fish executes
|
||||
it without options on fish startup to install the out-of-the-box key bindings.
|
||||
|
||||
By default, commands are bound to a mnemonic key sequence, shown below. Each command's binding
|
||||
can be configured using a namesake corresponding option:
|
||||
COMMAND | DEFAULT KEY SEQUENCE | CORRESPONDING OPTION
|
||||
Search Directory | Ctrl+Alt+F (F for file) | --directory
|
||||
Search Git Log | Ctrl+Alt+L (L for log) | --git_log
|
||||
Search Git Status | Ctrl+Alt+S (S for status) | --git_status
|
||||
Search History | Ctrl+R (R for reverse) | --history
|
||||
Search Processes | Ctrl+Alt+P (P for process) | --processes
|
||||
Search Variables | Ctrl+V (V for variable) | --variables
|
||||
Override a command's binding by specifying its corresponding option with the desired key
|
||||
sequence using fish's key name syntax (e.g. ctrl-f, ctrl-alt-v). Disable a command's binding
|
||||
by specifying its corresponding option with no value.
|
||||
|
||||
Because fzf_configure_bindings erases bindings it previously installed, it can be cleanly
|
||||
executed multiple times. Once the desired fzf_configure_bindings command has been found, add it
|
||||
to your config.fish in order to persist the customized bindings.
|
||||
|
||||
In terms of validation, fzf_configure_bindings fails if passed unknown options. It expects an
|
||||
equals sign between an option's name and value. However, it does not validate key sequences.
|
||||
|
||||
Pass -h or --help to print this help message and exit.
|
||||
|
||||
EXAMPLES
|
||||
Default bindings but bind Search Directory to Ctrl+F and Search Variables to Ctrl+Alt+V
|
||||
\$ fzf_configure_bindings --directory=ctrl-f --variables=ctrl-alt-v
|
||||
Default bindings but disable Search History
|
||||
\$ fzf_configure_bindings --history=
|
||||
An agglomeration of different options
|
||||
\$ fzf_configure_bindings --git_status=ctrl-g --history=ctrl-h --variables= --processes=
|
||||
|
||||
SEE Also
|
||||
To learn more about fish key bindings, see bind(1) and fish_key_reader(1).
|
||||
"
|
||||
end
|
||||
13
config/fish/functions/_fzf_extract_var_info.fish
Normal file
13
config/fish/functions/_fzf_extract_var_info.fish
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# helper function for _fzf_search_variables
|
||||
function _fzf_extract_var_info --argument-names variable_name set_show_output --description "Extract and reformat lines pertaining to \$variable_name from \$set_show_output."
|
||||
# Extract only the lines about the variable, all of which begin with either
|
||||
# $variable_name: ...or... $variable_name[
|
||||
string match --regex "^\\\$$variable_name(?::|\[).*" <$set_show_output |
|
||||
# Strip the variable name prefix, including ": " for scope info lines
|
||||
string replace --regex "^\\\$$variable_name(?:: )?" '' |
|
||||
# Distill the lines of values, replacing...
|
||||
# [1]: |value|
|
||||
# ...with...
|
||||
# [1] value
|
||||
string replace --regex ": \|(.*)\|" ' $1'
|
||||
end
|
||||
49
config/fish/functions/_fzf_preview_changed_file.fish
Normal file
49
config/fish/functions/_fzf_preview_changed_file.fish
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# helper for _fzf_search_git_status
|
||||
# arg should be a line from git status --short, e.g.
|
||||
# MM functions/_fzf_preview_changed_file.fish
|
||||
# D README.md
|
||||
# R LICENSE -> "New License"
|
||||
function _fzf_preview_changed_file --argument-names path_status --description "Show the git diff of the given file."
|
||||
# remove quotes because they'll be interpreted literally by git diff
|
||||
# no need to requote when referencing $path because fish does not perform word splitting
|
||||
# https://fishshell.com/docs/current/fish_for_bash_users.html
|
||||
set -f path (string unescape (string sub --start 4 $path_status))
|
||||
# first letter of short format shows index, second letter shows working tree
|
||||
# https://git-scm.com/docs/git-status/2.35.0#_short_format
|
||||
set -f index_status (string sub --length 1 $path_status)
|
||||
set -f working_tree_status (string sub --start 2 --length 1 $path_status)
|
||||
|
||||
set -f diff_opts --color=always
|
||||
|
||||
if test $index_status = '?'
|
||||
_fzf_report_diff_type Untracked
|
||||
_fzf_preview_file $path
|
||||
else if contains {$index_status}$working_tree_status DD AU UD UA DU AA UU
|
||||
# Unmerged statuses taken directly from git status help's short format table
|
||||
# Unmerged statuses are mutually exclusive with other statuses, so if we see
|
||||
# these, then safe to assume the path is unmerged
|
||||
_fzf_report_diff_type Unmerged
|
||||
git diff $diff_opts -- $path
|
||||
else
|
||||
if test $index_status != ' '
|
||||
_fzf_report_diff_type Staged
|
||||
|
||||
# renames are only detected in the index, never working tree, so only need to test for it here
|
||||
# https://stackoverflow.com/questions/73954214
|
||||
if test $index_status = R
|
||||
# diff the post-rename path with the original path, otherwise the diff will show the entire file as being added
|
||||
set -f orig_and_new_path (string split --max 1 -- ' -> ' $path)
|
||||
git diff --staged $diff_opts -- $orig_and_new_path[1] $orig_and_new_path[2]
|
||||
# path currently has the form of "original -> current", so we need to correct it before it's used below
|
||||
set path $orig_and_new_path[2]
|
||||
else
|
||||
git diff --staged $diff_opts -- $path
|
||||
end
|
||||
end
|
||||
|
||||
if test $working_tree_status != ' '
|
||||
_fzf_report_diff_type Unstaged
|
||||
git diff $diff_opts -- $path
|
||||
end
|
||||
end
|
||||
end
|
||||
43
config/fish/functions/_fzf_preview_file.fish
Normal file
43
config/fish/functions/_fzf_preview_file.fish
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# helper function for _fzf_search_directory and _fzf_search_git_status
|
||||
function _fzf_preview_file --description "Print a preview for the given file based on its file type."
|
||||
# because there's no way to guarantee that _fzf_search_directory passes the path to _fzf_preview_file
|
||||
# as one argument, we collect all the arguments into one single variable and treat that as the path
|
||||
set -f file_path $argv
|
||||
|
||||
if test -L "$file_path" # symlink
|
||||
# notify user and recurse on the target of the symlink, which can be any of these file types
|
||||
set -l target_path (realpath "$file_path")
|
||||
|
||||
set_color yellow
|
||||
echo "'$file_path' is a symlink to '$target_path'."
|
||||
set_color normal
|
||||
|
||||
_fzf_preview_file "$target_path"
|
||||
else if test -f "$file_path" # regular file
|
||||
if set --query fzf_preview_file_cmd
|
||||
# need to escape quotes to make sure eval receives file_path as a single arg
|
||||
eval "$fzf_preview_file_cmd '$file_path'"
|
||||
else
|
||||
bat --style=numbers --color=always "$file_path"
|
||||
end
|
||||
else if test -d "$file_path" # directory
|
||||
if set --query fzf_preview_dir_cmd
|
||||
# see above
|
||||
eval "$fzf_preview_dir_cmd '$file_path'"
|
||||
else
|
||||
# -A list hidden files as well, except for . and ..
|
||||
# -F helps classify files by appending symbols after the file name
|
||||
command ls -A -F "$file_path"
|
||||
end
|
||||
else if test -c "$file_path"
|
||||
_fzf_report_file_type "$file_path" "character device file"
|
||||
else if test -b "$file_path"
|
||||
_fzf_report_file_type "$file_path" "block device file"
|
||||
else if test -S "$file_path"
|
||||
_fzf_report_file_type "$file_path" socket
|
||||
else if test -p "$file_path"
|
||||
_fzf_report_file_type "$file_path" "named pipe"
|
||||
else
|
||||
echo "$file_path doesn't exist." >&2
|
||||
end
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue