Organizing fish structure using bother fisher and omf. Primarily fisher as it makes local development a sinch.

This commit is contained in:
Shawn Anderson 2020-09-28 23:21:14 -07:00
parent 78e80ba3d4
commit 1c345db4d8
62 changed files with 734 additions and 686 deletions

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-github/conf.d/github.fish

View File

@ -6,29 +6,6 @@
# powerful commandline tools. It's interactive computing for effective
# workflow.
#-------------------------------------------------------------------------------
# FZF -> Fuzzy find everything!
# Use tmux pane by default
set FZF_TMUX 1
# Use Ripgrep (Faster than Grep)
if type rg &> /dev/null
set FZF_DEFAULT_COMMAND 'rg --files --hidden --follow --glob "!.git/" --glob "!plugged/"'
set FZF_CTRL_T_COMMAND 'rg --files --hidden --follow --glob "!.git/" --glob "!plugged/" $dir'
end
# Multi-select by default
set FZF_DEFAULT_OPTS '-m'
# If installed through vim, fzf needs to be added to path
set PATH $PATH ~/.local/share/nvim/plugged/fzf/bin
#-------------------------------------------------------------------------------
# Autojump -> Faster filesystem navigation
if test -f ~/.autojump/share/autojump/autojump.fish
. ~/.autojump/share/autojump/autojump.fish
end
#-------------------------------------------------------------------------------
# Abbreviations
abbr python python3
abbr vim nvim
@ -38,17 +15,26 @@ abbr l ls -a
#-------------------------------------------------------------------------------
# Key Bindings
# Edit and reload
bind \ee '$EDITOR ~/.config/fish/config.fish'
bind \er 'exec fish'
# Replace \cd with \cg because \cd also exits shells.
bind \cg delete-char
# Replace \ca with \ea because \ca is used as tmux leader key.
bind \ea beginning-of-line
bind \ee '$EDITOR ~/.config/fish/config.fish' # Edit config.fish with alt-e
bind \er 'exec fish' # Reload fish config with alt-r
bind \cg delete-char # Replace readline <C-d> with <C-g> because <C-d> also exits shells.
bind \ea beginning-of-line # Replace <C-a> with <Alt-a> because <C-a> is used as tmux leader key.
#-------------------------------------------------------------------------------
# Forgit plugin requires sourcing to activate abbreviations
# From https://github.com/wfxr/forgit
source ~/.config/fish/functions/forgit.plugin.fish
# FZF -> Fuzzy find everything!
set PATH $PATH ~/.local/share/nvim/plugged/fzf/bin # Fzf is installed through vim plug
set FZF_TMUX 1 # Use tmux pane by default
set FZF_DEFAULT_OPTS '-m' # Multi-select by default
if type rg &> /dev/null # Use Ripgrep (Faster than Grep)
set FZF_DEFAULT_COMMAND 'rg --files --hidden --follow --glob "!.git/" --glob "!plugged/"'
set FZF_CTRL_T_COMMAND 'rg --files --hidden --follow --glob "!.git/" --glob "!plugged/" $dir'
end
#-------------------------------------------------------------------------------
# Autojump -> Faster filesystem navigation
if test -f ~/.autojump/share/autojump/autojump.fish
. ~/.autojump/share/autojump/autojump.fish
end
#-------------------------------------------------------------------------------
# See fishfile for installed plugins through fisherman

View File

@ -0,0 +1,8 @@
# Defined in /tmp/fish.nJXl9C/pacmd-loopback.fish @ line 1
function pacmd-loopback --description 'Loop a pacmd source into a pacmd sink interactively.'
if test (set source (pacmd list-sources | grep name: | awk '{ print $2 }' | cut -d'<' -f2 | cut -d'>' -f1 | fzf-tmux --header="Select a source" --phony); set sink (pacmd list-sinks | grep name: | awk '{ print $2 }' | cut -d'<' -f2 | cut -d'>' -f1 | fzf-tmux --header="Select a sink:"); printf "No\nYes" | fzf-tmux --header="CONFIRM: <$source> -> <$sink>") = "Yes"
pacmd load-module module-loopback source=$source sink=$sink
else
echo "Aborted."
end
end

View File

@ -0,0 +1,10 @@
# helper function for __fzf_search_shell_variables
function __fzf_display_value_or_error --argument-names variable_name --description "Displays either the value of the variable passed in, or an informative message if it is not available."
if set --query $variable_name
echo $$variable_name
else
set_color red
echo "$variable_name was not exported to this process so its value cannot be displayed." >&2
set_color normal
end
end

View File

