Get rid of fzf cause we're going back to emacs
This commit is contained in:
parent
83f238cf47
commit
bea678c2ec
@ -1,7 +0,0 @@
|
||||
complete fzf_configure_bindings --no-files
|
||||
complete fzf_configure_bindings --long help --short h --description "Print help"
|
||||
complete fzf_configure_bindings --long directory --description "Change the key binding for searching directory"
|
||||
complete fzf_configure_bindings --long git_log --description "Change the key binding for searching git log"
|
||||
complete fzf_configure_bindings --long git_status --description "Change the key binding for searching git status"
|
||||
complete fzf_configure_bindings --long history --description "Change the key binding for searching history"
|
||||
complete fzf_configure_bindings --long variables --description "Change the key binding for searching variables"
|
@ -1,543 +0,0 @@
|
||||
# MIT (c) Chris Apple
|
||||
|
||||
function forgit::warn
|
||||
printf "%b[Warn]%b %s\n" '\e[0;33m' '\e[0m' "$argv" >&2;
|
||||
end
|
||||
|
||||
function forgit::info
|
||||
printf "%b[Info]%b %s\n" '\e[0;32m' '\e[0m' "$argv" >&2;
|
||||
end
|
||||
|
||||
function forgit::inside_work_tree
|
||||
git rev-parse --is-inside-work-tree >/dev/null;
|
||||
end
|
||||
|
||||
set -g forgit_pager "$FORGIT_PAGER"
|
||||
set -g forgit_show_pager "$FORGIT_SHOW_PAGER"
|
||||
set -g forgit_diff_pager "$FORGIT_DIFF_PAGER"
|
||||
set -g forgit_ignore_pager "$FORGIT_IGNORE_PAGER"
|
||||
set -g forgit_log_format "$FORGIT_LOG_FORMAT"
|
||||
|
||||
test -z "$forgit_pager"; and set -g forgit_pager (git config core.pager || echo 'cat')
|
||||
test -z "$forgit_show_pager"; and set -g forgit_show_pager (git config pager.show || echo "$forgit_pager")
|
||||
test -z "$forgit_diff_pager"; and set -g forgit_diff_pager (git config pager.diff || echo "$forgit_pager")
|
||||
test -z "$forgit_ignore_pager"; and set -g forgit_ignore_pager (type -q bat >/dev/null 2>&1 && echo 'bat -l gitignore --color=always' || echo 'cat')
|
||||
test -z "$forgit_log_format"; and set -g forgit_log_format "-%C(auto)%h%d %s %C(black)%C(bold)%cr%Creset"
|
||||
|
||||
# https://github.com/wfxr/emoji-cli
|
||||
type -q emojify >/dev/null 2>&1 && set -g forgit_emojify '|emojify'
|
||||
|
||||
# git commit viewer
|
||||
function forgit::log -d "git commit viewer"
|
||||
forgit::inside_work_tree || return 1
|
||||
|
||||
set files (echo $argv | sed -nE 's/.* -- (.*)/\1/p')
|
||||
set cmd "echo {} |grep -Eo '[a-f0-9]+' |head -1 |xargs -I% git show --color=always % -- $files | $forgit_show_pager"
|
||||
|
||||
if test -n "$FORGIT_COPY_CMD"
|
||||
set copy_cmd $FORGIT_COPY_CMD
|
||||
else
|
||||
set copy_cmd pbcopy
|
||||
end
|
||||
|
||||
set opts "
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
+s +m --tiebreak=index
|
||||
--bind=\"enter:execute($cmd |env LESS='-r' less)\"
|
||||
--bind=\"ctrl-y:execute-silent(echo {} |grep -Eo '[a-f0-9]+' | head -1 | tr -d '[:space:]' |$copy_cmd)\"
|
||||
$FORGIT_LOG_FZF_OPTS
|
||||
"
|
||||
|
||||
if set -q FORGIT_LOG_GRAPH_ENABLE
|
||||
set graph "--graph"
|
||||
else
|
||||
set graph ""
|
||||
end
|
||||
|
||||
eval "git log $graph --color=always --format='$forgit_log_format' $argv $forgit_emojify" |
|
||||
env FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd"
|
||||
end
|
||||
|
||||
## git diff viewer
|
||||
function forgit::diff -d "git diff viewer"
|
||||
forgit::inside_work_tree || return 1
|
||||
if count $argv > /dev/null
|
||||
if git rev-parse "$argv[1]" > /dev/null 2>&1
|
||||
set commit "$argv[1]" && set files "$argv[2..]"
|
||||
else
|
||||
set files "$argv"
|
||||
end
|
||||
end
|
||||
|
||||
set repo (git rev-parse --show-toplevel)
|
||||
set cmd "echo {} |sed 's/.*] //' | xargs -I% git diff --color=always $commit -- '$repo/%' | $forgit_diff_pager"
|
||||
set opts "
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
+m -0 --bind=\"enter:execute($cmd |env LESS='-r' less)\"
|
||||
$FORGIT_DIFF_FZF_OPTS
|
||||
"
|
||||
|
||||
eval "git diff --name-only $commit -- $files*| sed -E 's/^(.)[[:space:]]+(.*)\$/[\1] \2/'" | env FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd"
|
||||
end
|
||||
|
||||
# git add selector
|
||||
function forgit::add -d "git add selector"
|
||||
forgit::inside_work_tree || return 1
|
||||
# Add files if passed as arguments
|
||||
count $argv >/dev/null && git add "$argv" && git status --short && return
|
||||
|
||||
set changed (git config --get-color color.status.changed red)
|
||||
set unmerged (git config --get-color color.status.unmerged red)
|
||||
set untracked (git config --get-color color.status.untracked red)
|
||||
|
||||
set extract_file "
|
||||
sed 's/^[[:space:]]*//' | # remove leading whitespace
|
||||
cut -d ' ' -f 2- | # cut the line after the M or ??, this leaves just the filename
|
||||
sed 's/.* -> //' | # for rename case
|
||||
sed -e 's/^\\\"//' -e 's/\\\"\$//' # removes surrounding quotes
|
||||
"
|
||||
set preview "
|
||||
set file (echo {} | $extract_file)
|
||||
# exit
|
||||
if test (git status -s -- \$file | grep '^??') # diff with /dev/null for untracked files
|
||||
git diff --color=always --no-index -- /dev/null \$file | $forgit_diff_pager | sed '2 s/added:/untracked:/'
|
||||
else
|
||||
git diff --color=always -- \$file | $forgit_diff_pager
|
||||
end
|
||||
"
|
||||
set opts "
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
-0 -m --nth 2..,..
|
||||
$FORGIT_ADD_FZF_OPTS
|
||||
"
|
||||
set files (git -c color.status=always -c status.relativePaths=true status -su |
|
||||
grep -F -e "$changed" -e "$unmerged" -e "$untracked" |
|
||||
sed -E 's/^(..[^[:space:]]*)[[:space:]]+(.*)\$/[\1] \2/' | # deal with white spaces internal to fname
|
||||
env FZF_DEFAULT_OPTS="$opts" fzf --preview="$preview" |
|
||||
sh -c "$extract_file") # for rename case
|
||||
|
||||
if test -n "$files"
|
||||
for file in $files
|
||||
echo $file | tr '\n' '\0' | xargs -I{} -0 git add {}
|
||||
end
|
||||
git status --short
|
||||
return
|
||||
end
|
||||
echo 'Nothing to add.'
|
||||
end
|
||||
|
||||
## git reset HEAD (unstage) selector
|
||||
function forgit::reset::head -d "git reset HEAD (unstage) selector"
|
||||
forgit::inside_work_tree || return 1
|
||||
set cmd "git diff --cached --color=always -- {} | $forgit_diff_pager"
|
||||
set opts "
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
-m -0
|
||||
$FORGIT_RESET_HEAD_FZF_OPTS
|
||||
"
|
||||
set files (git diff --cached --name-only --relative | env FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd")
|
||||
if test -n "$files"
|
||||
for file in $files
|
||||
echo $file | tr '\n' '\0' |xargs -I{} -0 git reset -q HEAD {}
|
||||
end
|
||||
git status --short
|
||||
return
|
||||
end
|
||||
echo 'Nothing to unstage.'
|
||||
end
|
||||
|
||||
# git checkout-restore selector
|
||||
function forgit::checkout::file -d "git checkout-file selector" --argument-names 'file_name'
|
||||
forgit::inside_work_tree || return 1
|
||||
|
||||
if test -n "$file_name"
|
||||
git checkout -- "$file_name"
|
||||
set checkout_status $status
|
||||
git status --short
|
||||
return $checkout_status
|
||||
end
|
||||
|
||||
|
||||
set cmd "git diff --color=always -- {} | $forgit_diff_pager"
|
||||
set opts "
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
-m -0
|
||||
$FORGIT_CHECKOUT_FILE_FZF_OPTS
|
||||
"
|
||||
set git_rev_parse (git rev-parse --show-toplevel)
|
||||
set files (git ls-files --modified "$git_rev_parse" | env FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd")
|
||||
|
||||
if test -n "$files"
|
||||
for file in $files
|
||||
echo $file | tr '\n' '\0' | xargs -I{} -0 git checkout -q {}
|
||||
end
|
||||
git status --short
|
||||
return
|
||||
end
|
||||
echo 'Nothing to restore.'
|
||||
end
|
||||
|
||||
function forgit::checkout::commit -d "git checkout commit selector" --argument-names 'commit_id'
|
||||
forgit::inside_work_tree || return 1
|
||||
|
||||
if test -n "$commit_id"
|
||||
git checkout "$commit_id"
|
||||
set checkout_status $status
|
||||
git status --short
|
||||
return $checkout_status
|
||||
end
|
||||
|
||||
if test -n "$FORGIT_COPY_CMD"
|
||||
set copy_cmd $FORGIT_COPY_CMD
|
||||
else
|
||||
set copy_cmd pbcopy
|
||||
end
|
||||
|
||||
|
||||
set cmd "echo {} |grep -Eo '[a-f0-9]+' |head -1 |xargs -I% git show --color=always % | $forgit_show_pager"
|
||||
set opts "
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
+s +m --tiebreak=index
|
||||
--bind=\"ctrl-y:execute-silent(echo {} |grep -Eo '[a-f0-9]+' | head -1 | tr -d '[:space:]' | $copy_cmd)\"
|
||||
$FORGIT_COMMIT_FZF_OPTS
|
||||
"
|
||||
|
||||
if set -q FORGIT_LOG_GRAPH_ENABLE
|
||||
set graph "--graph"
|
||||
else
|
||||
set graph ""
|
||||
end
|
||||
|
||||
eval "git log $graph --color=always --format='$forgit_log_format' $forgit_emojify" |
|
||||
FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd" |grep -Eo '[a-f0-9]+' |head -1 |xargs -I% git checkout % --
|
||||
end
|
||||
|
||||
|
||||
function forgit::checkout::branch -d "git checkout branch selector" --argument-names 'input_branch_name'
|
||||
forgit::inside_work_tree || return 1
|
||||
|
||||
if test -n "$input_branch_name"
|
||||
git checkout -b "$input_branch_name"
|
||||
set checkout_status $status
|
||||
git status --short
|
||||
return $checkout_status
|
||||
end
|
||||
|
||||
set cmd "git branch --color=always --verbose --all | sort -k1.1,1.1 -r"
|
||||
set preview "git log {1} --graph --pretty=format:'$forgit_log_format' --color=always --abbrev-commit --date=relative"
|
||||
|
||||
set opts "
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
+s +m --tiebreak=index --header-lines=1
|
||||
$FORGIT_CHECKOUT_BRANCH_FZF_OPTS
|
||||
"
|
||||
|
||||
set branch (eval "$cmd" | FZF_DEFAULT_OPTS="$opts" fzf --preview="$preview" | awk '{print $1}')
|
||||
|
||||
test -z "$branch" && return 1
|
||||
|
||||
# track the remote branch if possible
|
||||
if not git checkout --track "$branch" 2>/dev/null
|
||||
git checkout "$branch"
|
||||
end
|
||||
end
|
||||
|
||||
# git stash viewer
|
||||
function forgit::stash::show -d "git stash viewer"
|
||||
forgit::inside_work_tree || return 1
|
||||
set cmd "echo {} |cut -d: -f1 |xargs -I% git stash show --color=always --ext-diff % |$forgit_diff_pager"
|
||||
set opts "
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
+s +m -0 --tiebreak=index --bind=\"enter:execute($cmd |env LESS='-r' less)\"
|
||||
$FORGIT_STASH_FZF_OPTS
|
||||
"
|
||||
git stash list | env FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd"
|
||||
end
|
||||
|
||||
# git clean selector
|
||||
function forgit::clean -d "git clean selector"
|
||||
forgit::inside_work_tree || return 1
|
||||
|
||||
set opts "
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
-m -0
|
||||
$FORGIT_CLEAN_FZF_OPTS
|
||||
"
|
||||
|
||||
set files (git clean -xdffn $argv| awk '{print $3}'| env FZF_DEFAULT_OPTS="$opts" fzf |sed 's#/$##')
|
||||
|
||||
if test -n "$files"
|
||||
for file in $files
|
||||
echo $file | tr '\n' '\0'| xargs -0 -I{} git clean -xdff {}
|
||||
end
|
||||
git status --short
|
||||
return
|
||||
end
|
||||
echo 'Nothing to clean.'
|
||||
end
|
||||
|
||||
function forgit::cherry::pick -d "git cherry-picking" --argument-names 'target'
|
||||
forgit::inside_work_tree || return 1
|
||||
set base (git branch --show-current)
|
||||
if test -z "$target"
|
||||
echo "Please specify target branch"
|
||||
return 1
|
||||
end
|
||||
set preview "echo {1} | xargs -I% git show --color=always % | $forgit_show_pager"
|
||||
set opts "
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
-m -0
|
||||
"
|
||||
echo $base
|
||||
echo $target
|
||||
git cherry "$base" "$target" --abbrev -v | cut -d ' ' -f2- |
|
||||
env FZF_DEFAULT_OPTS="$opts" fzf --preview="$preview" | cut -d' ' -f1 |
|
||||
xargs -I% git cherry-pick %
|
||||
end
|
||||
|
||||
function forgit::fixup -d "git fixup"
|
||||
forgit::inside_work_tree || return 1
|
||||
git diff --cached --quiet && echo 'Nothing to fixup: there are no staged changes.' && return 1
|
||||
|
||||
if set -q FORGIT_LOG_GRAPH_ENABLE
|
||||
set graph "--graph"
|
||||
else
|
||||
set graph ""
|
||||
end
|
||||
|
||||
set cmd "git log $graph --color=always --format='$forgit_log_format' $argv $forgit_emojify"
|
||||
set files (echo $argv | sed -nE 's/.* -- (.*)/\1/p')
|
||||
set preview "echo {} |grep -Eo '[a-f0-9]+' |head -1 |xargs -I% git show --color=always % -- $files | $forgit_show_pager"
|
||||
|
||||
if test -n "$FORGIT_COPY_CMD"
|
||||
set copy_cmd $FORGIT_COPY_CMD
|
||||
else
|
||||
set copy_cmd pbcopy
|
||||
end
|
||||
|
||||
set opts "
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
+s +m --tiebreak=index
|
||||
--bind=\"ctrl-y:execute-silent(echo {} |grep -Eo '[a-f0-9]+' | head -1 | tr -d '[:space:]' |$copy_cmd)\"
|
||||
$FORGIT_FIXUP_FZF_OPTS
|
||||
"
|
||||
|
||||
set target_commit (eval "$cmd" | FZF_DEFAULT_OPTS="$opts" fzf --preview="$preview" | grep -Eo '[a-f0-9]+' | head -1)
|
||||
|
||||
if test -n "$target_commit" && git commit --fixup "$target_commit"
|
||||
# "$target_commit~" is invalid when the commit is the first commit, but we can use "--root" instead
|
||||
set prev_commit "$target_commit~"
|
||||
if test "(git rev-parse '$target_commit')" = "(git rev-list --max-parents=0 HEAD)"
|
||||
set prev_commit "--root"
|
||||
end
|
||||
|
||||
GIT_SEQUENCE_EDITOR=: git rebase --autostash -i --autosquash "$prev_commit"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function forgit::rebase -d "git rebase"
|
||||
forgit::inside_work_tree || return 1
|
||||
|
||||
if set -q FORGIT_LOG_GRAPH_ENABLE
|
||||
set graph "--graph"
|
||||
else
|
||||
set graph ""
|
||||
end
|
||||
set cmd "git log $graph --color=always --format='$forgit_log_format' $argv $forgit_emojify"
|
||||
|
||||
set files (echo $argv | sed -nE 's/.* -- (.*)/\1/p')
|
||||
set preview "echo {} |grep -Eo '[a-f0-9]+' |head -1 |xargs -I% git show --color=always % -- $files | $forgit_show_pager"
|
||||
|
||||
if test -n "$FORGIT_COPY_CMD"
|
||||
set copy_cmd $FORGIT_COPY_CMD
|
||||
else
|
||||
set copy_cmd pbcopy
|
||||
end
|
||||
|
||||
set opts "
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
+s +m --tiebreak=index
|
||||
--bind=\"ctrl-y:execute-silent(echo {} |grep -Eo '[a-f0-9]+' | head -1 | tr -d '[:space:]' |$copy_cmd)\"
|
||||
$FORGIT_REBASE_FZF_OPTS
|
||||
"
|
||||
set commit (eval "$cmd" | FZF_DEFAULT_OPTS="$opts" fzf --preview="$preview" |
|
||||
grep -Eo '[a-f0-9]+' | head -1)
|
||||
|
||||
if test $commit
|
||||
git rebase -i "$commit"
|
||||
end
|
||||
end
|
||||
|
||||
# git ignore generator
|
||||
if test -z "$FORGIT_GI_REPO_REMOTE"
|
||||
set -g FORGIT_GI_REPO_REMOTE https://github.com/dvcs/gitignore
|
||||
end
|
||||
|
||||
if test -z "$FORGIT_GI_REPO_LOCAL"
|
||||
if test -z "XDG_CACHE_HOME"
|
||||
set -g FORGIT_GI_REPO_LOCAL $XDG_CACHE_HOME/forgit/gi/repos/dvcs/gitignore
|
||||
else
|
||||
set -g FORGIT_GI_REPO_LOCAL $HOME/.cache/forgit/gi/repos/dvcs/gitignore
|
||||
end
|
||||
end
|
||||
|
||||
if test -z "$FORGIT_GI_TEMPLATES"
|
||||
set -g FORGIT_GI_TEMPLATES $FORGIT_GI_REPO_LOCAL/templates
|
||||
end
|
||||
|
||||
function forgit::ignore -d "git ignore generator"
|
||||
if not test -d "$FORGIT_GI_REPO_LOCAL"
|
||||
forgit::ignore::update
|
||||
end
|
||||
|
||||
set cmd "$forgit_ignore_pager $FORGIT_GI_TEMPLATES/{2}{,.gitignore} 2>/dev/null"
|
||||
set opts "
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
-m --preview-window='right:70%'
|
||||
$FORGIT_IGNORE_FZF_OPTS
|
||||
"
|
||||
set IFS '\n'
|
||||
|
||||
set args $argv
|
||||
if not count $argv > /dev/null
|
||||
set args (forgit::ignore::list | nl -nrn -w4 -s' ' |
|
||||
env FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd" |awk '{print $2}')
|
||||
end
|
||||
|
||||
if not count $args > /dev/null
|
||||
return 1
|
||||
end
|
||||
|
||||
forgit::ignore::get $args
|
||||
end
|
||||
|
||||
function forgit::ignore::update
|
||||
if test -d "$FORGIT_GI_REPO_LOCAL"
|
||||
forgit::info 'Updating gitignore repo...'
|
||||
set pull_result (git -C "$FORGIT_GI_REPO_LOCAL" pull --no-rebase --ff)
|
||||
test -n "$pull_result" || return 1
|
||||
else
|
||||
forgit::info 'Initializing gitignore repo...'
|
||||
git clone --depth=1 "$FORGIT_GI_REPO_REMOTE" "$FORGIT_GI_REPO_LOCAL"
|
||||
end
|
||||
end
|
||||
|
||||
function forgit::ignore::get
|
||||
for item in $argv
|
||||
set filename (find -L "$FORGIT_GI_TEMPLATES" -type f \( -iname "$item.gitignore" -o -iname "$item}" \) -print -quit)
|
||||
if test -n "$filename"
|
||||
set header $filename && set header (echo $filename | sed 's/.*\.//')
|
||||
echo "### $header" && cat "$filename" && echo
|
||||
else
|
||||
forgit::warn "No gitignore template found for '$item'." && continue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function forgit::ignore::list
|
||||
find "$FORGIT_GI_TEMPLATES" -print |sed -e 's#.gitignore$##' -e 's#.*/##' | sort -fu
|
||||
end
|
||||
|
||||
function forgit::ignore::clean
|
||||
setopt localoptions rmstarsilent
|
||||
[[ -d "$FORGIT_GI_REPO_LOCAL" ]] && rm -rf "$FORGIT_GI_REPO_LOCAL"
|
||||
end
|
||||
|
||||
set -g FORGIT_FZF_DEFAULT_OPTS "
|
||||
$FZF_DEFAULT_OPTS
|
||||
--ansi
|
||||
--height='80%'
|
||||
--bind='alt-k:preview-up,alt-p:preview-up'
|
||||
--bind='alt-j:preview-down,alt-n:preview-down'
|
||||
--bind='ctrl-r:toggle-all'
|
||||
--bind='ctrl-s:toggle-sort'
|
||||
--bind='?:toggle-preview'
|
||||
--bind='alt-w:toggle-preview-wrap'
|
||||
--preview-window='right:60%'
|
||||
+1
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
"
|
||||
|
||||
# register aliases
|
||||
if test -z "$FORGIT_NO_ALIASES"
|
||||
if test -n "$forgit_add"
|
||||
alias $forgit_add 'forgit::add'
|
||||
else
|
||||
alias ga 'forgit::add'
|
||||
end
|
||||
|
||||
if test -n "$forgit_reset_head"
|
||||
alias $forgit_reset_head 'forgit::reset::head'
|
||||
else
|
||||
alias grh 'forgit::reset::head'
|
||||
end
|
||||
|
||||
if test -n "$forgit_log"
|
||||
alias $forgit_log 'forgit::log'
|
||||
else
|
||||
alias glo 'forgit::log'
|
||||
end
|
||||
|
||||
if test -n "$forgit_diff"
|
||||
alias $forgit_diff 'forgit::diff'
|
||||
else
|
||||
alias gd 'forgit::diff'
|
||||
end
|
||||
|
||||
if test -n "$forgit_ignore"
|
||||
alias $forgit_ignore 'forgit::ignore'
|
||||
else
|
||||
alias gi 'forgit::ignore'
|
||||
end
|
||||
|
||||
if test -n "$forgit_checkout_file"
|
||||
alias $forgit_checkout_file 'forgit::checkout::file'
|
||||
else
|
||||
alias gcf 'forgit::checkout::file'
|
||||
end
|
||||
|
||||
if test -n "$forgit_checkout_branch"
|
||||
alias $forgit_checkout_branch 'forgit::checkout::branch'
|
||||
else
|
||||
alias gcb 'forgit::checkout::branch'
|
||||
end
|
||||
|
||||
if test -n "$forgit_clean"
|
||||
alias $forgit_clean 'forgit::clean'
|
||||
else
|
||||
alias gclean 'forgit::clean'
|
||||
end
|
||||
|
||||
if test -n "$forgit_stash_show"
|
||||
alias $forgit_stash_show 'forgit::stash::show'
|
||||
else
|
||||
alias gss 'forgit::stash::show'
|
||||
end
|
||||
|
||||
if test -n "$forgit_cherry_pick"
|
||||
alias $forgit_cherry_pick 'forgit::cherry::pick'
|
||||
else
|
||||
alias gcp 'forgit::cherry::pick'
|
||||
end
|
||||
|
||||
if test -n "$forgit_rebase"
|
||||
alias $forgit_rebase 'forgit::rebase'
|
||||
else
|
||||
alias grb 'forgit::rebase'
|
||||
end
|
||||
|
||||
if test -n "$forgit_fixup"
|
||||
alias $forgit_fixup 'forgit::fixup'
|
||||
else
|
||||
alias gfu 'forgit::fixup'
|
||||
end
|
||||
|
||||
if test -n "$forgit_checkout_commit"
|
||||
alias $forgit_checkout_commit 'forgit::checkout::commit'
|
||||
else
|
||||
alias gco 'forgit::checkout::commit'
|
||||
end
|
||||
|
||||
end
|
@ -1,35 +0,0 @@
|
||||
# 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
|
||||
|
||||
function _fzf_migration_message --on-event fzf_update
|
||||
set_color FF8C00 # dark orange
|
||||
printf '\n%s\n' 'If you last updated fzf.fish before 2021-06-11, you need to migrate your key bindings.'
|
||||
printf '%s\n\n' 'Check out https://github.com/PatrickF1/fzf.fish/wiki/Migration-Guides#v7.'
|
||||
set_color normal
|
||||
end
|
@ -5,13 +5,11 @@ set -gx XDG_CONFIG_HOME /home/joe/.config
|
||||
set -gx XDG_DATA_HOME /home/joe/.local/share
|
||||
set -gx XDG_CACHE_HOME /home/joe/.cache
|
||||
|
||||
set -gx VISUAL nvim
|
||||
set -gx EDITOR nvim
|
||||
|
||||
fish_hybrid_key_bindings
|
||||
set -gx VISUAL emacsclient -n
|
||||
set -gx EDITOR emacsclient -n
|
||||
|
||||
set -gx MANPAGER "sh -c 'col -bx | bat -l man -p'"
|
||||
bind \cx 'if jobs > /dev/null ; fg; fish_prompt; end'
|
||||
bind -M insert \cx restore_job
|
||||
bind -M insert \ed 'edit-dotfile'
|
||||
|
||||
if [ (uname -r | sed -n 's/.*\( *Microsoft *\).*/\1/ip') ]
|
||||
@ -19,6 +17,9 @@ if [ (uname -r | sed -n 's/.*\( *Microsoft *\).*/\1/ip') ]
|
||||
alias xdg-open wsl-open
|
||||
end
|
||||
|
||||
set -gx forgit_reset_head grf
|
||||
set -gx forgit_diff gdi
|
||||
|
||||
abbr -a -g gs "git status --untracked-files"
|
||||
abbr -a -g gl "git lop -10"
|
||||
abbr -a -g gll "git lol -15"
|
||||
@ -38,17 +39,17 @@ abbr -a -g gpr "git remote prune origin"
|
||||
abbr -a -g gm "git merge"
|
||||
abbr -a -g gmm "git merge master"
|
||||
abbr -a -g gf "git fetch"
|
||||
abbr -a -g grh "git reset --hard"
|
||||
abbr -a -g gcl "git clean -fd"
|
||||
abbr -a -g gd "git diff"
|
||||
# abbr -a -g gpu "git push -u origin"
|
||||
# abbr -a -g glp "git lfs pull"
|
||||
# abbr -a -g glm "gss git merge ; glp"
|
||||
# abbr -a -g gd "git diff"
|
||||
# abbr -a -g gdh "git diff HEAD"
|
||||
# abbr -a -g gms "git merge --squash"
|
||||
# abbr -a -g gb "git branch"
|
||||
# abbr -a -g gba "git branch -a"
|
||||
# abbr -a -g gr "git rebase"
|
||||
# abbr -a -g grh "git reset --hard"
|
||||
# abbr -a -g gcl "git clean -fd"
|
||||
# abbr -a -g gst "git stash"
|
||||
# abbr -a -g gsl "git stash list"
|
||||
# abbr -a -g gsp "git stash pop"
|
||||
|
@ -1,4 +1,2 @@
|
||||
jorgebucaran/fisher
|
||||
sei40kr/fish-ranger-cd
|
||||
PatrickF1/fzf.fish
|
||||
wfxr/forgit
|
||||
|
@ -6,11 +6,9 @@ SETUVAR XDG_CACHE_HOME:/home/joe/\x2ecache
|
||||
SETUVAR XDG_CONFIG_HOME:/home/joe/\x2econfig
|
||||
SETUVAR XDG_DATA_HOME:/home/joe/\x2elocal/share
|
||||
SETUVAR __fish_initialized:3100
|
||||
SETUVAR _fisher_PatrickF1_2F_fzf_2E_fish_files:/home/joe/\x2econfig/fish/functions/_fzf_configure_bindings_help\x2efish\x1e/home/joe/\x2econfig/fish/functions/_fzf_extract_var_info\x2efish\x1e/home/joe/\x2econfig/fish/functions/_fzf_preview_file\x2efish\x1e/home/joe/\x2econfig/fish/functions/_fzf_report_file_type\x2efish\x1e/home/joe/\x2econfig/fish/functions/_fzf_search_directory\x2efish\x1e/home/joe/\x2econfig/fish/functions/_fzf_search_git_log\x2efish\x1e/home/joe/\x2econfig/fish/functions/_fzf_search_git_status\x2efish\x1e/home/joe/\x2econfig/fish/functions/_fzf_search_history\x2efish\x1e/home/joe/\x2econfig/fish/functions/_fzf_search_variables\x2efish\x1e/home/joe/\x2econfig/fish/functions/_fzf_wrapper\x2efish\x1e/home/joe/\x2econfig/fish/functions/fzf_configure_bindings\x2efish\x1e/home/joe/\x2econfig/fish/conf\x2ed/fzf\x2efish\x1e/home/joe/\x2econfig/fish/completions/fzf_configure_bindings\x2efish
|
||||
SETUVAR _fisher_jorgebucaran_2F_fisher_files:/home/joe/\x2econfig/fish/functions/fisher\x2efish\x1e/home/joe/\x2econfig/fish/completions/fisher\x2efish
|
||||
SETUVAR _fisher_plugins:jorgebucaran/fisher\x1esei40kr/fish\x2dranger\x2dcd\x1ePatrickF1/fzf\x2efish\x1ewfxr/forgit
|
||||
SETUVAR _fisher_plugins:jorgebucaran/fisher\x1esei40kr/fish\x2dranger\x2dcd
|
||||
SETUVAR _fisher_sei40kr_2F_fish_2D_ranger_2D_cd_files:/home/joe/\x2econfig/fish/functions/ranger\x2dcd\x2efish
|
||||
SETUVAR _fisher_wfxr_2F_forgit_files:/home/joe/\x2econfig/fish/conf\x2ed/forgit\x2eplugin\x2efish
|
||||
SETUVAR fish_color_autosuggestion:969896
|
||||
SETUVAR fish_color_cancel:\x2dr
|
||||
SETUVAR fish_color_command:b294bb
|
||||
|
@ -1,42 +0,0 @@
|
||||
function _fzf_configure_bindings_help --description "Prints the help message for fzf_configure_bindings."
|
||||
echo "\
|
||||
USAGE:
|
||||
fzf_configure_bindings [--FEATURE[=KEY_SEQUENCE]...]
|
||||
|
||||
DESCRIPTION
|
||||
By default, fzf_configure_bindings installs mnemonic key bindings for fzf.fish's features. Each
|
||||
feature's binding can be customized through a corresponding namesake option:
|
||||
FEATURE | MNEMONIC 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 variables | Ctrl+V (V for variable) | --variables
|
||||
An option with a key sequence value overrides the binding for its feature, while an option
|
||||
without a value disables the binding. A feature that is not customized retains its default
|
||||
menomonic binding specified above. Key bindings are installed for default and insert modes.
|
||||
|
||||
In terms of validation, fzf_configure_bindings fails if passed unknown options. Furthermore, it
|
||||
expects an equals sign between an option's name and value. However, it does not validate key
|
||||
sequences. Rather, consider using fish_key_reader to manually validate them.
|
||||
|
||||
In terms of experimentation, fzf_configure_bindings erases any bindings it previously installed
|
||||
before installing new ones so it can be repeatedly executed in the same fish session without
|
||||
problem. Once the desired fzf_configure_bindings command has been found, add it to config.fish
|
||||
in order to persist the bindings.
|
||||
|
||||
The -h and --help options print this help message.
|
||||
|
||||
EXAMPLES
|
||||
Install the default mnemonic bindings
|
||||
\$ fzf_configure_bindings
|
||||
Install the default bindings but override git log's binding to Ctrl+G
|
||||
\$ fzf_configure_bindings --git_log=\cg
|
||||
Install the default bindings but leave search history unbound
|
||||
\$ fzf_configure_bindings --history
|
||||
Alternative style of disabling search history
|
||||
\$ fzf_configure_bindings --history=
|
||||
An agglomeration of all the options
|
||||
\$ fzf_configure_bindings --git_status=\cg --history=\ch --variables --directory --git_log
|
||||
"
|
||||
end
|
@ -1,15 +0,0 @@
|
||||
# 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
|
@ -1,43 +0,0 @@
|
||||
# helper function for _fzf_search_directory
|
||||
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 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
|
@ -1,6 +0,0 @@
|
||||
# helper function for _fzf_preview_file
|
||||
function _fzf_report_file_type --argument-names file_path file_type --description "Explain the file type for a file."
|
||||
set_color red
|
||||
echo "Cannot preview '$file_path': it is a $file_type."
|
||||
set_color normal
|
||||
end
|
@ -1,41 +0,0 @@
|
||||
function _fzf_search_directory --description "Search the current directory. Replace the current token with the selected file paths."
|
||||
set fd_opts --color=always $fzf_fd_opts
|
||||
set fzf_arguments --multi --ansi $fzf_dir_opts
|
||||
set token (commandline --current-token)
|
||||
# expand any variables or leading tilde (~) in the token
|
||||
set expanded_token (eval echo -- $token)
|
||||
# unescape token because it's already quoted so backslashes will mess up the path
|
||||
set unescaped_exp_token (string unescape -- $expanded_token)
|
||||
|
||||
# If the current token is a directory and has a trailing slash,
|
||||
# then use it as fd's base directory.
|
||||
if string match --quiet -- "*/" $unescaped_exp_token && test -d "$unescaped_exp_token"
|
||||
set --append fd_opts --base-directory=$unescaped_exp_token
|
||||
# use the directory name as fzf's prompt to indicate the search is limited to that directory
|
||||
set --prepend fzf_arguments --prompt="$unescaped_exp_token" --preview="_fzf_preview_file $expanded_token{}"
|
||||
set file_paths_selected $unescaped_exp_token(fd $fd_opts 2>/dev/null | _fzf_wrapper $fzf_arguments)
|
||||
else
|
||||
set --prepend fzf_arguments --query="$unescaped_exp_token" --preview='_fzf_preview_file {}'
|
||||
set file_paths_selected (fd $fd_opts 2>/dev/null | _fzf_wrapper $fzf_arguments)
|
||||
end
|
||||
|
||||
|
||||
if test $status -eq 0
|
||||
# Fish will cd implicitly if a directory name ending in a slash is provided.
|
||||
# To help the user leverage this feature, we automatically append / to the selected path if
|
||||
# - only one path was selected,
|
||||
# - the user was in the middle of inputting the first token,
|
||||
# - the path is a directory
|
||||
# Then, the user only needs to hit Enter once more to cd into that directory.
|
||||
if test (count $file_paths_selected) = 1
|
||||
set commandline_tokens (commandline --tokenize)
|
||||
if test "$commandline_tokens" = "$token" -a -d "$file_paths_selected"
|
||||
set file_paths_selected $file_paths_selected/
|
||||
end
|
||||
end
|
||||
|
||||
commandline --current-token --replace -- (string escape -- $file_paths_selected | string join ' ')
|
||||
end
|
||||
|
||||
commandline --function repaint
|
||||
end
|
@ -1,24 +0,0 @@
|
||||
function _fzf_search_git_log --description "Search the output of git log and preview commits. Replace the current token with the selected commit hash."
|
||||
if not git rev-parse --git-dir >/dev/null 2>&1
|
||||
echo '_fzf_search_git_log: Not in a git repository.' >&2
|
||||
else
|
||||
# see documentation for git format placeholders at https://git-scm.com/docs/git-log#Documentation/git-log.txt-emnem
|
||||
# %h gives you the abbreviated commit hash, which is useful for saving screen space, but we will have to expand it later below
|
||||
set log_fmt_str '%C(bold blue)%h%C(reset) - %C(cyan)%ad%C(reset) %C(yellow)%d%C(reset) %C(normal)%s%C(reset) %C(dim normal)[%an]%C(reset)'
|
||||
set selected_log_line (
|
||||
git log --color=always --format=format:$log_fmt_str --date=short | \
|
||||
_fzf_wrapper --ansi \
|
||||
--tiebreak=index \
|
||||
--preview='git show --color=always {1}' \
|
||||
--query=(commandline --current-token) \
|
||||
$fzf_git_log_opts
|
||||
)
|
||||
if test $status -eq 0
|
||||
set abbreviated_commit_hash (string split --max 1 " " $selected_log_line)[1]
|
||||
set commit_hash (git rev-parse $abbreviated_commit_hash)
|
||||
commandline --current-token --replace $commit_hash
|
||||
end
|
||||
end
|
||||
|
||||
commandline --function repaint
|
||||
end
|
@ -1,33 +0,0 @@
|
||||
function _fzf_search_git_status --description "Search the output of git status. Replace the current token with the selected file paths."
|
||||
if not git rev-parse --git-dir >/dev/null 2>&1
|
||||
echo '_fzf_search_git_status: Not in a git repository.' >&2
|
||||
else
|
||||
set selected_paths (
|
||||
# Pass configuration color.status=always to force status to use colors even though output is sent to a pipe
|
||||
git -c color.status=always status --short |
|
||||
_fzf_wrapper --ansi \
|
||||
--multi \
|
||||
--query=(commandline --current-token) \
|
||||
$fzf_git_status_opts
|
||||
)
|
||||
if test $status -eq 0
|
||||
# git status --short automatically escapes the paths of most files for us so not going to bother trying to handle
|
||||
# the few edges cases of weird file names that should be extremely rare (e.g. "this;needs;escaping")
|
||||
set cleaned_paths
|
||||
|
||||
for path in $selected_paths
|
||||
if test (string sub --length 1 $path) = R
|
||||
# path has been renamed and looks like "R LICENSE -> LICENSE.md"
|
||||
# extract the path to use from after the arrow
|
||||
set --append cleaned_paths (string split -- "-> " $path)[-1]
|
||||
else
|
||||
set --append cleaned_paths (string sub --start=4 $path)
|
||||
end
|
||||
end
|
||||
|
||||
commandline --current-token --replace -- (string escape -- $cleaned_paths | string join ' ')
|
||||
end
|
||||
end
|
||||
|
||||
commandline --function repaint
|
||||
end
|
@ -1,24 +0,0 @@
|
||||
function _fzf_search_history --description "Search command history. Replace the command line with the selected command."
|
||||
# history merge incorporates history changes from other fish sessions
|
||||
builtin history merge
|
||||
|
||||
set command_with_ts (
|
||||
# Reference https://devhints.io/strftime to understand strftime format symbols
|
||||
builtin history --null --show-time="%m-%d %H:%M:%S │ " |
|
||||
_fzf_wrapper --read0 \
|
||||
--tiebreak=index \
|
||||
--query=(commandline) \
|
||||
# preview current command using fish_ident in a window at the bottom 3 lines tall
|
||||
--preview="echo -- {4..} | fish_indent --ansi" \
|
||||
--preview-window="bottom:3:wrap" \
|
||||
$fzf_history_opts |
|
||||
string collect
|
||||
)
|
||||
|
||||
if test $status -eq 0
|
||||
set command_selected (string split --max 1 " │ " $command_with_ts)[2]
|
||||
commandline --replace -- $command_selected
|
||||
end
|
||||
|
||||
commandline --function repaint
|
||||
end
|
@ -1,45 +0,0 @@
|
||||
# This function expects the following two arguments:
|
||||
# argument 1 = output of (set --show | psub), i.e. a file with the scope info and values of all variables
|
||||
# argument 2 = output of (set --names | psub), i.e. a file with all variable names
|
||||
function _fzf_search_variables --argument-names set_show_output set_names_output --description "Search and preview shell variables. Replace the current token with the selected variable."
|
||||
if test -z "$set_names_output"
|
||||
printf '%s\n' '_fzf_search_variables requires 2 arguments.' >&2
|
||||
|
||||
commandline --function repaint
|
||||
return 22 # 22 means invalid argument in POSIX
|
||||
end
|
||||
|
||||
# Exclude the history variable from being piped into fzf because
|
||||
# 1. it's not included in $set_names_output
|
||||
# 2. it tends to be a very large value => increases computation time
|
||||
# 3._fzf_search_history is a much better way to examine history anyway
|
||||
set all_variable_names (string match --invert history <$set_names_output)
|
||||
|
||||
set current_token (commandline --current-token)
|
||||
# Use the current token to pre-populate fzf's query. If the current token begins
|
||||
# with a $, remove it from the query so that it will better match the variable names
|
||||
set cleaned_curr_token (string replace -- '$' '' $current_token)
|
||||
|
||||
set variable_names_selected (
|
||||
printf '%s\n' $all_variable_names |
|
||||
_fzf_wrapper --preview "_fzf_extract_var_info {} $set_show_output" \
|
||||
--multi \
|
||||
--query=$cleaned_curr_token \
|
||||
$fzf_shell_vars_opts
|
||||
)
|
||||
|
||||
if test $status -eq 0
|
||||
# If the current token begins with a $, do not overwrite the $ when
|
||||
# replacing the current token with the selected variable.
|
||||
# Uses brace expansion to prepend $ to each variable name.
|
||||
commandline --current-token --replace (
|
||||
if string match --quiet -- '$*' $current_token
|
||||
string join " " \${$variable_names_selected}
|
||||
else
|
||||
string join " " $variable_names_selected
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
commandline --function repaint
|
||||
end
|
@ -1,20 +0,0 @@
|
||||
function _fzf_wrapper --description "Prepares some environment variables before executing fzf."
|
||||
# Make sure fzf uses fish to execute preview commands, some of which
|
||||
# are autoloaded fish functions so don't exist in other shells.
|
||||
# Use --local so that it doesn't clobber SHELL outside of this function.
|
||||
set --local --export SHELL (command --search fish)
|
||||
|
||||
# If FZF_DEFAULT_OPTS is not set, then set some sane defaults.
|
||||
# See https://github.com/junegunn/fzf#environment-variables
|
||||
if not set --query FZF_DEFAULT_OPTS
|
||||
# cycle allows jumping between the first and last results, making scrolling faster
|
||||
# layout=reverse lists results top to bottom, mimicking the familiar layouts of git log, history, and env
|
||||
# border shows where the fzf window begins and ends
|
||||
# height=90% leaves space to see the current command and some scrollback, maintaining context of work
|
||||
# preview-window=wrap wraps long lines in the preview window, making reading easier
|
||||
# marker=* makes the multi-select marker more distinguishable from the pointer (since both default to >)
|
||||
set --export FZF_DEFAULT_OPTS '--cycle --layout=reverse --border --height=90% --preview-window=wrap --marker="*"'
|
||||
end
|
||||
|
||||
fzf $argv
|
||||
end
|
@ -1,3 +1,3 @@
|
||||
function e --wraps=nvim --description 'alias e nvim'
|
||||
nvim $argv;
|
||||
emacsclient -n $argv;
|
||||
end
|
||||
|
@ -81,33 +81,6 @@ function fish_prompt
|
||||
function fish_mode_prompt
|
||||
end
|
||||
|
||||
if test "$fish_key_bindings" = fish_vi_key_bindings
|
||||
or test "$fish_key_bindings" = fish_hybrid_key_bindings
|
||||
set -l mode
|
||||
switch $fish_bind_mode
|
||||
case default
|
||||
set mode (set_color --bold red)N
|
||||
case insert
|
||||
set mode (set_color --bold green)I
|
||||
case replace_one
|
||||
set mode (set_color --bold green)R
|
||||
echo '[R]'
|
||||
case replace
|
||||
set mode (set_color --bold cyan)R
|
||||
case visual
|
||||
set mode (set_color --bold magenta)V
|
||||
end
|
||||
set mode $mode(set_color normal)
|
||||
_nim_prompt_wrapper $retc '' $mode
|
||||
end
|
||||
|
||||
|
||||
# git
|
||||
set -l prompt_git (fish_git_prompt '%s')
|
||||
test -n "$prompt_git"
|
||||
and _nim_prompt_wrapper $retc G $prompt_git
|
||||
|
||||
# New line
|
||||
echo
|
||||
|
||||
# Background jobs
|
||||
@ -125,11 +98,11 @@ function fish_prompt
|
||||
echo -n '╰─>'
|
||||
set -l user (whoami)
|
||||
if test "$user" = "root"
|
||||
set_color -o red
|
||||
echo -n '# '
|
||||
set_color -o red
|
||||
echo -n '# '
|
||||
else
|
||||
set_color -o green
|
||||
echo -n '$ '
|
||||
set_color -o green
|
||||
echo -n '$ '
|
||||
end
|
||||
|
||||
set_color normal
|
||||
|
@ -1,44 +0,0 @@
|
||||
# Always installs bindings for insert and default mode for simplicity and b/c it has almost no side-effect
|
||||
# https://gitter.im/fish-shell/fish-shell?at=60a55915ee77a74d685fa6b1
|
||||
function fzf_configure_bindings --description "Installs the default key bindings for fzf.fish with user overrides passed as options."
|
||||
# no need to install bindings if not in interactive mode or running tests
|
||||
status is-interactive || test "$CI" = true; or return
|
||||
|
||||
set options_spec h/help 'directory=?' 'git_log=?' 'git_status=?' 'history=?' 'variables=?'
|
||||
argparse --max-args=0 --ignore-unknown $options_spec -- $argv 2>/dev/null
|
||||
if test $status -ne 0
|
||||
echo "Invalid option or a positional argument was provided." 1>&2
|
||||
_fzf_configure_bindings_help
|
||||
return 22
|
||||
else if set --query _flag_help
|
||||
_fzf_configure_bindings_help
|
||||
return
|
||||
else
|
||||
# Initialize with default key sequences and then override or disable them based on flags
|
||||
# index 1 = directory, 2 = git_log, 3 = git_status, 4 = history, 5 = variables
|
||||
set key_sequences \e\cf \e\cl \e\cs \cr \cv # \c = control, \e = escape
|
||||
set --query _flag_directory && set key_sequences[1] "$_flag_directory"
|
||||
set --query _flag_git_log && set key_sequences[2] "$_flag_git_log"
|
||||
set --query _flag_git_status && set key_sequences[3] "$_flag_git_status"
|
||||
set --query _flag_history && set key_sequences[4] "$_flag_history"
|
||||
set --query _flag_variables && set key_sequences[5] "$_flag_variables"
|
||||
|
||||
# If fzf bindings already exists, uninstall it first for a clean slate
|
||||
if functions --query _fzf_uninstall_bindings
|
||||
_fzf_uninstall_bindings
|
||||
end
|
||||
|
||||
for mode in default insert
|
||||
test -n $key_sequences[1] && bind --mode $mode $key_sequences[1] _fzf_search_directory
|
||||
test -n $key_sequences[2] && bind --mode $mode $key_sequences[2] _fzf_search_git_log
|
||||
test -n $key_sequences[3] && bind --mode $mode $key_sequences[3] _fzf_search_git_status
|
||||
test -n $key_sequences[4] && bind --mode $mode $key_sequences[4] _fzf_search_history
|
||||
test -n $key_sequences[5] && bind --mode $mode $key_sequences[5] "$_fzf_search_vars_command"
|
||||
end
|
||||
|
||||
function _fzf_uninstall_bindings --inherit-variable key_sequences
|
||||
bind --erase -- $key_sequences
|
||||
bind --erase --mode insert -- $key_sequences
|
||||
end
|
||||
end
|
||||
end
|
6
.config/fish/functions/restore_job.fish
Normal file
6
.config/fish/functions/restore_job.fish
Normal file
@ -0,0 +1,6 @@
|
||||
function restore_job
|
||||
if jobs > /dev/null
|
||||
fg
|
||||
fish_prompt
|
||||
end
|
||||
end
|
@ -48,6 +48,8 @@ set autochdir
|
||||
set splitbelow
|
||||
set splitright
|
||||
set tabstop=4
|
||||
set tw=80
|
||||
set ft+=t
|
||||
set shiftwidth=4
|
||||
set expandtab
|
||||
set softtabstop=4
|
||||
|
@ -33,6 +33,9 @@
|
||||
(dolist (mode '(org-mode-hook term-mode-hook vterm-mode-hook eshell-mode-hook dired-mode-hook shell-mode-hook magit-mode-hook))
|
||||
(add-hook mode (lambda () (display-line-numbers-mode 0))))
|
||||
|
||||
(make-variable-buffer-local 'global-hl-line-mode)
|
||||
(add-hook 'vterm-mode-hook (lambda () (setq global-hl-line-mode nil)))
|
||||
|
||||
(setq scroll-margin 0
|
||||
scroll-conservatively 100000
|
||||
scroll-preserve-screen-position 1)
|
||||
@ -114,7 +117,7 @@ all of the evil keybindings in buffers like magit, without compromises."
|
||||
'(flycheck-color-mode-line-face-to-color 'mode-line-buffer-id)
|
||||
'(frame-background-mode 'dark)
|
||||
'(package-selected-packages
|
||||
'(magit ranger multi-vterm evil-collection smartparens vterm all-the-icons-dired all-the-icons org-bullets sudoku select-themes fsharp-mode eglot-fsharp fish-mode find-file-in-project helpful ahk-mode rainbow-delimiters csharp-mode doom-themes marginalia eglot selectrum-prescient prescient selectrum avy evil-commentary evil-embrace evil-snipe evil-surround undo-tree which-key dashboard))
|
||||
'(treemacs-icons-dired magit ranger multi-vterm evil-collection smartparens vterm all-the-icons-dired all-the-icons org-bullets sudoku select-themes fsharp-mode eglot-fsharp fish-mode find-file-in-project helpful ahk-mode rainbow-delimiters csharp-mode doom-themes marginalia eglot selectrum-prescient prescient selectrum avy evil-commentary evil-embrace evil-snipe evil-surround undo-tree which-key dashboard))
|
||||
'(window-divider-mode nil))
|
||||
(custom-set-faces
|
||||
;; custom-set-faces was added by Custom.
|
||||
|
Loading…
x
Reference in New Issue
Block a user