From 1c345db4d896bf426e616a16bc7c1c1da09175d7 Mon Sep 17 00:00:00 2001 From: Shawn Anderson Date: Mon, 28 Sep 2020 23:21:14 -0700 Subject: [PATCH] Organizing fish structure using bother fisher and omf. Primarily fisher as it makes local development a sinch. --- dotfiles/.config/fish/conf.d/github.fish | 1 + dotfiles/.config/fish/config.fish | 56 ++-- .../fisher/fish-audio/pacmd-loopback.fish | 8 + .../__fzf_display_value_or_error.fish | 10 + .../fisher/fish-fzf/__fzf_preview_file.fish | 28 ++ .../fish-fzf/__fzf_report_file_type.fish | 6 + .../fish-fzf/__fzf_search_current_dir.fish | 16 + .../fisher/fish-fzf/__fzf_search_git_log.fish | 20 ++ .../fish-fzf/__fzf_search_git_status.fish | 29 ++ .../fisher/fish-fzf/__fzf_search_history.fish | 17 + .../__fzf_search_shell_variables.fish | 21 ++ .../fish/fisher/fish-fzf/fzf-bcd-widget.fish | 6 + .../fisher/fish-fzf/fzf-cdhist-widget.fish | 15 + .../fish/fisher/fish-fzf/fzf-complete.fish | 46 +++ .../fish/fisher/fish-fzf/fzf-select.fish | 8 + .../fisher/fish-fzf/fzf_key_bindings.fish | 1 + .../fisher/fish-github/__github_add_org.fish | 9 + .../fish-github/__github_get_org_repos.fish | 9 + .../fisher/fish-github/conf.d/github.fish | 6 + .../.config/fish/fisher/fish-github/fcd.fish | 19 ++ .../fish/fisher/fish-github/fclone.fish | 17 + .../.config/fish/fisher/fish-github/fhub.fish | 17 + .../fish/fisher/fish-github/fkill.fish | 7 + .../fisher/fish-github/forgit.plugin.fish | 299 +++++++++++++++++ .../fish/fisher/fish-github/readme.fish | 6 + .../fish/fisher/fish-utils/EditDailyLog.fish | 3 + .../fish/fisher/fish-utils/LogDirectory.fish | 3 + .../fisher/fish-utils/OpenLogDirectory.fish | 4 + .../fish/fisher/fish-utils/RunBackup.fish | 29 ++ .../fisher/fish-utils/create_daily_log.fish | 3 + dotfiles/.config/fish/fishfile | 5 + .../fish/functions/.RunBackup.fish.swp | Bin 12288 -> 0 bytes .../.config/fish/functions/EditDailyLog.fish | 4 +- .../.config/fish/functions/LogDirectory.fish | 4 +- .../fish/functions/OpenLogDirectory.fish | 5 +- .../.config/fish/functions/RunBackup.fish | 30 +- .../functions/__fish_prog_needs_command.fish | 7 + .../functions/__fish_prog_using_command.fish | 9 + .../__fzf_display_value_or_error.fish | 11 +- .../fish/functions/__fzf_preview_file.fish | 29 +- .../functions/__fzf_report_file_type.fish | 7 +- .../functions/__fzf_search_current_dir.fish | 17 +- .../fish/functions/__fzf_search_git_log.fish | 21 +- .../functions/__fzf_search_git_status.fish | 30 +- .../fish/functions/__fzf_search_history.fish | 18 +- .../__fzf_search_shell_variables.fish | 22 +- .../fish/functions/__github_add_org.fish | 10 +- .../functions/__github_get_org_repos.fish | 10 +- .../fish/functions/create_daily_log.fish | 4 +- dotfiles/.config/fish/functions/fcd.fish | 20 +- dotfiles/.config/fish/functions/fclone.fish | 18 +- dotfiles/.config/fish/functions/fhub.fish | 18 +- dotfiles/.config/fish/functions/fkill.fish | 8 +- .../.config/fish/functions/forgit.plugin.fish | 300 +----------------- .../fish/functions/fzf-bcd-widget.fish | 7 +- .../fish/functions/fzf-cdhist-widget.fish | 16 +- .../.config/fish/functions/fzf-complete.fish | 47 +-- .../.config/fish/functions/fzf-select.fish | 9 +- .../fish/functions/fzf_key_bindings.fish | 2 +- .../fish/functions/pacmd-loopback.fish | 9 +- dotfiles/.config/fish/functions/readme.fish | 1 + dotfiles/.local/share/fzf/github_orgs | 3 +- 62 files changed, 734 insertions(+), 686 deletions(-) create mode 120000 dotfiles/.config/fish/conf.d/github.fish create mode 100644 dotfiles/.config/fish/fisher/fish-audio/pacmd-loopback.fish create mode 100644 dotfiles/.config/fish/fisher/fish-fzf/__fzf_display_value_or_error.fish create mode 100644 dotfiles/.config/fish/fisher/fish-fzf/__fzf_preview_file.fish create mode 100644 dotfiles/.config/fish/fisher/fish-fzf/__fzf_report_file_type.fish create mode 100644 dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_current_dir.fish create mode 100644 dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_git_log.fish create mode 100755 dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_git_status.fish create mode 100644 dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_history.fish create mode 100644 dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_shell_variables.fish create mode 100644 dotfiles/.config/fish/fisher/fish-fzf/fzf-bcd-widget.fish create mode 100644 dotfiles/.config/fish/fisher/fish-fzf/fzf-cdhist-widget.fish create mode 100644 dotfiles/.config/fish/fisher/fish-fzf/fzf-complete.fish create mode 100644 dotfiles/.config/fish/fisher/fish-fzf/fzf-select.fish create mode 120000 dotfiles/.config/fish/fisher/fish-fzf/fzf_key_bindings.fish create mode 100644 dotfiles/.config/fish/fisher/fish-github/__github_add_org.fish create mode 100644 dotfiles/.config/fish/fisher/fish-github/__github_get_org_repos.fish create mode 100644 dotfiles/.config/fish/fisher/fish-github/conf.d/github.fish create mode 100644 dotfiles/.config/fish/fisher/fish-github/fcd.fish create mode 100644 dotfiles/.config/fish/fisher/fish-github/fclone.fish create mode 100644 dotfiles/.config/fish/fisher/fish-github/fhub.fish create mode 100644 dotfiles/.config/fish/fisher/fish-github/fkill.fish create mode 100644 dotfiles/.config/fish/fisher/fish-github/forgit.plugin.fish create mode 100644 dotfiles/.config/fish/fisher/fish-github/readme.fish create mode 100644 dotfiles/.config/fish/fisher/fish-utils/EditDailyLog.fish create mode 100644 dotfiles/.config/fish/fisher/fish-utils/LogDirectory.fish create mode 100644 dotfiles/.config/fish/fisher/fish-utils/OpenLogDirectory.fish create mode 100644 dotfiles/.config/fish/fisher/fish-utils/RunBackup.fish create mode 100644 dotfiles/.config/fish/fisher/fish-utils/create_daily_log.fish delete mode 100644 dotfiles/.config/fish/functions/.RunBackup.fish.swp mode change 100644 => 120000 dotfiles/.config/fish/functions/EditDailyLog.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/LogDirectory.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/OpenLogDirectory.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/RunBackup.fish create mode 100644 dotfiles/.config/fish/functions/__fish_prog_needs_command.fish create mode 100644 dotfiles/.config/fish/functions/__fish_prog_using_command.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/__fzf_display_value_or_error.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/__fzf_preview_file.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/__fzf_report_file_type.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/__fzf_search_current_dir.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/__fzf_search_git_log.fish mode change 100755 => 120000 dotfiles/.config/fish/functions/__fzf_search_git_status.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/__fzf_search_history.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/__fzf_search_shell_variables.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/__github_add_org.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/__github_get_org_repos.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/create_daily_log.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/fcd.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/fclone.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/fhub.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/fkill.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/forgit.plugin.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/fzf-bcd-widget.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/fzf-cdhist-widget.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/fzf-complete.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/fzf-select.fish mode change 100644 => 120000 dotfiles/.config/fish/functions/pacmd-loopback.fish create mode 120000 dotfiles/.config/fish/functions/readme.fish diff --git a/dotfiles/.config/fish/conf.d/github.fish b/dotfiles/.config/fish/conf.d/github.fish new file mode 120000 index 0000000..5665d39 --- /dev/null +++ b/dotfiles/.config/fish/conf.d/github.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-github/conf.d/github.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/config.fish b/dotfiles/.config/fish/config.fish index c2b962a..4613c8e 100644 --- a/dotfiles/.config/fish/config.fish +++ b/dotfiles/.config/fish/config.fish @@ -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 with because also exits shells. +bind \ea beginning-of-line # Replace with because 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 diff --git a/dotfiles/.config/fish/fisher/fish-audio/pacmd-loopback.fish b/dotfiles/.config/fish/fisher/fish-audio/pacmd-loopback.fish new file mode 100644 index 0000000..99c4192 --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-audio/pacmd-loopback.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-fzf/__fzf_display_value_or_error.fish b/dotfiles/.config/fish/fisher/fish-fzf/__fzf_display_value_or_error.fish new file mode 100644 index 0000000..6d10f0a --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-fzf/__fzf_display_value_or_error.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-fzf/__fzf_preview_file.fish b/dotfiles/.config/fish/fisher/fish-fzf/__fzf_preview_file.fish new file mode 100644 index 0000000..d0a9a95 --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-fzf/__fzf_preview_file.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-fzf/__fzf_report_file_type.fish b/dotfiles/.config/fish/fisher/fish-fzf/__fzf_report_file_type.fish new file mode 100644 index 0000000..e92eb02 --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-fzf/__fzf_report_file_type.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_current_dir.fish b/dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_current_dir.fish new file mode 100644 index 0000000..9435434 --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_current_dir.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_git_log.fish b/dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_git_log.fish new file mode 100644 index 0000000..ffc7286 --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_git_log.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_git_status.fish b/dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_git_status.fish new file mode 100755 index 0000000..153b95a --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_git_status.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_history.fish b/dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_history.fish new file mode 100644 index 0000000..843a55b --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_history.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_shell_variables.fish b/dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_shell_variables.fish new file mode 100644 index 0000000..906a395 --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-fzf/__fzf_search_shell_variables.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-fzf/fzf-bcd-widget.fish b/dotfiles/.config/fish/fisher/fish-fzf/fzf-bcd-widget.fish new file mode 100644 index 0000000..07dc544 --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-fzf/fzf-bcd-widget.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-fzf/fzf-cdhist-widget.fish b/dotfiles/.config/fish/fisher/fish-fzf/fzf-cdhist-widget.fish new file mode 100644 index 0000000..31bd6f7 --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-fzf/fzf-cdhist-widget.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-fzf/fzf-complete.fish b/dotfiles/.config/fish/fisher/fish-fzf/fzf-complete.fish new file mode 100644 index 0000000..0ca0484 --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-fzf/fzf-complete.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-fzf/fzf-select.fish b/dotfiles/.config/fish/fisher/fish-fzf/fzf-select.fish new file mode 100644 index 0000000..88eab28 --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-fzf/fzf-select.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-fzf/fzf_key_bindings.fish b/dotfiles/.config/fish/fisher/fish-fzf/fzf_key_bindings.fish new file mode 120000 index 0000000..4b95db2 --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-fzf/fzf_key_bindings.fish @@ -0,0 +1 @@ +/home/ygg/.local/share/nvim/plugged/fzf/shell/key-bindings.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/fisher/fish-github/__github_add_org.fish b/dotfiles/.config/fish/fisher/fish-github/__github_add_org.fish new file mode 100644 index 0000000..3e7237a --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-github/__github_add_org.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-github/__github_get_org_repos.fish b/dotfiles/.config/fish/fisher/fish-github/__github_get_org_repos.fish new file mode 100644 index 0000000..870e195 --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-github/__github_get_org_repos.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-github/conf.d/github.fish b/dotfiles/.config/fish/fisher/fish-github/conf.d/github.fish new file mode 100644 index 0000000..d8796b6 --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-github/conf.d/github.fish @@ -0,0 +1,6 @@ +#------------------------------------------------------------------------------- +# From https://github.com/wfxr/forgit +# Forgit plugin requires sourcing to activate abbreviations +source ~/.config/fish/functions/forgit.plugin.fish + + diff --git a/dotfiles/.config/fish/fisher/fish-github/fcd.fish b/dotfiles/.config/fish/fisher/fish-github/fcd.fish new file mode 100644 index 0000000..c8c5cf5 --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-github/fcd.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-github/fclone.fish b/dotfiles/.config/fish/fisher/fish-github/fclone.fish new file mode 100644 index 0000000..998079c --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-github/fclone.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-github/fhub.fish b/dotfiles/.config/fish/fisher/fish-github/fhub.fish new file mode 100644 index 0000000..0a8310b --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-github/fhub.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-github/fkill.fish b/dotfiles/.config/fish/fisher/fish-github/fkill.fish new file mode 100644 index 0000000..04cd1a1 --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-github/fkill.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-github/forgit.plugin.fish b/dotfiles/.config/fish/fisher/fish-github/forgit.plugin.fish new file mode 100644 index 0000000..4deb289 --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-github/forgit.plugin.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-github/readme.fish b/dotfiles/.config/fish/fisher/fish-github/readme.fish new file mode 100644 index 0000000..1ad0ede --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-github/readme.fish @@ -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 diff --git a/dotfiles/.config/fish/fisher/fish-utils/EditDailyLog.fish b/dotfiles/.config/fish/fisher/fish-utils/EditDailyLog.fish new file mode 100644 index 0000000..e68738a --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-utils/EditDailyLog.fish @@ -0,0 +1,3 @@ +function EditDailyLog + vim (LogDirectory)/(date +%d-%B).md +end diff --git a/dotfiles/.config/fish/fisher/fish-utils/LogDirectory.fish b/dotfiles/.config/fish/fisher/fish-utils/LogDirectory.fish new file mode 100644 index 0000000..6badb1d --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-utils/LogDirectory.fish @@ -0,0 +1,3 @@ +function LogDirectory + echo ~/Documents/Session\ Notes/(date +%B) +end diff --git a/dotfiles/.config/fish/fisher/fish-utils/OpenLogDirectory.fish b/dotfiles/.config/fish/fisher/fish-utils/OpenLogDirectory.fish new file mode 100644 index 0000000..f86fafe --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-utils/OpenLogDirectory.fish @@ -0,0 +1,4 @@ +function OpenLogDirectory + tmux split-window -h -c (LogDirectory) +end + diff --git a/dotfiles/.config/fish/fisher/fish-utils/RunBackup.fish b/dotfiles/.config/fish/fisher/fish-utils/RunBackup.fish new file mode 100644 index 0000000..0834931 --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-utils/RunBackup.fish @@ -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 + diff --git a/dotfiles/.config/fish/fisher/fish-utils/create_daily_log.fish b/dotfiles/.config/fish/fisher/fish-utils/create_daily_log.fish new file mode 100644 index 0000000..3146705 --- /dev/null +++ b/dotfiles/.config/fish/fisher/fish-utils/create_daily_log.fish @@ -0,0 +1,3 @@ +function create_daily_log + touch (date +%d-%B).md +end diff --git a/dotfiles/.config/fish/fishfile b/dotfiles/.config/fish/fishfile index aea2aa0..dcda27c 100644 --- a/dotfiles/.config/fish/fishfile +++ b/dotfiles/.config/fish/fishfile @@ -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 diff --git a/dotfiles/.config/fish/functions/.RunBackup.fish.swp b/dotfiles/.config/fish/functions/.RunBackup.fish.swp deleted file mode 100644 index 74c766c0b51eaf1079161b4172dbc5e4fed086c8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2PiqrF7>B2V9>l8XNlKuJ$Us4=$G&Vco6*UCYy#5a_AvY_zgS^JMYXp?>;##c{|aQjr(#dSXLNkmD>3F z<=L<2|K4w%RI1dv9j#V@=|h*DwbkXww{)~JZRg$~VHm_ko|$f#nX(sVK98L#@-lqn z^E*0z<@-Sun3jk!8lZtg7?@W#mfBHu@bcn9zJrS0UDqI8lV9hpaB}70UDqI8lV9hID!UrqSU)nN=5T1 z9{>M0-~WHkDD@M31E0Vy*aR=Y61WKdo>uAy_y|6LHy{H~!2&n|j)ULG{T+M;ufa>O z30A;O&<5507XSwh&;Sk401eOp4bT7$&;Sk0-ax9-93Mx55%*;;TrXm8Cokr%#D+5S zy~3u$jaVBT?iwe3U-qQfHeHj8)ul_f>%3JcF094WYH4e6p|q?lq7yndc~=JQ(6{Ak zqFpN2udH7i9n(o7LH!gbqvCL9_@HoU8P<_B?iKP7S68{37Z~jkSIAxC?)lCP>ug%T zo%OquY8;QxuE0S*dfj#|`~B$qcAKi|zI4GjV0Jt{yQ;^2{$R)0i8`@9R#5Y9GHSI~ F{{iut7?}V7 diff --git a/dotfiles/.config/fish/functions/EditDailyLog.fish b/dotfiles/.config/fish/functions/EditDailyLog.fish deleted file mode 100644 index e68738a..0000000 --- a/dotfiles/.config/fish/functions/EditDailyLog.fish +++ /dev/null @@ -1,3 +0,0 @@ -function EditDailyLog - vim (LogDirectory)/(date +%d-%B).md -end diff --git a/dotfiles/.config/fish/functions/EditDailyLog.fish b/dotfiles/.config/fish/functions/EditDailyLog.fish new file mode 120000 index 0000000..8166ec6 --- /dev/null +++ b/dotfiles/.config/fish/functions/EditDailyLog.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-utils/EditDailyLog.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/LogDirectory.fish b/dotfiles/.config/fish/functions/LogDirectory.fish deleted file mode 100644 index 6badb1d..0000000 --- a/dotfiles/.config/fish/functions/LogDirectory.fish +++ /dev/null @@ -1,3 +0,0 @@ -function LogDirectory - echo ~/Documents/Session\ Notes/(date +%B) -end diff --git a/dotfiles/.config/fish/functions/LogDirectory.fish b/dotfiles/.config/fish/functions/LogDirectory.fish new file mode 120000 index 0000000..15684ca --- /dev/null +++ b/dotfiles/.config/fish/functions/LogDirectory.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-utils/LogDirectory.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/OpenLogDirectory.fish b/dotfiles/.config/fish/functions/OpenLogDirectory.fish deleted file mode 100644 index f86fafe..0000000 --- a/dotfiles/.config/fish/functions/OpenLogDirectory.fish +++ /dev/null @@ -1,4 +0,0 @@ -function OpenLogDirectory - tmux split-window -h -c (LogDirectory) -end - diff --git a/dotfiles/.config/fish/functions/OpenLogDirectory.fish b/dotfiles/.config/fish/functions/OpenLogDirectory.fish new file mode 120000 index 0000000..e1cae27 --- /dev/null +++ b/dotfiles/.config/fish/functions/OpenLogDirectory.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-utils/OpenLogDirectory.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/RunBackup.fish b/dotfiles/.config/fish/functions/RunBackup.fish deleted file mode 100644 index 0834931..0000000 --- a/dotfiles/.config/fish/functions/RunBackup.fish +++ /dev/null @@ -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 - diff --git a/dotfiles/.config/fish/functions/RunBackup.fish b/dotfiles/.config/fish/functions/RunBackup.fish new file mode 120000 index 0000000..21965d0 --- /dev/null +++ b/dotfiles/.config/fish/functions/RunBackup.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-utils/RunBackup.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/__fish_prog_needs_command.fish b/dotfiles/.config/fish/functions/__fish_prog_needs_command.fish new file mode 100644 index 0000000..672c047 --- /dev/null +++ b/dotfiles/.config/fish/functions/__fish_prog_needs_command.fish @@ -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 diff --git a/dotfiles/.config/fish/functions/__fish_prog_using_command.fish b/dotfiles/.config/fish/functions/__fish_prog_using_command.fish new file mode 100644 index 0000000..45b95f7 --- /dev/null +++ b/dotfiles/.config/fish/functions/__fish_prog_using_command.fish @@ -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 diff --git a/dotfiles/.config/fish/functions/__fzf_display_value_or_error.fish b/dotfiles/.config/fish/functions/__fzf_display_value_or_error.fish deleted file mode 100644 index 6d10f0a..0000000 --- a/dotfiles/.config/fish/functions/__fzf_display_value_or_error.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/__fzf_display_value_or_error.fish b/dotfiles/.config/fish/functions/__fzf_display_value_or_error.fish new file mode 120000 index 0000000..b720376 --- /dev/null +++ b/dotfiles/.config/fish/functions/__fzf_display_value_or_error.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-fzf/__fzf_display_value_or_error.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/__fzf_preview_file.fish b/dotfiles/.config/fish/functions/__fzf_preview_file.fish deleted file mode 100644 index d0a9a95..0000000 --- a/dotfiles/.config/fish/functions/__fzf_preview_file.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/__fzf_preview_file.fish b/dotfiles/.config/fish/functions/__fzf_preview_file.fish new file mode 120000 index 0000000..b1966d5 --- /dev/null +++ b/dotfiles/.config/fish/functions/__fzf_preview_file.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-fzf/__fzf_preview_file.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/__fzf_report_file_type.fish b/dotfiles/.config/fish/functions/__fzf_report_file_type.fish deleted file mode 100644 index e92eb02..0000000 --- a/dotfiles/.config/fish/functions/__fzf_report_file_type.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/__fzf_report_file_type.fish b/dotfiles/.config/fish/functions/__fzf_report_file_type.fish new file mode 120000 index 0000000..066e6fe --- /dev/null +++ b/dotfiles/.config/fish/functions/__fzf_report_file_type.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-fzf/__fzf_report_file_type.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/__fzf_search_current_dir.fish b/dotfiles/.config/fish/functions/__fzf_search_current_dir.fish deleted file mode 100644 index 9435434..0000000 --- a/dotfiles/.config/fish/functions/__fzf_search_current_dir.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/__fzf_search_current_dir.fish b/dotfiles/.config/fish/functions/__fzf_search_current_dir.fish new file mode 120000 index 0000000..75e4625 --- /dev/null +++ b/dotfiles/.config/fish/functions/__fzf_search_current_dir.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-fzf/__fzf_search_current_dir.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/__fzf_search_git_log.fish b/dotfiles/.config/fish/functions/__fzf_search_git_log.fish deleted file mode 100644 index ffc7286..0000000 --- a/dotfiles/.config/fish/functions/__fzf_search_git_log.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/__fzf_search_git_log.fish b/dotfiles/.config/fish/functions/__fzf_search_git_log.fish new file mode 120000 index 0000000..fa0c702 --- /dev/null +++ b/dotfiles/.config/fish/functions/__fzf_search_git_log.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-fzf/__fzf_search_git_log.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/__fzf_search_git_status.fish b/dotfiles/.config/fish/functions/__fzf_search_git_status.fish deleted file mode 100755 index 153b95a..0000000 --- a/dotfiles/.config/fish/functions/__fzf_search_git_status.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/__fzf_search_git_status.fish b/dotfiles/.config/fish/functions/__fzf_search_git_status.fish new file mode 120000 index 0000000..55de63b --- /dev/null +++ b/dotfiles/.config/fish/functions/__fzf_search_git_status.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-fzf/__fzf_search_git_status.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/__fzf_search_history.fish b/dotfiles/.config/fish/functions/__fzf_search_history.fish deleted file mode 100644 index 843a55b..0000000 --- a/dotfiles/.config/fish/functions/__fzf_search_history.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/__fzf_search_history.fish b/dotfiles/.config/fish/functions/__fzf_search_history.fish new file mode 120000 index 0000000..32aebde --- /dev/null +++ b/dotfiles/.config/fish/functions/__fzf_search_history.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-fzf/__fzf_search_history.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/__fzf_search_shell_variables.fish b/dotfiles/.config/fish/functions/__fzf_search_shell_variables.fish deleted file mode 100644 index 906a395..0000000 --- a/dotfiles/.config/fish/functions/__fzf_search_shell_variables.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/__fzf_search_shell_variables.fish b/dotfiles/.config/fish/functions/__fzf_search_shell_variables.fish new file mode 120000 index 0000000..70413e8 --- /dev/null +++ b/dotfiles/.config/fish/functions/__fzf_search_shell_variables.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-fzf/__fzf_search_shell_variables.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/__github_add_org.fish b/dotfiles/.config/fish/functions/__github_add_org.fish deleted file mode 100644 index 3e7237a..0000000 --- a/dotfiles/.config/fish/functions/__github_add_org.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/__github_add_org.fish b/dotfiles/.config/fish/functions/__github_add_org.fish new file mode 120000 index 0000000..e7416e7 --- /dev/null +++ b/dotfiles/.config/fish/functions/__github_add_org.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-github/__github_add_org.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/__github_get_org_repos.fish b/dotfiles/.config/fish/functions/__github_get_org_repos.fish deleted file mode 100644 index 870e195..0000000 --- a/dotfiles/.config/fish/functions/__github_get_org_repos.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/__github_get_org_repos.fish b/dotfiles/.config/fish/functions/__github_get_org_repos.fish new file mode 120000 index 0000000..85ad036 --- /dev/null +++ b/dotfiles/.config/fish/functions/__github_get_org_repos.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-github/__github_get_org_repos.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/create_daily_log.fish b/dotfiles/.config/fish/functions/create_daily_log.fish deleted file mode 100644 index 3146705..0000000 --- a/dotfiles/.config/fish/functions/create_daily_log.fish +++ /dev/null @@ -1,3 +0,0 @@ -function create_daily_log - touch (date +%d-%B).md -end diff --git a/dotfiles/.config/fish/functions/create_daily_log.fish b/dotfiles/.config/fish/functions/create_daily_log.fish new file mode 120000 index 0000000..f1f7d00 --- /dev/null +++ b/dotfiles/.config/fish/functions/create_daily_log.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-utils/create_daily_log.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/fcd.fish b/dotfiles/.config/fish/functions/fcd.fish deleted file mode 100644 index e779b74..0000000 --- a/dotfiles/.config/fish/functions/fcd.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/fcd.fish b/dotfiles/.config/fish/functions/fcd.fish new file mode 120000 index 0000000..6295950 --- /dev/null +++ b/dotfiles/.config/fish/functions/fcd.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-github/fcd.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/fclone.fish b/dotfiles/.config/fish/functions/fclone.fish deleted file mode 100644 index 998079c..0000000 --- a/dotfiles/.config/fish/functions/fclone.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/fclone.fish b/dotfiles/.config/fish/functions/fclone.fish new file mode 120000 index 0000000..5b1ee99 --- /dev/null +++ b/dotfiles/.config/fish/functions/fclone.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-github/fclone.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/fhub.fish b/dotfiles/.config/fish/functions/fhub.fish deleted file mode 100644 index 0a8310b..0000000 --- a/dotfiles/.config/fish/functions/fhub.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/fhub.fish b/dotfiles/.config/fish/functions/fhub.fish new file mode 120000 index 0000000..9c25c43 --- /dev/null +++ b/dotfiles/.config/fish/functions/fhub.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-github/fhub.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/fkill.fish b/dotfiles/.config/fish/functions/fkill.fish deleted file mode 100644 index 04cd1a1..0000000 --- a/dotfiles/.config/fish/functions/fkill.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/fkill.fish b/dotfiles/.config/fish/functions/fkill.fish new file mode 120000 index 0000000..48e6bd7 --- /dev/null +++ b/dotfiles/.config/fish/functions/fkill.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-github/fkill.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/forgit.plugin.fish b/dotfiles/.config/fish/functions/forgit.plugin.fish deleted file mode 100644 index 4deb289..0000000 --- a/dotfiles/.config/fish/functions/forgit.plugin.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/forgit.plugin.fish b/dotfiles/.config/fish/functions/forgit.plugin.fish new file mode 120000 index 0000000..c9c44a6 --- /dev/null +++ b/dotfiles/.config/fish/functions/forgit.plugin.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-github/forgit.plugin.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/fzf-bcd-widget.fish b/dotfiles/.config/fish/functions/fzf-bcd-widget.fish deleted file mode 100644 index 07dc544..0000000 --- a/dotfiles/.config/fish/functions/fzf-bcd-widget.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/fzf-bcd-widget.fish b/dotfiles/.config/fish/functions/fzf-bcd-widget.fish new file mode 120000 index 0000000..f01b455 --- /dev/null +++ b/dotfiles/.config/fish/functions/fzf-bcd-widget.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-fzf/fzf-bcd-widget.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/fzf-cdhist-widget.fish b/dotfiles/.config/fish/functions/fzf-cdhist-widget.fish deleted file mode 100644 index 31bd6f7..0000000 --- a/dotfiles/.config/fish/functions/fzf-cdhist-widget.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/fzf-cdhist-widget.fish b/dotfiles/.config/fish/functions/fzf-cdhist-widget.fish new file mode 120000 index 0000000..402ac79 --- /dev/null +++ b/dotfiles/.config/fish/functions/fzf-cdhist-widget.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-fzf/fzf-cdhist-widget.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/fzf-complete.fish b/dotfiles/.config/fish/functions/fzf-complete.fish deleted file mode 100644 index 0ca0484..0000000 --- a/dotfiles/.config/fish/functions/fzf-complete.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/fzf-complete.fish b/dotfiles/.config/fish/functions/fzf-complete.fish new file mode 120000 index 0000000..76a5ec1 --- /dev/null +++ b/dotfiles/.config/fish/functions/fzf-complete.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-fzf/fzf-complete.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/fzf-select.fish b/dotfiles/.config/fish/functions/fzf-select.fish deleted file mode 100644 index 88eab28..0000000 --- a/dotfiles/.config/fish/functions/fzf-select.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/fzf-select.fish b/dotfiles/.config/fish/functions/fzf-select.fish new file mode 120000 index 0000000..bf5c05d --- /dev/null +++ b/dotfiles/.config/fish/functions/fzf-select.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-fzf/fzf-select.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/fzf_key_bindings.fish b/dotfiles/.config/fish/functions/fzf_key_bindings.fish index 4b95db2..b57510a 120000 --- a/dotfiles/.config/fish/functions/fzf_key_bindings.fish +++ b/dotfiles/.config/fish/functions/fzf_key_bindings.fish @@ -1 +1 @@ -/home/ygg/.local/share/nvim/plugged/fzf/shell/key-bindings.fish \ No newline at end of file +/home/ygg/.config/fish/fisher/fish-fzf/fzf_key_bindings.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/pacmd-loopback.fish b/dotfiles/.config/fish/functions/pacmd-loopback.fish deleted file mode 100644 index 99c4192..0000000 --- a/dotfiles/.config/fish/functions/pacmd-loopback.fish +++ /dev/null @@ -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 diff --git a/dotfiles/.config/fish/functions/pacmd-loopback.fish b/dotfiles/.config/fish/functions/pacmd-loopback.fish new file mode 120000 index 0000000..a849e3e --- /dev/null +++ b/dotfiles/.config/fish/functions/pacmd-loopback.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-audio/pacmd-loopback.fish \ No newline at end of file diff --git a/dotfiles/.config/fish/functions/readme.fish b/dotfiles/.config/fish/functions/readme.fish new file mode 120000 index 0000000..dcd0fb7 --- /dev/null +++ b/dotfiles/.config/fish/functions/readme.fish @@ -0,0 +1 @@ +/home/ygg/.config/fish/fisher/fish-github/readme.fish \ No newline at end of file diff --git a/dotfiles/.local/share/fzf/github_orgs b/dotfiles/.local/share/fzf/github_orgs index c54682c..b16a85a 100644 --- a/dotfiles/.local/share/fzf/github_orgs +++ b/dotfiles/.local/share/fzf/github_orgs @@ -1,3 +1,4 @@ longtailfinancial holoviz -longtailfinancial +cadcad +blockscience