@ -0,0 +1,28 @@
# helper function for __fzf_search_current_dir
function __fzf_preview_file --argument-names file_path --description "Prints a preview for the given file based on its file type."
if test -f "$file_path" # regular file
bat --style=numbers --color=always "$file_path"
else if test -d "$file_path" # directory
set --local CLICOLOR_FORCE true
ls -a "$file_path"
else 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 -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 "Unexpected file symbol $file_type_char. Please open an issue at https://github.com/patrickf3139/fzf.fish." >&2
end
end

View File

@ -0,0 +1,6 @@
# 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

View File

@ -0,0 +1,16 @@
# originally implemented and transposed from https://github.com/patrickf3139/dotfiles/pull/11
function __fzf_search_current_dir --description "Search the current directory using fzf and fd. Insert the selected relative file path into the commandline at the cursor."
# Make sure that fzf uses fish to execute __fzf_preview_file.
# See similar comment in __fzf_search_shell_variables.fish.
set --local --export SHELL (command --search fish)
set file_path_selected (
fd --hidden --follow --color=always --exclude=.git 2> /dev/null |
fzf --ansi --preview='__fzf_preview_file {}'
)
if test $status -eq 0
commandline --insert (echo $file_path_selected | string escape)
end
commandline --function repaint
end

View File

@ -0,0 +1,20 @@
# Originally implemented in and transposed from https://github.com/patrickf3139/dotfiles/pull/2
function __fzf_search_git_log --description "Search the git log of the current git repository. Insert the selected commit hash into the commandline at the cursor."
if not git rev-parse --git-dir >/dev/null 2>&1
echo '__fzf_search_git_log: Not in a git repository.' >&2
else
set selected_log_line (
# 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
git log --color=always --format=format:'%C(bold blue)%h%C(reset) - %C(cyan)%as%C(reset) %C(yellow)%d%C(reset) %C(normal)%s%C(reset) %C(dim normal)[%an]%C(reset)' | \
fzf --ansi --tiebreak=index --preview='git show --color=always (string split --max 1 " " {})[1]'
)
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 --insert $commit_hash
end
end
commandline --function repaint
end

View File

@ -0,0 +1,29 @@
function __fzf_search_git_status --description "Search the git status of the current git repository. Insert the selected file paths into the commandline at the cursor."
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 --ansi --multi
)
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")
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 cleaned_path (string split -- "-> " $path)[-1]
else
set cleaned_path (string sub --start=4 $path)
end
# add a space after each path to keep them separated when inserted
set cleaned_path_padded "$cleaned_path "
commandline --insert $cleaned_path_padded
end
end
commandline --function repaint
end
end

View File

@ -0,0 +1,17 @@
# originally implemented and transposed from https://github.com/patrickf3139/dotfiles/pull/11
function __fzf_search_history --description "Search command history using fzf. Replace the commandline with the selected command."
# history merge incorporates history changes from other fish sessions
history merge
set command_with_ts (
# Reference https://devhints.io/strftime to understand strftime format symbols
history --null --show-time="%m/%e %H:%M:%S | " |
fzf --read0 --tiebreak=index --query=(commandline)
)
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

View File

@ -0,0 +1,21 @@
function __fzf_search_shell_variables --description "Search and inspect shell variables using fzf. Insert the selected variable into the commandline at the cursor."
# Make sure that fzf uses fish to execute __echo_value_or_print_message, which
# is an autoloaded fish function so doesn't exist in other shells.
# Using --local so that it does not clobber SHELL outside of this function.
set --local --export SHELL (command --search fish)
# Pipe the names of all shell variables to fzf and attempt to display the value
# of the selected variable in fzf's preview window.
# Non-exported variables will not be accessible to the fzf process, in which case
# __echo_value_or_print_message will print an informative message in lieu of the value.
set variable_name (
set --names |
fzf --preview '__fzf_display_value_or_error {}'
)
if test $status -eq 0
commandline --insert $variable_name
end
commandline --function repaint
end

View File

@ -0,0 +1,6 @@
# https://github.com/junegunn/fzf/wiki/Examples-(fish)
function fzf-bcd-widget -d 'cd backwards'
pwd | awk -v RS=/ '/\n/ {exit} {p=p $0 "/"; print p}' | tac | eval (__fzfcmd) +m --select-1 --exit-0 $FZF_BCD_OPTS | read -l result
[ "$result" ]; and cd $result
commandline -f repaint
end

View File

@ -0,0 +1,15 @@
# From https://github.com/junegunn/fzf/wiki/Examples-(fish)
function fzf-cdhist-widget -d 'cd to one of the previously visited locations'
# Clear non-existent folders from cdhist.
set -l buf
for i in (seq 1 (count $dirprev))
set -l dir $dirprev[$i]
if test -d $dir
set buf $buf $dir
end
end
set dirprev $buf
string join \n $dirprev | tac | sed 1d | eval (__fzfcmd) +m --tiebreak=index --toggle-sort=ctrl-r $FZF_CDHIST_OPTS | read -l result
[ "$result" ]; and cd $result
commandline -f repaint
end

View File

@ -0,0 +1,46 @@
# From https://github.com/junegunn/fzf/wiki/Examples-(fish)
function fzf-complete -d 'fzf completion and print selection back to commandline'
# As of 2.6, fish's "complete" function does not understand
# subcommands. Instead, we use the same hack as __fish_complete_subcommand and
# extract the subcommand manually.
set -l cmd (commandline -co) (commandline -ct)
switch $cmd[1]
case env sudo
for i in (seq 2 (count $cmd))
switch $cmd[$i]
case '-*'
case '*=*'
case '*'
set cmd $cmd[$i..-1]
break
end
end
end
set cmd (string join -- ' ' $cmd)
set -l complist (complete -C$cmd)
set -l result
string join -- \n $complist | sort | eval (__fzfcmd) -m --select-1 --exit-0 --header '(commandline)' | cut -f1 | while read -l r; set result $result $r; end
set prefix (string sub -s 1 -l 1 -- (commandline -t))
for i in (seq (count $result))
set -l r $result[$i]
switch $prefix
case "'"
commandline -t -- (string escape -- $r)
case '"'
if string match '*"*' -- $r >/dev/null
commandline -t -- (string escape -- $r)
else
commandline -t -- '"'$r'"'
end
case '~'
commandline -t -- (string sub -s 2 (string escape -n -- $r))
case '*'
commandline -t -- (string escape -n -- $r)
end
[ $i -lt (count $result) ]; and commandline -i ' '
end
commandline -f repaint
end

View File

@ -0,0 +1,8 @@
# From https://github.com/junegunn/fzf/wiki/Examples-(fish)
function fzf-select -d 'fzf commandline job and print unescaped selection back to commandline'
set -l cmd (commandline -j)
[ "$cmd" ]; or return
eval $cmd | eval (__fzfcmd) -m --tiebreak=index --select-1 --exit-0 | string join ' ' | read -l result
[ "$result" ]; and commandline -j -- $result
commandline -f repaint
end

View File

@ -0,0 +1 @@
/home/ygg/.local/share/nvim/plugged/fzf/shell/key-bindings.fish

View File

@ -0,0 +1,9 @@
# Defined in /tmp/fish.azx9vq/__github_add_org.fish @ line 1
function __github_add_org --description 'Add an organization name to the local share fzf file.' --argument org
if ! test -n "$org"
echo "Please provide and org name!"
return 1
else
echo $org >> ~/.local/share/fzf/github_orgs
end
end

View File

@ -0,0 +1,9 @@
# Defined in /tmp/fish.mAOD6Y/__github_get_org_repos.fish @ line 2
function __github_get_org_repos --description 'Return a list of all the github repos owned by a github organization.' --argument org
if ! test -n "$org"
echo "Please provide a github organization name."
return 1
else
curl "https://api.github.com/orgs/$org/repos?per_page=100&page=1" | jq '.[].full_name' | awk -F'"' '{print $2}'
end
end

View File

@ -0,0 +1,6 @@
#-------------------------------------------------------------------------------
# From https://github.com/wfxr/forgit
# Forgit plugin requires sourcing to activate abbreviations
source ~/.config/fish/functions/forgit.plugin.fish

View File

@ -0,0 +1,19 @@
function fcd -d "Fuzzy change directory"
if set -q argv[1]
set searchdir $argv[1]
else
set searchdir $HOME
end
# https://github.com/fish-shell/fish-shell/issues/1362
set -l tmpfile (mktemp)
find $searchdir \( ! -regex '.*/\..*' \) ! -name __pycache__ -type d | fzf > $tmpfile
set -l destdir (cat $tmpfile)
rm -f $tmpfile
if test -z "$destdir"
return 1
end
cd $destdir
end

View File

@ -0,0 +1,17 @@
# Defined in /tmp/fish.yoQzI0/fclone.fish @ line 2
function fclone --argument org
if ! test -n "$org"
set org_file ~/.local/share/fzf/github_orgs
if ! test -e $org_file
echo -n "Please provide an organization name either as an argument to this command or in a list at $org_file"
return 1
else
set org (cat $org_file | fzf-tmux -e --header="Please select an organization. Set additional orgs in $org_file")
end
end
set repo (__github_get_org_repos $org | fzf-tmux --header="Please select a repository to clone.")
if test -n "$repo"
echo "Cloning '$repo' from Github"
git clone "https://github.com/$repo.git"
end
end

View File

@ -0,0 +1,17 @@
# Defined in /tmp/fish.T4Z5Kp/fclone.fish @ line 2
function fhub --argument org
if ! test -n "$org"
set org_file ~/.local/share/fzf/github_orgs
if ! test -e $org_file
echo -n "Please provide an organization name either as an argument to this command or in a list at $org_file"
return 1
else
set org (cat $org_file | fzf-tmux -e --header="Please select an organization. Set additional orgs in $org_file")
end
end
set repo (__github_get_org_repos $org | fzf-tmux --header="Please select a repository to clone.")
if test -n "$repo"
echo "Opening '$repo' in Web Browser"
hub browse $repo
end
end

View File

@ -0,0 +1,7 @@
function fkill -d "Fuzzy kill"
set pid (ps -ef | sed 1d | fzf -m | awk '{print $2}')
if test -n "$pid"
echo $pid | xargs kill -9
end
end

View File

@ -0,0 +1,299 @@
#!/usr/local/bin/fish
# 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 forgit_pager "$FORGIT_PAGER"
set forgit_show_pager "$FORGIT_SHOW_PAGER"
set forgit_diff_pager "$FORGIT_DIFF_PAGER"
set forgit_ignore_pager "$FORGIT_IGNORE_PAGER"
test -z "$forgit_pager"; and set forgit_pager (git config core.pager || echo 'cat')
test -z "$forgit_show_pager"; and set forgit_show_pager (git config pager.show || echo "$forgit_pager")
test -z "$forgit_diff_pager"; and set forgit_diff_pager (git config pager.diff || echo "$forgit_pager")
test -z "$forgit_ignore_pager"; and set forgit_ignore_pager (type -q bat >/dev/null 2>&1 && echo 'bat -l gitignore --color=always' || echo 'cat')
# https://github.com/wfxr/emoji-cli
type -q emojify >/dev/null 2>&1 && set forgit_emojify '|emojify'
# git commit viewer
function forgit::log
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 '\n' | $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='%C(auto)%h%d %s %C(black)%C(bold)%cr' $argv $forgit_emojify" |
env FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd"
end
## git diff viewer
function forgit::diff
forgit::inside_work_tree || return 1
if count $argv > /dev/null
if git rev-parse "$1" > /dev/null 2>&1
#set commit "$1" && set files ("${@:2}")
set commit "$1" && set files "$2"
else
set files "$argv"
end
end
set repo (git rev-parse --show-toplevel)
set opts "
$FORGIT_FZF_DEFAULT_OPTS
+m -0 --bind=\"enter:execute($cmd |env LESS='-R' less)\"
$FORGIT_DIFF_FZF_OPTS
"
set cmd "echo {} |sed 's/.*] //' | xargs -I% git diff --color=always $commit -- '$repo/%' | $forgit_diff_pager"
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
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
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
forgit::inside_work_tree || return 1
set cmd "git diff --color=always -- {} | $forgit_diff_pager"
set opts "
$FORGIT_FZF_DEFAULT_OPTS
-m -0
$FORGIT_CHECKOUT_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
# git stash viewer
function forgit::stash::show
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
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
forgit::inside_work_tree || return 1
set base (git branch --show-current)
if not count $argv > /dev/null
echo "Please specify target branch"
return 1
end
set target $argv[1]
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
# git ignore generator
if test -z "$FORGIT_GI_REPO_REMOTE"
set -x FORGIT_GI_REPO_REMOTE https://github.com/dvcs/gitignore
end
if test -z "$FORGIT_GI_REPO_LOCAL"
if test "XDG_CACHE_HOME"
set -x FORGIT_GI_REPO_LOCAL $XDG_CACHE_HOME/forgit/gi/repos/dvcs/gitignore
else
set -x FORGIT_GI_REPO_LOCAL $HOME/.cache/forgit/gi/repos/dvcs/gitignore
end
end
if test -z "$FORGIT_GI_TEMPLATES"
set -x FORGIT_GI_TEMPLATES $FORGIT_GI_REPO_LOCAL/templates
end
function forgit::ignore
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

View File

@ -0,0 +1,6 @@
function readme -a owner repo branch
if test -z "$branch"
set branch master
end
curl -s https://raw.githubusercontent.com/$owner/$repo/$branch/README.md
end

View File

@ -0,0 +1,3 @@
function EditDailyLog
vim (LogDirectory)/(date +%d-%B).md
end

View File

@ -0,0 +1,3 @@
function LogDirectory
echo ~/Documents/Session\ Notes/(date +%B)
end

View File

@ -0,0 +1,4 @@
function OpenLogDirectory
tmux split-window -h -c (LogDirectory)
end

View File

@ -0,0 +1,29 @@
function RunBackup
echo Pushing ~/.vim to GitHub
cd ~/.vim
git add .
git commit --ammend -m "Running Backup: (date +%D)
git push origin master
echo Pushing ~/.config/fish to GitHub
cd ~/.config/fish
git add config.fish functions/
git commit --ammend -m "Running Backup: (date +%D)
git push origin master
echo Pushing ~/.config/tmux to GitHub
cd ~/.config/tmux
git add .
git commit --ammend -m "Running Backup: (date +%D)
git push origin master
echo Pushing ~/Documents/Notes to GitHub
cd ~/Documents/Notes/
git add .
git commit --ammend -m "Running Backup: (date +%D)
git push origin master
cp ~/Documents ~/sfuhome/Documents
end

View File

@ -0,0 +1,3 @@
function create_daily_log
touch (date +%d-%B).md
end

View File

@ -1 +1,6 @@
jorgebucaran/nvm.fish
tuvistavie/fish-completion-helpers
~/.config/fish/fisher/fish-github
~/.config/fish/fisher/fish-utils
~/.config/fish/fisher/fish-audio
~/.config/fish/fisher/fish-fzf

View File

@ -1,3 +0,0 @@
function EditDailyLog
vim (LogDirectory)/(date +%d-%B).md
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-utils/EditDailyLog.fish

View File

@ -1,3 +0,0 @@
function LogDirectory
echo ~/Documents/Session\ Notes/(date +%B)
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-utils/LogDirectory.fish

View File

@ -1,4 +0,0 @@
function OpenLogDirectory
tmux split-window -h -c (LogDirectory)
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-utils/OpenLogDirectory.fish

View File

@ -1,29 +0,0 @@
function RunBackup
echo Pushing ~/.vim to GitHub
cd ~/.vim
git add .
git commit --ammend -m "Running Backup: (date +%D)
git push origin master
echo Pushing ~/.config/fish to GitHub
cd ~/.config/fish
git add config.fish functions/
git commit --ammend -m "Running Backup: (date +%D)
git push origin master
echo Pushing ~/.config/tmux to GitHub
cd ~/.config/tmux
git add .
git commit --ammend -m "Running Backup: (date +%D)
git push origin master
echo Pushing ~/Documents/Notes to GitHub
cd ~/Documents/Notes/
git add .
git commit --ammend -m "Running Backup: (date +%D)
git push origin master
cp ~/Documents ~/sfuhome/Documents
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-utils/RunBackup.fish

View File

@ -0,0 +1,7 @@
function __fish_prog_needs_command
set -l cmd (commandline -opc)
if test (count $cmd) -eq 1
return 0
end
return 1
end

View File

@ -0,0 +1,9 @@
function __fish_prog_using_command
set -l cmd (commandline -opc)
if test (count $cmd) -gt 1
if test $argv[1] = $cmd[2]
return 0
end
end
return 1
end

View File

@ -1,10 +0,0 @@
# helper function for __fzf_search_shell_variables
function __fzf_display_value_or_error --argument-names variable_name --description "Displays either the value of the variable passed in, or an informative message if it is not available."
if set --query $variable_name
echo $$variable_name
else
set_color red
echo "$variable_name was not exported to this process so its value cannot be displayed." >&2
set_color normal
end
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-fzf/__fzf_display_value_or_error.fish

View File

@ -1,28 +0,0 @@
# helper function for __fzf_search_current_dir
function __fzf_preview_file --argument-names file_path --description "Prints a preview for the given file based on its file type."
if test -f "$file_path" # regular file
bat --style=numbers --color=always "$file_path"
else if test -d "$file_path" # directory
set --local CLICOLOR_FORCE true
ls -a "$file_path"
else 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 -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 "Unexpected file symbol $file_type_char. Please open an issue at https://github.com/patrickf3139/fzf.fish." >&2
end
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-fzf/__fzf_preview_file.fish

View File

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

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-fzf/__fzf_report_file_type.fish

View File

@ -1,16 +0,0 @@
# originally implemented and transposed from https://github.com/patrickf3139/dotfiles/pull/11
function __fzf_search_current_dir --description "Search the current directory using fzf and fd. Insert the selected relative file path into the commandline at the cursor."
# Make sure that fzf uses fish to execute __fzf_preview_file.
# See similar comment in __fzf_search_shell_variables.fish.
set --local --export SHELL (command --search fish)
set file_path_selected (
fd --hidden --follow --color=always --exclude=.git 2> /dev/null |
fzf --ansi --preview='__fzf_preview_file {}'
)
if test $status -eq 0
commandline --insert (echo $file_path_selected | string escape)
end
commandline --function repaint
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-fzf/__fzf_search_current_dir.fish

View File

@ -1,20 +0,0 @@
# Originally implemented in and transposed from https://github.com/patrickf3139/dotfiles/pull/2
function __fzf_search_git_log --description "Search the git log of the current git repository. Insert the selected commit hash into the commandline at the cursor."
if not git rev-parse --git-dir >/dev/null 2>&1
echo '__fzf_search_git_log: Not in a git repository.' >&2
else
set selected_log_line (
# 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
git log --color=always --format=format:'%C(bold blue)%h%C(reset) - %C(cyan)%as%C(reset) %C(yellow)%d%C(reset) %C(normal)%s%C(reset) %C(dim normal)[%an]%C(reset)' | \
fzf --ansi --tiebreak=index --preview='git show --color=always (string split --max 1 " " {})[1]'
)
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 --insert $commit_hash
end
end
commandline --function repaint
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-fzf/__fzf_search_git_log.fish

View File

@ -1,29 +0,0 @@
function __fzf_search_git_status --description "Search the git status of the current git repository. Insert the selected file paths into the commandline at the cursor."
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 --ansi --multi
)
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")
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 cleaned_path (string split -- "-> " $path)[-1]
else
set cleaned_path (string sub --start=4 $path)
end
# add a space after each path to keep them separated when inserted
set cleaned_path_padded "$cleaned_path "
commandline --insert $cleaned_path_padded
end
end
commandline --function repaint
end
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-fzf/__fzf_search_git_status.fish

View File

@ -1,17 +0,0 @@
# originally implemented and transposed from https://github.com/patrickf3139/dotfiles/pull/11
function __fzf_search_history --description "Search command history using fzf. Replace the commandline with the selected command."
# history merge incorporates history changes from other fish sessions
history merge
set command_with_ts (
# Reference https://devhints.io/strftime to understand strftime format symbols
history --null --show-time="%m/%e %H:%M:%S | " |
fzf --read0 --tiebreak=index --query=(commandline)
)
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

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-fzf/__fzf_search_history.fish

View File

@ -1,21 +0,0 @@
function __fzf_search_shell_variables --description "Search and inspect shell variables using fzf. Insert the selected variable into the commandline at the cursor."
# Make sure that fzf uses fish to execute __echo_value_or_print_message, which
# is an autoloaded fish function so doesn't exist in other shells.
# Using --local so that it does not clobber SHELL outside of this function.
set --local --export SHELL (command --search fish)
# Pipe the names of all shell variables to fzf and attempt to display the value
# of the selected variable in fzf's preview window.
# Non-exported variables will not be accessible to the fzf process, in which case
# __echo_value_or_print_message will print an informative message in lieu of the value.
set variable_name (
set --names |
fzf --preview '__fzf_display_value_or_error {}'
)
if test $status -eq 0
commandline --insert $variable_name
end
commandline --function repaint
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-fzf/__fzf_search_shell_variables.fish

View File

@ -1,9 +0,0 @@
# Defined in /tmp/fish.azx9vq/__github_add_org.fish @ line 1
function __github_add_org --description 'Add an organization name to the local share fzf file.' --argument org
if ! test -n "$org"
echo "Please provide and org name!"
return 1
else
echo $org >> ~/.local/share/fzf/github_orgs
end
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-github/__github_add_org.fish

View File

@ -1,9 +0,0 @@
# Defined in /tmp/fish.mAOD6Y/__github_get_org_repos.fish @ line 2
function __github_get_org_repos --description 'Return a list of all the github repos owned by a github organization.' --argument org
if ! test -n "$org"
echo "Please provide a github organization name."
return 1
else
curl "https://api.github.com/orgs/$org/repos?per_page=100&page=1" | jq '.[].full_name' | awk -F'"' '{print $2}'
end
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-github/__github_get_org_repos.fish

View File

@ -1,3 +0,0 @@
function create_daily_log
touch (date +%d-%B).md
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-utils/create_daily_log.fish

View File

@ -1,19 +0,0 @@
function -d "Fuzzy change directory" fcd
if set -q argv[1]
set searchdir $argv[1]
else
set searchdir $HOME
end
# https://github.com/fish-shell/fish-shell/issues/1362
set -l tmpfile (mktemp)
find $searchdir \( ! -regex '.*/\..*' \) ! -name __pycache__ -type d | fzf > $tmpfile
set -l destdir (cat $tmpfile)
rm -f $tmpfile
if test -z "$destdir"
return 1
end
cd $destdir
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-github/fcd.fish

View File

@ -1,17 +0,0 @@
# Defined in /tmp/fish.yoQzI0/fclone.fish @ line 2
function fclone --argument org
if ! test -n "$org"
set org_file ~/.local/share/fzf/github_orgs
if ! test -e $org_file
echo -n "Please provide an organization name either as an argument to this command or in a list at $org_file"
return 1
else
set org (cat $org_file | fzf-tmux -e --header="Please select an organization. Set additional orgs in $org_file")
end
end
set repo (__github_get_org_repos $org | fzf-tmux --header="Please select a repository to clone.")
if test -n "$repo"
echo "Cloning '$repo' from Github"
git clone "https://github.com/$repo.git"
end
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-github/fclone.fish

View File

@ -1,17 +0,0 @@
# Defined in /tmp/fish.T4Z5Kp/fclone.fish @ line 2
function fhub --argument org
if ! test -n "$org"
set org_file ~/.local/share/fzf/github_orgs
if ! test -e $org_file
echo -n "Please provide an organization name either as an argument to this command or in a list at $org_file"
return 1
else
set org (cat $org_file | fzf-tmux -e --header="Please select an organization. Set additional orgs in $org_file")
end
end
set repo (__github_get_org_repos $org | fzf-tmux --header="Please select a repository to clone.")
if test -n "$repo"
echo "Opening '$repo' in Web Browser"
hub browse $repo
end
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-github/fhub.fish

View File

@ -1,7 +0,0 @@
function fkill -d "Fuzzy kill"
set pid (ps -ef | sed 1d | fzf -m | awk '{print $2}')
if test -n "$pid"
echo $pid | xargs kill -9
end
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-github/fkill.fish

View File

@ -1,299 +0,0 @@
#!/usr/local/bin/fish
# 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 forgit_pager "$FORGIT_PAGER"
set forgit_show_pager "$FORGIT_SHOW_PAGER"
set forgit_diff_pager "$FORGIT_DIFF_PAGER"
set forgit_ignore_pager "$FORGIT_IGNORE_PAGER"
test -z "$forgit_pager"; and set forgit_pager (git config core.pager || echo 'cat')
test -z "$forgit_show_pager"; and set forgit_show_pager (git config pager.show || echo "$forgit_pager")
test -z "$forgit_diff_pager"; and set forgit_diff_pager (git config pager.diff || echo "$forgit_pager")
test -z "$forgit_ignore_pager"; and set forgit_ignore_pager (type -q bat >/dev/null 2>&1 && echo 'bat -l gitignore --color=always' || echo 'cat')
# https://github.com/wfxr/emoji-cli
type -q emojify >/dev/null 2>&1 && set forgit_emojify '|emojify'
# git commit viewer
function forgit::log
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 '\n' | $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='%C(auto)%h%d %s %C(black)%C(bold)%cr' $argv $forgit_emojify" |
env FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd"
end
## git diff viewer
function forgit::diff
forgit::inside_work_tree || return 1
if count $argv > /dev/null
if git rev-parse "$1" > /dev/null 2>&1
#set commit "$1" && set files ("${@:2}")
set commit "$1" && set files "$2"
else
set files "$argv"
end
end
set repo (git rev-parse --show-toplevel)
set opts "
$FORGIT_FZF_DEFAULT_OPTS
+m -0 --bind=\"enter:execute($cmd |env LESS='-R' less)\"
$FORGIT_DIFF_FZF_OPTS
"
set cmd "echo {} |sed 's/.*] //' | xargs -I% git diff --color=always $commit -- '$repo/%' | $forgit_diff_pager"
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
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
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
forgit::inside_work_tree || return 1
set cmd "git diff --color=always -- {} | $forgit_diff_pager"
set opts "
$FORGIT_FZF_DEFAULT_OPTS
-m -0
$FORGIT_CHECKOUT_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
# git stash viewer
function forgit::stash::show
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
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
forgit::inside_work_tree || return 1
set base (git branch --show-current)
if not count $argv > /dev/null
echo "Please specify target branch"
return 1
end
set target $argv[1]
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
# git ignore generator
if test -z "$FORGIT_GI_REPO_REMOTE"
set -x FORGIT_GI_REPO_REMOTE https://github.com/dvcs/gitignore
end
if test -z "$FORGIT_GI_REPO_LOCAL"
if test "XDG_CACHE_HOME"
set -x FORGIT_GI_REPO_LOCAL $XDG_CACHE_HOME/forgit/gi/repos/dvcs/gitignore
else
set -x FORGIT_GI_REPO_LOCAL $HOME/.cache/forgit/gi/repos/dvcs/gitignore
end
end
if test -z "$FORGIT_GI_TEMPLATES"
set -x FORGIT_GI_TEMPLATES $FORGIT_GI_REPO_LOCAL/templates
end
function forgit::ignore
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

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-github/forgit.plugin.fish

View File

@ -1,6 +0,0 @@
# https://github.com/junegunn/fzf/wiki/Examples-(fish)
function fzf-bcd-widget -d 'cd backwards'
pwd | awk -v RS=/ '/\n/ {exit} {p=p $0 "/"; print p}' | tac | eval (__fzfcmd) +m --select-1 --exit-0 $FZF_BCD_OPTS | read -l result
[ "$result" ]; and cd $result
commandline -f repaint
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-fzf/fzf-bcd-widget.fish

View File

@ -1,15 +0,0 @@
# From https://github.com/junegunn/fzf/wiki/Examples-(fish)
function fzf-cdhist-widget -d 'cd to one of the previously visited locations'
# Clear non-existent folders from cdhist.
set -l buf
for i in (seq 1 (count $dirprev))
set -l dir $dirprev[$i]
if test -d $dir
set buf $buf $dir
end
end
set dirprev $buf
string join \n $dirprev | tac | sed 1d | eval (__fzfcmd) +m --tiebreak=index --toggle-sort=ctrl-r $FZF_CDHIST_OPTS | read -l result
[ "$result" ]; and cd $result
commandline -f repaint
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-fzf/fzf-cdhist-widget.fish

View File

@ -1,46 +0,0 @@
# From https://github.com/junegunn/fzf/wiki/Examples-(fish)
function fzf-complete -d 'fzf completion and print selection back to commandline'
# As of 2.6, fish's "complete" function does not understand
# subcommands. Instead, we use the same hack as __fish_complete_subcommand and
# extract the subcommand manually.
set -l cmd (commandline -co) (commandline -ct)
switch $cmd[1]
case env sudo
for i in (seq 2 (count $cmd))
switch $cmd[$i]
case '-*'
case '*=*'
case '*'
set cmd $cmd[$i..-1]
break
end
end
end
set cmd (string join -- ' ' $cmd)
set -l complist (complete -C$cmd)
set -l result
string join -- \n $complist | sort | eval (__fzfcmd) -m --select-1 --exit-0 --header '(commandline)' | cut -f1 | while read -l r; set result $result $r; end
set prefix (string sub -s 1 -l 1 -- (commandline -t))
for i in (seq (count $result))
set -l r $result[$i]
switch $prefix
case "'"
commandline -t -- (string escape -- $r)
case '"'
if string match '*"*' -- $r >/dev/null
commandline -t -- (string escape -- $r)
else
commandline -t -- '"'$r'"'
end
case '~'
commandline -t -- (string sub -s 2 (string escape -n -- $r))
case '*'
commandline -t -- (string escape -n -- $r)
end
[ $i -lt (count $result) ]; and commandline -i ' '
end
commandline -f repaint
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-fzf/fzf-complete.fish

View File

@ -1,8 +0,0 @@
# From https://github.com/junegunn/fzf/wiki/Examples-(fish)
function fzf-select -d 'fzf commandline job and print unescaped selection back to commandline'
set -l cmd (commandline -j)
[ "$cmd" ]; or return
eval $cmd | eval (__fzfcmd) -m --tiebreak=index --select-1 --exit-0 | string join ' ' | read -l result
[ "$result" ]; and commandline -j -- $result
commandline -f repaint
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-fzf/fzf-select.fish

View File

@ -1 +1 @@
/home/ygg/.local/share/nvim/plugged/fzf/shell/key-bindings.fish
/home/ygg/.config/fish/fisher/fish-fzf/fzf_key_bindings.fish

View File

@ -1,8 +0,0 @@
# Defined in /tmp/fish.nJXl9C/pacmd-loopback.fish @ line 1
function pacmd-loopback --description 'Loop a pacmd source into a pacmd sink interactively.'
if test (set source (pacmd list-sources | grep name: | awk '{ print $2 }' | cut -d'<' -f2 | cut -d'>' -f1 | fzf-tmux --header="Select a source" --phony); set sink (pacmd list-sinks | grep name: | awk '{ print $2 }' | cut -d'<' -f2 | cut -d'>' -f1 | fzf-tmux --header="Select a sink:"); printf "No\nYes" | fzf-tmux --header="CONFIRM: <$source> -> <$sink>") = "Yes"
pacmd load-module module-loopback source=$source sink=$sink
else
echo "Aborted."
end
end

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-audio/pacmd-loopback.fish

View File

@ -0,0 +1 @@
/home/ygg/.config/fish/fisher/fish-github/readme.fish

View File

@ -1,3 +1,4 @@
longtailfinancial
holoviz
longtailfinancial
cadcad
blockscience