Dotfiles commit (try to keep under 50 characters)
Multi-line description of commit, feel free to be detailed. [Ticket: X] ~ ~ ".git/COMMIT_EDITMSG" 14L, 297C
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
complete --command fisher --exclusive --long help --description "Print help"
|
||||||
|
complete --command fisher --exclusive --long version --description "Print version"
|
||||||
|
complete --command fisher --exclusive --condition __fish_use_subcommand --arguments install --description "Install plugins"
|
||||||
|
complete --command fisher --exclusive --condition __fish_use_subcommand --arguments update --description "Update installed plugins"
|
||||||
|
complete --command fisher --exclusive --condition __fish_use_subcommand --arguments remove --description "Remove installed plugins"
|
||||||
|
complete --command fisher --exclusive --condition __fish_use_subcommand --arguments list --description "List installed plugins matching regex"
|
||||||
|
complete --command fisher --exclusive --condition "__fish_seen_subcommand_from update remove" --arguments "(fisher list)"
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
#
|
||||||
|
# Completions for the tealdeer implementation of tldr
|
||||||
|
# https://github.com/tealdeer-rs/tealdeer/
|
||||||
|
#
|
||||||
|
|
||||||
|
complete -c tldr -s h -l help -d 'Print the help message.' -f
|
||||||
|
complete -c tldr -s v -l version -d 'Show version information.' -f
|
||||||
|
complete -c tldr -s l -l list -d 'List all commands in the cache.' -f
|
||||||
|
complete -c tldr -s f -l render -d 'Render a specific markdown file.' -r
|
||||||
|
complete -c tldr -s p -l platform -d 'Override the operating system.' -xa 'linux macos sunos windows android freebsd netbsd openbsd'
|
||||||
|
complete -c tldr -s L -l language -d 'Override the language' -x
|
||||||
|
complete -c tldr -s u -l update -d 'Update the local cache.' -f
|
||||||
|
complete -c tldr -l no-auto-update -d 'If auto update is configured, disable it for this run.' -f
|
||||||
|
complete -c tldr -s c -l clear-cache -d 'Clear the local cache.' -f
|
||||||
|
complete -c tldr -l pager -d 'Use a pager to page output.' -f
|
||||||
|
complete -c tldr -s r -l raw -d 'Display the raw markdown instead of rendering it.' -f
|
||||||
|
complete -c tldr -s q -l quiet -d 'Suppress informational messages.' -f
|
||||||
|
complete -c tldr -l show-paths -d 'Show file and directory paths used by tealdeer.' -f
|
||||||
|
complete -c tldr -l seed-config -d 'Create a basic config.' -f
|
||||||
|
complete -c tldr -l color -d 'Controls when to use color.' -xa 'always auto never'
|
||||||
|
|
||||||
|
function __tealdeer_entries
|
||||||
|
if set entries (tldr --list 2>/dev/null)
|
||||||
|
string replace -a -i -r "\,\s" "\n" $entries
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
complete -f -c tldr -a '(__tealdeer_entries)'
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
# Deactivate the default virtualenv prompt so that we can add our own
|
||||||
|
set --global --export VIRTUAL_ENV_DISABLE_PROMPT 1
|
||||||
|
|
||||||
|
# Whether or not is a fresh session
|
||||||
|
set --global _pure_fresh_session true
|
||||||
|
|
||||||
|
set --global _pure_root (status current-filename | string replace --regex '/[^/]+$' '' | string replace --regex '/[^/]+$' '')
|
||||||
|
|
||||||
|
# Register `_pure_prompt_new_line` as an event handler for `fish_prompt`
|
||||||
|
for fpath in $fish_function_path
|
||||||
|
test -e $fpath/_pure_prompt_new_line.fish && source $fpath/_pure_prompt_new_line.fish
|
||||||
|
end
|
||||||
|
|
||||||
|
function _pure \
|
||||||
|
--description 'Display branding for pure prompt'
|
||||||
|
|
||||||
|
printf "%s %s" \
|
||||||
|
(set_color $pure_color_warning)$pure_symbol_prompt$pure_symbol_reverse_prompt$pure_symbol_prompt \
|
||||||
|
(set_color $pure_color_primary)"pure"(set_color normal)
|
||||||
|
end
|
||||||
|
|
||||||
|
function _pure_install --on-event pure_install \
|
||||||
|
--description 'Fisher handler when pure prompt is installed'
|
||||||
|
|
||||||
|
source $_pure_root/conf.d/pure.fish
|
||||||
|
|
||||||
|
printf "Now using: %s %s\n" \
|
||||||
|
(_pure) \
|
||||||
|
(set_color --bold $pure_color_success)$pure_version(set_color normal)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Fisher emit an event for all files under conf.d/.
|
||||||
|
# We listen to the event when the new conf.d/_pure_init.fish is sourced,
|
||||||
|
# to read old `pure_version` before sourcing conf.d/pure.fish happens.
|
||||||
|
function _pure_update --on-event _pure_init_update \
|
||||||
|
--description 'Fisher handler pure prompt is updated'
|
||||||
|
|
||||||
|
set --local previous_version $pure_version
|
||||||
|
source $_pure_root/conf.d/pure.fish
|
||||||
|
|
||||||
|
printf "Updating: %s %s → %s\n\t%s\n" \
|
||||||
|
(_pure) \
|
||||||
|
(set_color $pure_color_info)$previous_version(set_color normal) \
|
||||||
|
(set_color --bold $pure_color_success)$pure_version(set_color normal) \
|
||||||
|
" 📖 release notes: "(set_color $pure_color_info)"https://github.com/pure-fish/pure/releases/tag/v$pure_version"(set_color normal)
|
||||||
|
end
|
||||||
|
|
||||||
|
function _pure_uninstall --on-event pure_uninstall \
|
||||||
|
--description 'Fisher handler pure prompt is uninstalled'
|
||||||
|
|
||||||
|
rm -f $_pure_root/conf.d/pure.fish
|
||||||
|
|
||||||
|
# erase existing fish_prompt and fish_title to default
|
||||||
|
functions --erase fish_prompt
|
||||||
|
functions --erase fish_title
|
||||||
|
|
||||||
|
# restore fish_prompt and fish_title to default
|
||||||
|
# reload them into active session
|
||||||
|
# To remain compatible with both single-binary fish and traditional installations
|
||||||
|
# https://github.com/fish-shell/fish-shell/issues/11429#issuecomment-2834407208
|
||||||
|
if status list-files functions/fish_prompt.fish >/dev/null # standalone binary Fish ≥4.1.2
|
||||||
|
status get-file functions/fish_prompt.fish \
|
||||||
|
| tee $__fish_config_dir/functions/fish_prompt.fish \
|
||||||
|
| source
|
||||||
|
status get-file functions/fish_title.fish \
|
||||||
|
| tee $__fish_config_dir/functions/fish_title.fish \
|
||||||
|
| source
|
||||||
|
else # traditional installation
|
||||||
|
cat $__fish_data_dir/functions/fish_prompt.fish \
|
||||||
|
| tee $__fish_config_dir/functions/fish_prompt.fish \
|
||||||
|
| source
|
||||||
|
cat $__fish_data_dir/functions/fish_title.fish \
|
||||||
|
| tee $__fish_config_dir/functions/fish_title.fish \
|
||||||
|
| source
|
||||||
|
end
|
||||||
|
|
||||||
|
# delete _pure* files
|
||||||
|
for file in $_pure_root/{functions,conf.d}/_pure_*
|
||||||
|
rm -f $file
|
||||||
|
end
|
||||||
|
|
||||||
|
# erase _pure* variables
|
||||||
|
set --names \
|
||||||
|
| string replace --filter --regex '(^_?pure)' 'set --erase $1' \
|
||||||
|
| source
|
||||||
|
# erase _pure* functions
|
||||||
|
functions --names --all \
|
||||||
|
| string replace --filter --regex '(^_?pure)' 'functions --erase $1' \
|
||||||
|
| source
|
||||||
|
end
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# alias.fish
|
||||||
|
|
||||||
|
set -x EDITOR nvim
|
||||||
|
set -x VISUAL nvim
|
||||||
@@ -0,0 +1,340 @@
|
|||||||
|
# MIT License
|
||||||
|
|
||||||
|
# Copyright (c) 2016 Francisco Lourenço & Daniel Wehner
|
||||||
|
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
|
||||||
|
if not status is-interactive
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
|
set -g __done_version 1.19.1
|
||||||
|
|
||||||
|
function __done_run_powershell_script
|
||||||
|
set -l powershell_exe (command --search "powershell.exe")
|
||||||
|
|
||||||
|
if test $status -ne 0
|
||||||
|
and command --search wslvar
|
||||||
|
|
||||||
|
set -l powershell_exe (wslpath (wslvar windir)/System32/WindowsPowerShell/v1.0/powershell.exe)
|
||||||
|
end
|
||||||
|
|
||||||
|
if string length --quiet "$powershell_exe"
|
||||||
|
and test -x "$powershell_exe"
|
||||||
|
|
||||||
|
set cmd (string escape $argv)
|
||||||
|
|
||||||
|
eval "$powershell_exe -Command $cmd"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function __done_windows_notification -a title -a message
|
||||||
|
if test "$__done_notify_sound" -eq 1
|
||||||
|
set soundopt "<audio silent=\"false\" src=\"ms-winsoundevent:Notification.Default\" />"
|
||||||
|
else
|
||||||
|
set soundopt "<audio silent=\"true\" />"
|
||||||
|
end
|
||||||
|
|
||||||
|
__done_run_powershell_script "
|
||||||
|
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
|
||||||
|
[Windows.UI.Notifications.ToastNotification, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
|
||||||
|
|
||||||
|
\$toast_xml_source = @\"
|
||||||
|
<toast>
|
||||||
|
$soundopt
|
||||||
|
<visual>
|
||||||
|
<binding template=\"ToastText02\">
|
||||||
|
<text id=\"1\">$title</text>
|
||||||
|
<text id=\"2\">$message</text>
|
||||||
|
</binding>
|
||||||
|
</visual>
|
||||||
|
</toast>
|
||||||
|
\"@
|
||||||
|
|
||||||
|
\$toast_xml = New-Object Windows.Data.Xml.Dom.XmlDocument
|
||||||
|
\$toast_xml.loadXml(\$toast_xml_source)
|
||||||
|
|
||||||
|
\$toast = New-Object Windows.UI.Notifications.ToastNotification \$toast_xml
|
||||||
|
|
||||||
|
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier(\"fish\").Show(\$toast)
|
||||||
|
"
|
||||||
|
end
|
||||||
|
|
||||||
|
function __done_get_focused_window_id
|
||||||
|
if type -q lsappinfo
|
||||||
|
lsappinfo info -only bundleID (lsappinfo front | string replace 'ASN:0x0-' '0x') | cut -d '"' -f4
|
||||||
|
else if test -n "$SWAYSOCK"
|
||||||
|
and type -q jq
|
||||||
|
swaymsg --type get_tree | jq '.. | objects | select(.focused == true) | .id'
|
||||||
|
else if test -n "$HYPRLAND_INSTANCE_SIGNATURE"
|
||||||
|
hyprctl activewindow | awk '/^\tpid: / {print $2}'
|
||||||
|
else if begin
|
||||||
|
test "$XDG_SESSION_DESKTOP" = gnome; and type -q gdbus
|
||||||
|
end
|
||||||
|
gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval 'global.display.focus_window.get_id()'
|
||||||
|
else if type -q xprop
|
||||||
|
and test -n "$DISPLAY"
|
||||||
|
# Test that the X server at $DISPLAY is running
|
||||||
|
and xprop -grammar >/dev/null 2>&1
|
||||||
|
xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2
|
||||||
|
else if uname -a | string match --quiet --ignore-case --regex microsoft
|
||||||
|
__done_run_powershell_script '
|
||||||
|
Add-Type @"
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
public class WindowsCompat {
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern IntPtr GetForegroundWindow();
|
||||||
|
}
|
||||||
|
"@
|
||||||
|
[WindowsCompat]::GetForegroundWindow()
|
||||||
|
'
|
||||||
|
else if set -q __done_allow_nongraphical
|
||||||
|
echo 12345 # dummy value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function __done_is_tmux_window_active
|
||||||
|
set -q fish_pid; or set -l fish_pid %self
|
||||||
|
|
||||||
|
# find the outermost process within tmux
|
||||||
|
# ppid != "tmux" -> pid = ppid
|
||||||
|
# ppid == "tmux" -> break
|
||||||
|
set tmux_fish_pid $fish_pid
|
||||||
|
while set tmux_fish_ppid (ps -o ppid= -p $tmux_fish_pid | string trim)
|
||||||
|
# remove leading hyphen so that basename does not treat it as an argument (e.g. -fish), and return only
|
||||||
|
# the actual command and not its arguments so that basename finds the correct command name.
|
||||||
|
# (e.g. '/usr/bin/tmux' from command '/usr/bin/tmux new-session -c /some/start/dir')
|
||||||
|
and ! string match -q "tmux*" (basename (ps -o command= -p $tmux_fish_ppid | string replace -r '^-' '' | string split ' ')[1])
|
||||||
|
set tmux_fish_pid $tmux_fish_ppid
|
||||||
|
end
|
||||||
|
|
||||||
|
# tmux session attached and window is active -> no notification
|
||||||
|
# all other combinations -> send notification
|
||||||
|
tmux list-panes -a -F "#{session_attached} #{window_active} #{pane_pid}" | string match -q "1 1 $tmux_fish_pid"
|
||||||
|
end
|
||||||
|
|
||||||
|
function __done_is_screen_window_active
|
||||||
|
string match --quiet --regex "$STY\s+\(Attached" (screen -ls)
|
||||||
|
end
|
||||||
|
|
||||||
|
function __done_is_process_window_focused
|
||||||
|
# Return false if the window is not focused
|
||||||
|
|
||||||
|
if set -q __done_allow_nongraphical
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
|
if set -q __done_kitty_remote_control
|
||||||
|
kitty @ --password="$__done_kitty_remote_control_password" ls | jq -e ".[].tabs[] | select(any(.windows[]; .is_self)) | .is_focused" >/dev/null
|
||||||
|
return $status
|
||||||
|
end
|
||||||
|
|
||||||
|
set __done_focused_window_id (__done_get_focused_window_id)
|
||||||
|
if test "$__done_sway_ignore_visible" -eq 1
|
||||||
|
and test -n "$SWAYSOCK"
|
||||||
|
string match --quiet --regex "^true" (swaymsg -t get_tree | jq ".. | objects | select(.id == "$__done_initial_window_id") | .visible")
|
||||||
|
return $status
|
||||||
|
else if test -n "$HYPRLAND_INSTANCE_SIGNATURE"
|
||||||
|
set window_pid (hyprctl activewindow | awk '/^\tpid: / {print $2}')
|
||||||
|
if test -n "$window_pid"
|
||||||
|
and test $__done_initial_window_id -eq $window_pid
|
||||||
|
return $status
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
else if test "$__done_initial_window_id" != "$__done_focused_window_id"
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
# If inside a tmux session, check if the tmux window is focused
|
||||||
|
if type -q tmux
|
||||||
|
and test -n "$TMUX"
|
||||||
|
__done_is_tmux_window_active
|
||||||
|
return $status
|
||||||
|
end
|
||||||
|
|
||||||
|
# If inside a screen session, check if the screen window is focused
|
||||||
|
if type -q screen
|
||||||
|
and test -n "$STY"
|
||||||
|
__done_is_screen_window_active
|
||||||
|
return $status
|
||||||
|
end
|
||||||
|
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function __done_humanize_duration -a milliseconds
|
||||||
|
set -l seconds (math --scale=0 "$milliseconds/1000" % 60)
|
||||||
|
set -l minutes (math --scale=0 "$milliseconds/60000" % 60)
|
||||||
|
set -l hours (math --scale=0 "$milliseconds/3600000")
|
||||||
|
|
||||||
|
if test $hours -gt 0
|
||||||
|
printf '%s' $hours'h '
|
||||||
|
end
|
||||||
|
if test $minutes -gt 0
|
||||||
|
printf '%s' $minutes'm '
|
||||||
|
end
|
||||||
|
if test $seconds -gt 0
|
||||||
|
printf '%s' $seconds's'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# verify that the system has graphical capabilities before initializing
|
||||||
|
if test -z "$SSH_CLIENT" # not over ssh
|
||||||
|
and count (__done_get_focused_window_id) >/dev/null # is able to get window id
|
||||||
|
set __done_enabled
|
||||||
|
end
|
||||||
|
|
||||||
|
if set -q __done_allow_nongraphical
|
||||||
|
and set -q __done_notification_command
|
||||||
|
set __done_enabled
|
||||||
|
end
|
||||||
|
|
||||||
|
if set -q __done_enabled
|
||||||
|
set -g __done_initial_window_id ''
|
||||||
|
set -q __done_min_cmd_duration; or set -g __done_min_cmd_duration 5000
|
||||||
|
set -q __done_exclude; or set -g __done_exclude '^git (?!push|pull|fetch)'
|
||||||
|
set -q __done_notify_sound; or set -g __done_notify_sound 0
|
||||||
|
set -q __done_sway_ignore_visible; or set -g __done_sway_ignore_visible 0
|
||||||
|
set -q __done_tmux_pane_format; or set -g __done_tmux_pane_format '[#{window_index}]'
|
||||||
|
set -q __done_notification_duration; or set -g __done_notification_duration 3000
|
||||||
|
|
||||||
|
function __done_started --on-event fish_preexec
|
||||||
|
set __done_initial_window_id (__done_get_focused_window_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
function __done_ended --on-event fish_postexec
|
||||||
|
set -l exit_status $status
|
||||||
|
|
||||||
|
# backwards compatibility for fish < v3.0
|
||||||
|
set -q cmd_duration; or set -l cmd_duration $CMD_DURATION
|
||||||
|
|
||||||
|
if test $cmd_duration
|
||||||
|
and test $cmd_duration -gt $__done_min_cmd_duration # longer than notify_duration
|
||||||
|
and not __done_is_process_window_focused # process pane or window not focused
|
||||||
|
|
||||||
|
# don't notify if command matches exclude list
|
||||||
|
for pattern in $__done_exclude
|
||||||
|
if string match -qr $pattern $argv[1]
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Store duration of last command
|
||||||
|
set -l humanized_duration (__done_humanize_duration "$cmd_duration")
|
||||||
|
|
||||||
|
set -l title "Done in $humanized_duration"
|
||||||
|
set -l wd (string replace --regex "^$HOME" "~" (pwd))
|
||||||
|
set -l message "$wd/ $argv[1]"
|
||||||
|
set -l sender $__done_initial_window_id
|
||||||
|
|
||||||
|
if test $exit_status -ne 0
|
||||||
|
set title "Failed ($exit_status) after $humanized_duration"
|
||||||
|
end
|
||||||
|
|
||||||
|
if test -n "$TMUX_PANE"
|
||||||
|
set message (tmux lsw -F"$__done_tmux_pane_format" -f '#{==:#{pane_id},'$TMUX_PANE'}')" $message"
|
||||||
|
end
|
||||||
|
|
||||||
|
if set -q __done_notification_command
|
||||||
|
eval $__done_notification_command
|
||||||
|
if test "$__done_notify_sound" -eq 1
|
||||||
|
echo -e "\a" # bell sound
|
||||||
|
end
|
||||||
|
else if set -q KITTY_WINDOW_ID
|
||||||
|
printf "\x1b]99;i=done:d=0;$title\x1b\\"
|
||||||
|
printf "\x1b]99;i=done:d=1:p=body;$message\x1b\\"
|
||||||
|
else if type -q terminal-notifier # https://github.com/julienXX/terminal-notifier
|
||||||
|
if test "$__done_notify_sound" -eq 1
|
||||||
|
# pipe message into terminal-notifier to avoid escaping issues (https://github.com/julienXX/terminal-notifier/issues/134). fixes #140
|
||||||
|
echo "$message" | terminal-notifier -title "$title" -sender "$__done_initial_window_id" -sound default
|
||||||
|
else
|
||||||
|
echo "$message" | terminal-notifier -title "$title" -sender "$__done_initial_window_id"
|
||||||
|
end
|
||||||
|
|
||||||
|
else if type -q osascript # AppleScript
|
||||||
|
# escape double quotes that might exist in the message and break osascript. fixes #133
|
||||||
|
set -l message (string replace --all '"' '\"' "$message")
|
||||||
|
set -l title (string replace --all '"' '\"' "$title")
|
||||||
|
|
||||||
|
osascript -e "display notification \"$message\" with title \"$title\""
|
||||||
|
if test "$__done_notify_sound" -eq 1
|
||||||
|
osascript -e "display notification \"$message\" with title \"$title\" sound name \"Glass\""
|
||||||
|
else
|
||||||
|
osascript -e "display notification \"$message\" with title \"$title\""
|
||||||
|
end
|
||||||
|
|
||||||
|
else if type -q notify-send # Linux notify-send
|
||||||
|
# set urgency to normal
|
||||||
|
set -l urgency normal
|
||||||
|
|
||||||
|
# use user-defined urgency if set
|
||||||
|
if set -q __done_notification_urgency_level
|
||||||
|
set urgency "$__done_notification_urgency_level"
|
||||||
|
end
|
||||||
|
# override user-defined urgency level if non-zero exitstatus
|
||||||
|
if test $exit_status -ne 0
|
||||||
|
set urgency critical
|
||||||
|
if set -q __done_notification_urgency_level_failure
|
||||||
|
set urgency "$__done_notification_urgency_level_failure"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
notify-send --hint=int:transient:1 --urgency=$urgency --icon=utilities-terminal --app-name=fish --expire-time=$__done_notification_duration "$title" "$message"
|
||||||
|
|
||||||
|
if test "$__done_notify_sound" -eq 1
|
||||||
|
echo -e "\a" # bell sound
|
||||||
|
end
|
||||||
|
|
||||||
|
else if type -q notify-desktop # Linux notify-desktop
|
||||||
|
set -l urgency
|
||||||
|
if test $exit_status -ne 0
|
||||||
|
set urgency "--urgency=critical"
|
||||||
|
end
|
||||||
|
notify-desktop $urgency --icon=utilities-terminal --app-name=fish "$title" "$message"
|
||||||
|
if test "$__done_notify_sound" -eq 1
|
||||||
|
echo -e "\a" # bell sound
|
||||||
|
end
|
||||||
|
|
||||||
|
else if uname -a | string match --quiet --ignore-case --regex microsoft
|
||||||
|
__done_windows_notification "$title" "$message"
|
||||||
|
|
||||||
|
else # anything else
|
||||||
|
echo -e "\a" # bell sound
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function __done_uninstall -e done_uninstall
|
||||||
|
# Erase all __done_* functions
|
||||||
|
functions -e __done_ended
|
||||||
|
functions -e __done_started
|
||||||
|
functions -e __done_get_focused_window_id
|
||||||
|
functions -e __done_is_tmux_window_active
|
||||||
|
functions -e __done_is_screen_window_active
|
||||||
|
functions -e __done_is_process_window_focused
|
||||||
|
functions -e __done_windows_notification
|
||||||
|
functions -e __done_run_powershell_script
|
||||||
|
functions -e __done_humanize_duration
|
||||||
|
|
||||||
|
# Erase __done variables
|
||||||
|
set -e __done_version
|
||||||
|
end
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
set --global pure_version 4.18.0 # For bug report and tag-after-merge workflow
|
||||||
|
|
||||||
|
# Base colors
|
||||||
|
_pure_set_default pure_color_primary blue
|
||||||
|
_pure_set_default pure_color_info cyan
|
||||||
|
_pure_set_default pure_color_mute brblack
|
||||||
|
_pure_set_default pure_color_success magenta
|
||||||
|
_pure_set_default pure_color_normal normal
|
||||||
|
_pure_set_default pure_color_danger red
|
||||||
|
_pure_set_default pure_color_light white
|
||||||
|
_pure_set_default pure_color_warning yellow
|
||||||
|
_pure_set_default pure_color_dark black
|
||||||
|
|
||||||
|
# Prompt
|
||||||
|
_pure_set_default pure_symbol_prompt "❯"
|
||||||
|
_pure_set_default pure_symbol_reverse_prompt "❮" # used for VI mode
|
||||||
|
_pure_set_default pure_color_prompt_on_error pure_color_danger
|
||||||
|
_pure_set_default pure_color_prompt_on_success pure_color_success
|
||||||
|
|
||||||
|
# Current Working Directory
|
||||||
|
_pure_set_default pure_color_current_directory pure_color_primary
|
||||||
|
_pure_set_default pure_shorten_prompt_current_directory_length 0
|
||||||
|
_pure_set_default pure_truncate_prompt_current_directory_keeps -1
|
||||||
|
|
||||||
|
# Git
|
||||||
|
_pure_set_default pure_enable_git true
|
||||||
|
_pure_set_default pure_symbol_git_unpulled_commits "⇣"
|
||||||
|
_pure_set_default pure_symbol_git_unpushed_commits "⇡"
|
||||||
|
_pure_set_default pure_symbol_git_dirty "*"
|
||||||
|
_pure_set_default pure_symbol_git_stash "≡"
|
||||||
|
_pure_set_default pure_color_git_unpulled_commits pure_color_info
|
||||||
|
_pure_set_default pure_color_git_unpushed_commits pure_color_info
|
||||||
|
_pure_set_default pure_color_git_branch pure_color_mute
|
||||||
|
_pure_set_default pure_color_git_dirty pure_color_mute
|
||||||
|
_pure_set_default pure_color_git_stash pure_color_info
|
||||||
|
_pure_set_default pure_show_numbered_git_indicator false
|
||||||
|
|
||||||
|
# Remote info (user@hostname) for SSH and containers (Docker/LXC)
|
||||||
|
_pure_set_default pure_color_hostname pure_color_mute
|
||||||
|
_pure_set_default pure_color_at_sign pure_color_mute
|
||||||
|
_pure_set_default pure_color_username_normal pure_color_mute
|
||||||
|
_pure_set_default pure_color_username_root pure_color_light
|
||||||
|
|
||||||
|
# Number of running jobs
|
||||||
|
_pure_set_default pure_show_jobs false
|
||||||
|
_pure_set_default pure_color_jobs pure_color_normal
|
||||||
|
|
||||||
|
# Show system time
|
||||||
|
_pure_set_default pure_show_system_time false
|
||||||
|
_pure_set_default pure_system_time_format '+%T' # 12 hour time: '+%I:%M:%S %p'
|
||||||
|
_pure_set_default pure_color_system_time pure_color_mute
|
||||||
|
|
||||||
|
# Nix build environment
|
||||||
|
_pure_set_default pure_enable_nixdevshell false
|
||||||
|
_pure_set_default pure_symbol_nixdevshell_prefix "❄️" # otherwise nerdfonts: '' or ''
|
||||||
|
_pure_set_default pure_color_nixdevshell_prefix pure_color_info
|
||||||
|
_pure_set_default pure_color_nixdevshell_symbol pure_color_mute
|
||||||
|
|
||||||
|
# env for Python
|
||||||
|
_pure_set_default pure_enable_virtualenv true
|
||||||
|
_pure_set_default pure_symbol_virtualenv_prefix "" # 🐍
|
||||||
|
_pure_set_default pure_color_virtualenv pure_color_mute
|
||||||
|
|
||||||
|
# AWS profile name
|
||||||
|
_pure_set_default pure_enable_aws_profile true
|
||||||
|
_pure_set_default pure_symbol_aws_profile_prefix "" # ☁️
|
||||||
|
_pure_set_default pure_color_aws_profile pure_color_warning
|
||||||
|
|
||||||
|
# Print current working directory at the beginning of prompt
|
||||||
|
# true (default): current directory, git, user@hostname (ssh-only), command duration
|
||||||
|
# false: user@hostname (ssh-only), current directory, git, command duration
|
||||||
|
_pure_set_default pure_begin_prompt_with_current_directory true
|
||||||
|
|
||||||
|
# Show exit code of last command as a separate prompt character (cf. https://github.com/sindresorhus/pure/wiki/Customizations,-hacks-and-tweaks#show-exit-code-of-last-command-as-a-separate-prompt-character)
|
||||||
|
# false - single prompt character, default
|
||||||
|
# true - separate prompt character
|
||||||
|
_pure_set_default pure_separate_prompt_on_error false
|
||||||
|
|
||||||
|
# Prefix the prompt with a list of exit statuses ($pipestatus) if at least one is non-zero
|
||||||
|
_pure_set_default pure_show_exit_status false
|
||||||
|
_pure_set_default pure_convert_exit_status_to_signal false
|
||||||
|
_pure_set_default pure_symbol_exit_status_prefix "|"
|
||||||
|
_pure_set_default pure_symbol_exit_status_separator "|"
|
||||||
|
_pure_set_default pure_color_exit_status pure_color_danger
|
||||||
|
|
||||||
|
# Max execution time of a process before its run time is shown when it exits
|
||||||
|
_pure_set_default pure_threshold_command_duration 5
|
||||||
|
_pure_set_default pure_show_subsecond_command_duration false
|
||||||
|
_pure_set_default pure_color_command_duration pure_color_warning
|
||||||
|
|
||||||
|
# VI mode indicator
|
||||||
|
# true (default): indicate a non-insert mode by reversing the prompt symbol (❮)
|
||||||
|
# false: indicate vi mode with [I], [N], [V]
|
||||||
|
_pure_set_default pure_reverse_prompt_symbol_in_vimode true
|
||||||
|
|
||||||
|
# Title
|
||||||
|
_pure_set_default pure_symbol_title_bar_separator -
|
||||||
|
_pure_set_default pure_shorten_window_title_current_directory_length 0
|
||||||
|
_pure_set_default pure_truncate_window_title_current_directory_keeps -1
|
||||||
|
|
||||||
|
# Check for new release on startup
|
||||||
|
_pure_set_default pure_check_for_new_release false
|
||||||
|
|
||||||
|
# Prefix prompt when logged in as root
|
||||||
|
_pure_set_default pure_show_prefix_root_prompt false
|
||||||
|
_pure_set_default pure_symbol_prefix_root_prompt "#"
|
||||||
|
_pure_set_default pure_color_prefix_root_prompt pure_color_danger
|
||||||
|
|
||||||
|
# Compact mode
|
||||||
|
_pure_set_default pure_enable_single_line_prompt false
|
||||||
|
|
||||||
|
# Detect when running in container (e.g. docker, podman, LXC/LXD)
|
||||||
|
_pure_set_default pure_enable_container_detection true
|
||||||
|
_pure_set_default pure_symbol_container_prefix "" # suggestion: '🐋' or '📦'
|
||||||
|
|
||||||
|
# Detect when running in SSH
|
||||||
|
_pure_set_default pure_symbol_ssh_prefix "" # suggestion: 'ssh:/' or '🔗🔐🔒🌐'
|
||||||
|
|
||||||
|
# Display Kubernetes/k8s context and namespace
|
||||||
|
_pure_set_default pure_enable_k8s false
|
||||||
|
_pure_set_default pure_symbol_k8s_prefix "☸" # ☸️
|
||||||
|
_pure_set_default pure_color_k8s_prefix pure_color_info
|
||||||
|
_pure_set_default pure_color_k8s_context pure_color_success
|
||||||
|
_pure_set_default pure_color_k8s_namespace pure_color_primary
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
source /home/geoff/.config/fish/custom.fish
|
||||||
|
|
||||||
|
# overwrite greeting
|
||||||
|
# potentially disabling fastfetch
|
||||||
|
# function fish_greeting
|
||||||
|
# # fastfetch
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
|
||||||
|
# =========== ALIASES ===========
|
||||||
|
source /home/geoff/.config/fish/conf.d/alias.fish
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
## Source from conf.d before our fish config
|
||||||
|
source /home/geoff/.config/fish/conf.d/done.fish
|
||||||
|
|
||||||
|
## Set values
|
||||||
|
## Run fastfetch as welcome message
|
||||||
|
function fish_greeting
|
||||||
|
fastfetch
|
||||||
|
end
|
||||||
|
|
||||||
|
# Format man pages
|
||||||
|
set -x MANROFFOPT -c
|
||||||
|
set -x MANPAGER "sh -c 'col -bx | bat -l man -p'"
|
||||||
|
|
||||||
|
# Set settings for https://github.com/franciscolourenco/done
|
||||||
|
set -U __done_min_cmd_duration 10000
|
||||||
|
set -U __done_notification_urgency_level low
|
||||||
|
|
||||||
|
## Environment setup
|
||||||
|
# Apply .profile: use this to put fish compatible .profile stuff in
|
||||||
|
if test -f ~/.fish_profile
|
||||||
|
source ~/.fish_profile
|
||||||
|
end
|
||||||
|
|
||||||
|
# Append common directories for executable files to $PATH
|
||||||
|
fish_add_path ~/.local/bin ~/.cargo/bin ~/Applications/depot_tools
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
# Functions needed for !! and !$ https://github.com/oh-my-fish/plugin-bang-bang
|
||||||
|
function __history_previous_command
|
||||||
|
switch (commandline -t)
|
||||||
|
case "!"
|
||||||
|
commandline -t $history[1]
|
||||||
|
commandline -f repaint
|
||||||
|
case "*"
|
||||||
|
commandline -i !
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function __history_previous_command_arguments
|
||||||
|
switch (commandline -t)
|
||||||
|
case "!"
|
||||||
|
commandline -t ""
|
||||||
|
commandline -f history-token-search-backward
|
||||||
|
case "*"
|
||||||
|
commandline -i '$'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if [ "$fish_key_bindings" = fish_vi_key_bindings ]
|
||||||
|
|
||||||
|
bind -Minsert ! __history_previous_command
|
||||||
|
bind -Minsert '$' __history_previous_command_arguments
|
||||||
|
else
|
||||||
|
bind ! __history_previous_command
|
||||||
|
bind '$' __history_previous_command_arguments
|
||||||
|
end
|
||||||
|
|
||||||
|
# Fish command history
|
||||||
|
function history
|
||||||
|
builtin history --show-time='%F %T ' $argv
|
||||||
|
end
|
||||||
|
|
||||||
|
function backup --argument filename
|
||||||
|
cp $filename $filename.bak
|
||||||
|
end
|
||||||
|
|
||||||
|
# Copy DIR1 DIR2
|
||||||
|
function copy
|
||||||
|
set count (count $argv | tr -d \n)
|
||||||
|
if test "$count" = 2; and test -d "$argv[1]"
|
||||||
|
set from (echo $argv[1] | trim-right /)
|
||||||
|
set to (echo $argv[2])
|
||||||
|
command cp -r $from $to
|
||||||
|
else
|
||||||
|
command cp $argv
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
## Useful aliases
|
||||||
|
# Replace ls with eza
|
||||||
|
alias ls='eza -al --color=always --group-directories-first --icons=always' # preferred listing
|
||||||
|
alias la='eza -a --color=always --group-directories-first --icons=always' # all files and dirs
|
||||||
|
alias ll='eza -l --color=always --group-directories-first --icons=always' # long format
|
||||||
|
alias lt='eza -aT --color=always --group-directories-first --icons=always' # tree listing
|
||||||
|
alias l.="eza -a | grep -e '^\.'" # show only dotfiles
|
||||||
|
|
||||||
|
# Common use
|
||||||
|
alias grubup="sudo grub-mkconfig -o /boot/grub/grub.cfg"
|
||||||
|
alias fixpacman="sudo rm /var/lib/pacman/db.lck"
|
||||||
|
alias tarnow='tar -acf '
|
||||||
|
alias untar='tar -zxvf '
|
||||||
|
alias wget='wget -c '
|
||||||
|
alias psmem='ps auxf | sort -nr -k 4'
|
||||||
|
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
|
||||||
|
alias ..='cd ..'
|
||||||
|
alias ...='cd ../..'
|
||||||
|
alias ....='cd ../../..'
|
||||||
|
alias .....='cd ../../../..'
|
||||||
|
alias ......='cd ../../../../..'
|
||||||
|
alias dir='dir --color=auto'
|
||||||
|
alias vdir='vdir --color=auto'
|
||||||
|
alias grep='grep --color=auto'
|
||||||
|
alias fgrep='fgrep --color=auto'
|
||||||
|
alias egrep='egrep --color=auto'
|
||||||
|
alias hw='hwinfo --short' # Hardware Info
|
||||||
|
alias big="expac -H M '%m\t%n' | sort -h | nl" # Sort installed packages according to size in MB
|
||||||
|
alias gitpkg='pacman -Q | grep -i "\-git" | wc -l' # List amount of -git packages
|
||||||
|
alias update='sudo cachyos-rate-mirrors && sudo pacman -Syu'
|
||||||
|
|
||||||
|
# Get fastest mirrors
|
||||||
|
alias mirror="sudo cachyos-rate-mirrors"
|
||||||
|
|
||||||
|
# Help people new to Arch
|
||||||
|
alias apt='man pacman'
|
||||||
|
alias apt-get='man pacman'
|
||||||
|
alias tb='nc termbin.com 9999'
|
||||||
|
|
||||||
|
# Cleanup orphaned packages
|
||||||
|
alias cleanup='sudo pacman -Rns (pacman -Qtdq)'
|
||||||
|
|
||||||
|
# Get the error messages from journalctl
|
||||||
|
alias jctl="journalctl -p 3 -xb"
|
||||||
|
|
||||||
|
# Recent installed packages
|
||||||
|
alias rip="expac --timefmt='%Y-%m-%d %T' '%l\t%n %v' | sort | tail -200 | nl"
|
||||||
|
|
||||||
|
# kitten ssh
|
||||||
|
alias s="kitten ssh $argv"
|
||||||
|
|
||||||
|
# nvim
|
||||||
|
alias nvimf="nvim (kitten choose-file)"
|
||||||
|
|
||||||
|
# dotfiles
|
||||||
|
alias dotfiles='/usr/bin/git --git-dir="$HOME/.dotfiles/" --work-tree="$HOME"'
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
jorgebucaran/fisher
|
||||||
|
pure-fish/pure
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
# This file contains fish universal variable definitions.
|
||||||
|
# VERSION: 3.0
|
||||||
|
SETUVAR --export FZF_DEFAULT_OPTS:\x0a\x09\x20\x20\x20\x20\x2d\x2dcolor\x3dfg\x3a\x23797593\x2cbg\x3a\x23faf4ed\x2chl\x3a\x23d7827e\x0a\x09\x20\x20\x20\x20\x2d\x2dcolor\x3dfg\x2b\x3a\x23575279\x2cbg\x2b\x3a\x23f2e9e1\x2chl\x2b\x3a\x23d7827e\x0a\x09\x20\x20\x20\x20\x2d\x2dcolor\x3dborder\x3a\x23dfdad9\x2cheader\x3a\x23286983\x2cgutter\x3a\x23faf4ed\x0a\x09\x20\x20\x20\x20\x2d\x2dcolor\x3dspinner\x3a\x23ea9d34\x2cinfo\x3a\x2356949f\x0a\x09\x20\x20\x20\x20\x2d\x2dcolor\x3dpointer\x3a\x23907aa9\x2cmarker\x3a\x23b4637a\x2cprompt\x3a\x23797593\x0a\x20\x20\x20\x20\x20\x20\x2d\x2dcolor\x3dbg\x3a\x2d1\x2cbg\x2b\x3a\x2d1
|
||||||
|
SETUVAR __done_min_cmd_duration:10000
|
||||||
|
SETUVAR __done_notification_urgency_level:low
|
||||||
|
SETUVAR __fish_initialized:4300
|
||||||
|
SETUVAR _fisher_jorgebucaran_2F_fisher_files:\x7e/\x2econfig/fish/functions/fisher\x2efish\x1e\x7e/\x2econfig/fish/completions/fisher\x2efish
|
||||||
|
SETUVAR _fisher_plugins:jorgebucaran/fisher\x1epure\x2dfish/pure
|
||||||
|
SETUVAR _fisher_pure_2D_fish_2F_pure_files:\x7e/\x2econfig/fish/functions/_pure_check_availability\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_check_for_new_release\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_detect_container_by_cgroup_method\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_detect_container_by_pid_method\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_format_time\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_get_prompt_symbol\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_is_inside_container\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_is_single_line_prompt\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_k8s_context\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_k8s_namespace\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_parse_directory\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_parse_git_branch\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_place_iterm2_prompt_mark\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prefix_root_prompt\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_print_prompt\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_print_prompt_rows\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_aws_profile\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_beginning\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_command_duration\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_container\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_current_folder\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_ending\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_exit_status\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_first_line\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_git\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_git_branch\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_git_dirty\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_git_pending_commits\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_git_stash\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_jobs\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_k8s\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_new_line\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_nixdevshell\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_ssh\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_symbol\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_system_time\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_transient\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_vimode\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_prompt_virtualenv\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_set_color\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_set_default\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_string_width\x2efish\x1e\x7e/\x2econfig/fish/functions/_pure_user_at_host\x2efish\x1e\x7e/\x2econfig/fish/functions/fish_mode_prompt\x2efish\x1e\x7e/\x2econfig/fish/functions/fish_prompt\x2efish\x1e\x7e/\x2econfig/fish/functions/fish_title\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/_pure_init\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/pure\x2efish
|
||||||
|
SETUVAR _fisher_upgraded_to_4_4:\x1d
|
||||||
|
SETUVAR fish_user_paths:/usr/local/bin\x1e/usr/bin
|
||||||
|
SETUVAR pure_begin_prompt_with_current_directory:true
|
||||||
|
SETUVAR pure_check_for_new_release:false
|
||||||
|
SETUVAR pure_color_at_sign:pure_color_mute
|
||||||
|
SETUVAR pure_color_aws_profile:pure_color_warning
|
||||||
|
SETUVAR pure_color_command_duration:pure_color_warning
|
||||||
|
SETUVAR pure_color_current_directory:pure_color_primary
|
||||||
|
SETUVAR pure_color_danger:red
|
||||||
|
SETUVAR pure_color_dark:black
|
||||||
|
SETUVAR pure_color_exit_status:pure_color_danger
|
||||||
|
SETUVAR pure_color_git_branch:pure_color_mute
|
||||||
|
SETUVAR pure_color_git_dirty:pure_color_mute
|
||||||
|
SETUVAR pure_color_git_stash:pure_color_info
|
||||||
|
SETUVAR pure_color_git_unpulled_commits:pure_color_info
|
||||||
|
SETUVAR pure_color_git_unpushed_commits:pure_color_info
|
||||||
|
SETUVAR pure_color_hostname:pure_color_mute
|
||||||
|
SETUVAR pure_color_info:cyan
|
||||||
|
SETUVAR pure_color_jobs:pure_color_normal
|
||||||
|
SETUVAR pure_color_k8s_context:pure_color_success
|
||||||
|
SETUVAR pure_color_k8s_namespace:pure_color_primary
|
||||||
|
SETUVAR pure_color_k8s_prefix:pure_color_info
|
||||||
|
SETUVAR pure_color_light:white
|
||||||
|
SETUVAR pure_color_mute:brblack
|
||||||
|
SETUVAR pure_color_nixdevshell_prefix:pure_color_info
|
||||||
|
SETUVAR pure_color_nixdevshell_symbol:pure_color_mute
|
||||||
|
SETUVAR pure_color_normal:normal
|
||||||
|
SETUVAR pure_color_prefix_root_prompt:pure_color_danger
|
||||||
|
SETUVAR pure_color_primary:blue
|
||||||
|
SETUVAR pure_color_prompt_on_error:pure_color_danger
|
||||||
|
SETUVAR pure_color_prompt_on_success:pure_color_success
|
||||||
|
SETUVAR pure_color_success:magenta
|
||||||
|
SETUVAR pure_color_system_time:pure_color_mute
|
||||||
|
SETUVAR pure_color_username_normal:pure_color_mute
|
||||||
|
SETUVAR pure_color_username_root:pure_color_light
|
||||||
|
SETUVAR pure_color_virtualenv:pure_color_mute
|
||||||
|
SETUVAR pure_color_warning:yellow
|
||||||
|
SETUVAR pure_convert_exit_status_to_signal:false
|
||||||
|
SETUVAR pure_enable_aws_profile:true
|
||||||
|
SETUVAR pure_enable_container_detection:true
|
||||||
|
SETUVAR pure_enable_git:true
|
||||||
|
SETUVAR pure_enable_k8s:false
|
||||||
|
SETUVAR pure_enable_nixdevshell:false
|
||||||
|
SETUVAR pure_enable_single_line_prompt:false
|
||||||
|
SETUVAR pure_enable_virtualenv:true
|
||||||
|
SETUVAR pure_reverse_prompt_symbol_in_vimode:true
|
||||||
|
SETUVAR pure_separate_prompt_on_error:false
|
||||||
|
SETUVAR pure_shorten_prompt_current_directory_length:0
|
||||||
|
SETUVAR pure_shorten_window_title_current_directory_length:0
|
||||||
|
SETUVAR pure_show_exit_status:false
|
||||||
|
SETUVAR pure_show_jobs:false
|
||||||
|
SETUVAR pure_show_numbered_git_indicator:false
|
||||||
|
SETUVAR pure_show_prefix_root_prompt:false
|
||||||
|
SETUVAR pure_show_subsecond_command_duration:false
|
||||||
|
SETUVAR pure_show_system_time:false
|
||||||
|
SETUVAR pure_symbol_aws_profile_prefix:
|
||||||
|
SETUVAR pure_symbol_container_prefix:
|
||||||
|
SETUVAR pure_symbol_exit_status_prefix:\x7c
|
||||||
|
SETUVAR pure_symbol_exit_status_separator:\x7c
|
||||||
|
SETUVAR pure_symbol_git_dirty:\x2a
|
||||||
|
SETUVAR pure_symbol_git_stash:\u2261
|
||||||
|
SETUVAR pure_symbol_git_unpulled_commits:\u21e3
|
||||||
|
SETUVAR pure_symbol_git_unpushed_commits:\u21e1
|
||||||
|
SETUVAR pure_symbol_k8s_prefix:\u2638
|
||||||
|
SETUVAR pure_symbol_nixdevshell_prefix:\u2744\ufe0f
|
||||||
|
SETUVAR pure_symbol_prefix_root_prompt:\x23
|
||||||
|
SETUVAR pure_symbol_prompt:\u276f
|
||||||
|
SETUVAR pure_symbol_reverse_prompt:\u276e
|
||||||
|
SETUVAR pure_symbol_ssh_prefix:
|
||||||
|
SETUVAR pure_symbol_title_bar_separator:\x2d
|
||||||
|
SETUVAR pure_symbol_virtualenv_prefix:
|
||||||
|
SETUVAR pure_system_time_format:\x2b\x25T
|
||||||
|
SETUVAR pure_threshold_command_duration:5
|
||||||
|
SETUVAR pure_truncate_prompt_current_directory_keeps:\x2d1
|
||||||
|
SETUVAR pure_truncate_window_title_current_directory_keeps:\x2d1
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
function _pure_check_availability \
|
||||||
|
--description "Ensure command is available on system" \
|
||||||
|
--argument-names \
|
||||||
|
feature_flag \
|
||||||
|
required_command
|
||||||
|
|
||||||
|
set FAILURE 1
|
||||||
|
|
||||||
|
if not type -q $required_command # command, function or alias are OK
|
||||||
|
echo (set_color $pure_color_warning) \
|
||||||
|
"$feature_flag feature requires: `$required_command`" \
|
||||||
|
(set_color $pure_color_normal)
|
||||||
|
return $FAILURE
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
function _pure_check_for_new_release \
|
||||||
|
--description "Check for new release and show command to install"
|
||||||
|
|
||||||
|
if test "$pure_check_for_new_release" = true
|
||||||
|
echo "🛈 Checking for new release…"
|
||||||
|
set latest (pure_get_latest_release_version "pure-fish/pure")
|
||||||
|
|
||||||
|
if test "v"$pure_version != $latest
|
||||||
|
set --local latest_version (_pure_set_color $pure_color_info)$latest(_pure_set_color $pure_color_normal)
|
||||||
|
echo -e "🔔 New version available!\n"
|
||||||
|
echo -e (_pure_set_color $pure_color_success)"fisher install pure-fish/pure@$latest_version\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function pure_get_latest_release_version \
|
||||||
|
--argument-names user_repo
|
||||||
|
|
||||||
|
curl \
|
||||||
|
--silent \
|
||||||
|
"https://api.github.com/repos/$user_repo/releases/latest" \
|
||||||
|
| string match --regex '"tag_name": "\K.*?(?=")'
|
||||||
|
end
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
function _pure_detect_container_by_cgroup_method \
|
||||||
|
--description "Linux method to detect container using cgroup. see https://stackoverflow.com/a/37015387/802365" \
|
||||||
|
--argument-names cgroup_namespace
|
||||||
|
set --query cgroup_namespace[1]; or set cgroup_namespace /proc/1/cgroup
|
||||||
|
|
||||||
|
string match \
|
||||||
|
--quiet \
|
||||||
|
--entire \
|
||||||
|
--regex '(lxc|docker)' <$cgroup_namespace
|
||||||
|
end
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
function _pure_detect_container_by_pid_method \
|
||||||
|
--description "Linux method to detect container using /proc. see https://stackoverflow.com/a/37015387/802365" \
|
||||||
|
--argument-names proc_sched
|
||||||
|
|
||||||
|
set --query proc_sched[1]; or set proc_sched /proc/1/sched
|
||||||
|
|
||||||
|
if test -e $proc_sched
|
||||||
|
head -n 1 $proc_sched \
|
||||||
|
| string match \
|
||||||
|
--quiet \
|
||||||
|
--invert \
|
||||||
|
--regex 'init|systemd|shepherd'
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
set SUCCESS 0
|
||||||
|
set FAILURE 1
|
||||||
|
|
||||||
|
function _pure_format_time \
|
||||||
|
--description="Format milliseconds to a human readable format" \
|
||||||
|
--argument-names \
|
||||||
|
milliseconds \
|
||||||
|
threshold \
|
||||||
|
show_subsecond
|
||||||
|
|
||||||
|
set --query show_subsecond[1]; or set show_subsecond false
|
||||||
|
test "$milliseconds" -lt 0; and return $FAILURE
|
||||||
|
test "$milliseconds" -lt (math --scale=0 "$threshold * 1000"); and echo; and return $SUCCESS
|
||||||
|
|
||||||
|
set --local time
|
||||||
|
set --local days (math --scale=0 "$milliseconds / 86400000")
|
||||||
|
test "$days" -gt 0; and set --append time (printf "%sd" $days)
|
||||||
|
set --local hours (math --scale=0 "$milliseconds / 3600000 % 24")
|
||||||
|
test "$hours" -gt 0; and set --append time (printf "%sh" $hours)
|
||||||
|
set --local minutes (math --scale=0 "$milliseconds / 60000 % 60")
|
||||||
|
test "$minutes" -gt 0; and set --append time (printf "%sm" $minutes)
|
||||||
|
set --local seconds (math --scale=0 "$milliseconds / 1000 % 60")
|
||||||
|
|
||||||
|
if test "$show_subsecond" = true
|
||||||
|
set --local threshold_as_ms (math --scale=0 "$threshold*1000")
|
||||||
|
set --local subseconds (_pure_format_time_subseconds $milliseconds $threshold_as_ms)
|
||||||
|
set --append time $seconds$subseconds's'
|
||||||
|
else
|
||||||
|
test "$seconds" -gt $threshold; and set --append time (printf "%ss" $seconds)
|
||||||
|
end
|
||||||
|
|
||||||
|
echo -e (string join ' ' $time)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function _pure_format_time_subseconds \
|
||||||
|
--description="Format duration milliseconds to a human readable format" \
|
||||||
|
--argument-names \
|
||||||
|
duration \
|
||||||
|
threshold
|
||||||
|
|
||||||
|
set --local subseconds
|
||||||
|
if test "$duration" -gt $threshold
|
||||||
|
set --local precision 2
|
||||||
|
set --local milliseconds (string sub --start -3 --length $precision $duration)
|
||||||
|
set --append subseconds '.'$milliseconds
|
||||||
|
end
|
||||||
|
echo $subseconds
|
||||||
|
end
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
function _pure_get_prompt_symbol \
|
||||||
|
--description 'Print prompt symbol' \
|
||||||
|
--argument-names exit_code
|
||||||
|
|
||||||
|
set --local prompt_symbol $pure_symbol_prompt
|
||||||
|
test "$pure_reverse_prompt_symbol_in_vimode" = true
|
||||||
|
and string match -rq "fish_(vi|hybrid)_key_bindings" $fish_key_bindings
|
||||||
|
and not contains "$fish_bind_mode" insert replace
|
||||||
|
and set prompt_symbol $pure_symbol_reverse_prompt
|
||||||
|
|
||||||
|
echo "$prompt_symbol"
|
||||||
|
end
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
function _pure_is_inside_container \
|
||||||
|
--argument-names cgroup_namespace
|
||||||
|
set --query cgroup_namespace[1]; or set cgroup_namespace /proc/1/cgroup
|
||||||
|
|
||||||
|
set --local failure 1
|
||||||
|
if set --query pure_enable_container_detection; and test "$pure_enable_container_detection" = true
|
||||||
|
set --local success 0
|
||||||
|
if test -n "$container"
|
||||||
|
return $success
|
||||||
|
end
|
||||||
|
|
||||||
|
set --local os_name (uname -s)
|
||||||
|
# echo $os_name
|
||||||
|
if test "$os_name" = Linux
|
||||||
|
if _pure_detect_container_by_cgroup_method $cgroup_namespace
|
||||||
|
return $success
|
||||||
|
end
|
||||||
|
|
||||||
|
if _pure_detect_container_by_pid_method
|
||||||
|
return $success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return $failure
|
||||||
|
end
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
function _pure_is_single_line_prompt \
|
||||||
|
--description 'Test if single line prompt feature is enabled'
|
||||||
|
set --query pure_enable_single_line_prompt
|
||||||
|
and test "$pure_enable_single_line_prompt" = true
|
||||||
|
end
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
function _pure_k8s_context
|
||||||
|
kubectl config current-context 2>/dev/null
|
||||||
|
end
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
function _pure_k8s_namespace
|
||||||
|
set namespace (kubectl config view --minify --output 'jsonpath={..namespace}' 2>/dev/null)
|
||||||
|
|
||||||
|
if test -z "$namespace"
|
||||||
|
set namespace default
|
||||||
|
end
|
||||||
|
|
||||||
|
echo $namespace
|
||||||
|
end
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
function _pure_parse_directory \
|
||||||
|
--description "Replace '$HOME' with '~'" \
|
||||||
|
--argument-names max_path_length
|
||||||
|
|
||||||
|
set --local folder (fish_prompt_pwd_dir_length=$pure_shorten_prompt_current_directory_length prompt_pwd)
|
||||||
|
|
||||||
|
if test -n "$max_path_length"
|
||||||
|
if test (string length $folder) -gt $max_path_length
|
||||||
|
# If path exceeds maximum symbol limit, force fish path formating function to use 1 character
|
||||||
|
set folder (fish_prompt_pwd_dir_length=1 prompt_pwd)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if test "$pure_truncate_prompt_current_directory_keeps" -ge 1
|
||||||
|
set folder (
|
||||||
|
string split '/' $folder \
|
||||||
|
| tail -n $pure_truncate_prompt_current_directory_keeps \
|
||||||
|
| string join '/'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
echo $folder
|
||||||
|
end
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
function _pure_parse_git_branch --description "Parse current Git branch name"
|
||||||
|
command git symbolic-ref --short HEAD 2>/dev/null;
|
||||||
|
or command git name-rev --name-only HEAD 2>/dev/null
|
||||||
|
end
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
function _pure_place_iterm2_prompt_mark
|
||||||
|
if functions -q iterm2_prompt_mark
|
||||||
|
iterm2_prompt_mark
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
function _pure_prefix_root_prompt
|
||||||
|
set --local username (id -u -n) # current user name
|
||||||
|
set --local prefix_root_prompt
|
||||||
|
|
||||||
|
if set --query pure_show_prefix_root_prompt; and test "$pure_show_prefix_root_prompt" = true -a "$username" = "root"
|
||||||
|
set --local prefix_color (_pure_set_color $pure_color_prefix_root_prompt)
|
||||||
|
set prefix_root_prompt "$prefix_color$pure_symbol_prefix_root_prompt"
|
||||||
|
end
|
||||||
|
|
||||||
|
echo "$prefix_root_prompt"
|
||||||
|
end
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
function _pure_print_prompt \
|
||||||
|
--description 'Concatenate parts single prompt string'
|
||||||
|
set --local prompt
|
||||||
|
|
||||||
|
for prompt_part in $argv
|
||||||
|
if test (_pure_string_width $prompt_part) -gt 0
|
||||||
|
set --append prompt "$prompt_part"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
echo (string trim -l $prompt)
|
||||||
|
end
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
function _pure_print_prompt_rows \
|
||||||
|
--description "Manage default vs. compact prompt"
|
||||||
|
|
||||||
|
# print current path, git branch/status, command duration
|
||||||
|
if _pure_is_single_line_prompt
|
||||||
|
echo -e -n (_pure_prompt_first_line)
|
||||||
|
else
|
||||||
|
echo -e (_pure_prompt_first_line)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
function _pure_prompt \
|
||||||
|
--description 'Print prompt symbol'
|
||||||
|
|
||||||
|
set --local last_status $argv[-1]
|
||||||
|
|
||||||
|
set --local aws_profile (_pure_prompt_aws_profile) # AWS profile name
|
||||||
|
set --local exit_status (_pure_prompt_exit_status $argv) # List of exit statuses if non-zero
|
||||||
|
set --local jobs (_pure_prompt_jobs)
|
||||||
|
set --local nixdevshell (_pure_prompt_nixdevshell) # Nix build environment indicator
|
||||||
|
set --local pure_symbol (_pure_prompt_symbol $last_status)
|
||||||
|
set --local root_prefix (_pure_prefix_root_prompt)
|
||||||
|
set --local space
|
||||||
|
set --local system_time (_pure_prompt_system_time)
|
||||||
|
set --local vimode_indicator (_pure_prompt_vimode) # vi-mode indicator
|
||||||
|
set --local virtualenv (_pure_prompt_virtualenv) # Python virtualenv name
|
||||||
|
|
||||||
|
if _pure_is_single_line_prompt
|
||||||
|
set space ' '
|
||||||
|
end
|
||||||
|
|
||||||
|
echo (\
|
||||||
|
_pure_print_prompt \
|
||||||
|
$space \
|
||||||
|
$system_time \
|
||||||
|
$root_prefix \
|
||||||
|
$jobs \
|
||||||
|
$nixdevshell \
|
||||||
|
$virtualenv \
|
||||||
|
$aws_profile \
|
||||||
|
$vimode_indicator \
|
||||||
|
$exit_status \
|
||||||
|
$pure_symbol \
|
||||||
|
)
|
||||||
|
end
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
function _pure_prompt_aws_profile --description "Display AWS profile name"
|
||||||
|
|
||||||
|
if set --query pure_enable_aws_profile;
|
||||||
|
and test "$pure_enable_aws_profile" = true
|
||||||
|
|
||||||
|
set --local aws_profile ''
|
||||||
|
set --local aws_profile_color (_pure_set_color $pure_color_aws_profile)
|
||||||
|
|
||||||
|
if test -n "$AWS_VAULT"
|
||||||
|
set aws_profile "$AWS_VAULT"
|
||||||
|
else if test -n "$AWS_PROFILE" -o "$AWS_PROFILE" != default
|
||||||
|
set aws_profile "$AWS_PROFILE"
|
||||||
|
end
|
||||||
|
|
||||||
|
if test -n $aws_profile
|
||||||
|
echo "$pure_symbol_aws_profile_prefix$aws_profile_color$aws_profile"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
function _pure_prompt_beginning \
|
||||||
|
--description 'Clear existing line content'
|
||||||
|
|
||||||
|
set --local clear_line "\r\033[K"
|
||||||
|
|
||||||
|
echo $clear_line
|
||||||
|
end
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
function _pure_prompt_command_duration
|
||||||
|
set --local command_duration
|
||||||
|
|
||||||
|
# Get command execution duration
|
||||||
|
if test -n "$CMD_DURATION"
|
||||||
|
set command_duration (_pure_format_time $CMD_DURATION $pure_threshold_command_duration $pure_show_subsecond_command_duration)
|
||||||
|
end
|
||||||
|
set --local command_duration_color (_pure_set_color $pure_color_command_duration)
|
||||||
|
|
||||||
|
echo "$command_duration_color$command_duration"
|
||||||
|
end
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
function _pure_prompt_container
|
||||||
|
if _pure_is_inside_container
|
||||||
|
echo "$pure_symbol_container_prefix"(_pure_user_at_host)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
set FAILURE 1
|
||||||
|
|
||||||
|
function _pure_prompt_current_folder --argument-names current_prompt_width
|
||||||
|
|
||||||
|
if test -z "$current_prompt_width"; return $FAILURE; end
|
||||||
|
|
||||||
|
set --local current_folder (_pure_parse_directory (math $COLUMNS - $current_prompt_width - 1))
|
||||||
|
set --local current_folder_color (_pure_set_color $pure_color_current_directory)
|
||||||
|
|
||||||
|
echo "$current_folder_color$current_folder"
|
||||||
|
end
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
function _pure_prompt_ending
|
||||||
|
echo (set_color normal)" "
|
||||||
|
end
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
function _pure_prompt_exit_status \
|
||||||
|
--description 'Print list of exit statuses if last command failed'
|
||||||
|
|
||||||
|
if set --query pure_show_exit_status;
|
||||||
|
and test "$pure_show_exit_status" = true
|
||||||
|
|
||||||
|
set --local status_color (_pure_set_color $pure_color_exit_status)
|
||||||
|
set --local command_succeed 0
|
||||||
|
set --local last_status $argv[-1]
|
||||||
|
|
||||||
|
if test $last_status -ne $command_succeed # print only if last status is non-zero
|
||||||
|
set --local status_text ""
|
||||||
|
if set --query pure_convert_exit_status_to_signal;
|
||||||
|
and test "$pure_convert_exit_status_to_signal" = true
|
||||||
|
|
||||||
|
for exit_code in $argv
|
||||||
|
if test -z "$status_text" # don't put a separator before the first code
|
||||||
|
set status_text (fish_status_to_signal $exit_code)
|
||||||
|
else
|
||||||
|
set status_text (string join "$pure_symbol_exit_status_separator" "$status_text" (fish_status_to_signal $exit_code))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
set status_text (string join "$pure_symbol_exit_status_separator" $argv)
|
||||||
|
end
|
||||||
|
|
||||||
|
echo "$status_color$pure_symbol_exit_status_prefix$status_text"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
set --global FAILURE 1
|
||||||
|
|
||||||
|
function _pure_prompt_first_line \
|
||||||
|
--description 'Print contextual information before prompt.'
|
||||||
|
|
||||||
|
set --local prompt_ssh (_pure_prompt_ssh)
|
||||||
|
set --local prompt_container (_pure_prompt_container)
|
||||||
|
set --local prompt_k8s (_pure_prompt_k8s)
|
||||||
|
set --local prompt_git (_pure_prompt_git)
|
||||||
|
set --local prompt_command_duration (_pure_prompt_command_duration)
|
||||||
|
set --local prompt (_pure_print_prompt \
|
||||||
|
$prompt_ssh \
|
||||||
|
$prompt_container \
|
||||||
|
$prompt_k8s \
|
||||||
|
$prompt_git \
|
||||||
|
$prompt_command_duration
|
||||||
|
)
|
||||||
|
set --local prompt_width (_pure_string_width $prompt)
|
||||||
|
set --local current_folder (_pure_prompt_current_folder $prompt_width)
|
||||||
|
|
||||||
|
set --local prompt_components
|
||||||
|
if set --query pure_begin_prompt_with_current_directory; and test "$pure_begin_prompt_with_current_directory" = true
|
||||||
|
set prompt_components \
|
||||||
|
$current_folder \
|
||||||
|
$prompt_git \
|
||||||
|
$prompt_ssh \
|
||||||
|
$prompt_container \
|
||||||
|
$prompt_k8s \
|
||||||
|
$prompt_command_duration
|
||||||
|
else
|
||||||
|
set prompt_components \
|
||||||
|
$prompt_ssh \
|
||||||
|
$prompt_container \
|
||||||
|
$prompt_k8s \
|
||||||
|
$current_folder \
|
||||||
|
$prompt_git \
|
||||||
|
$prompt_command_duration
|
||||||
|
end
|
||||||
|
|
||||||
|
echo (_pure_print_prompt $prompt_components)
|
||||||
|
end
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
function _pure_prompt_git \
|
||||||
|
--description 'Print git repository information: branch name, dirty, upstream ahead/behind'
|
||||||
|
|
||||||
|
set ABORT_FEATURE 2
|
||||||
|
|
||||||
|
if set --query pure_enable_git; and test "$pure_enable_git" != true
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if not type -q --no-functions git # skip git-related features when `git` is not available
|
||||||
|
return $ABORT_FEATURE
|
||||||
|
end
|
||||||
|
|
||||||
|
set --local is_git_repository (command git rev-parse --is-inside-work-tree 2>/dev/null)
|
||||||
|
|
||||||
|
if test -n "$is_git_repository"
|
||||||
|
set --local git_prompt (_pure_prompt_git_branch)(_pure_prompt_git_dirty)(_pure_prompt_git_stash)
|
||||||
|
set --local git_pending_commits (_pure_prompt_git_pending_commits)
|
||||||
|
|
||||||
|
if test (_pure_string_width $git_pending_commits) -ne 0
|
||||||
|
set --append git_prompt $git_pending_commits
|
||||||
|
end
|
||||||
|
|
||||||
|
echo $git_prompt
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
function _pure_prompt_git_branch
|
||||||
|
set --local git_branch (_pure_parse_git_branch) # current git branch
|
||||||
|
set --local git_branch_color (_pure_set_color $pure_color_git_branch)
|
||||||
|
|
||||||
|
echo "$git_branch_color$git_branch"
|
||||||
|
end
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
function _pure_prompt_git_dirty
|
||||||
|
set --local git_dirty_symbol
|
||||||
|
set --local git_dirty_color
|
||||||
|
|
||||||
|
set --local is_git_dirty (
|
||||||
|
# Single git status call that respects status.showUntrackedFiles config.
|
||||||
|
# Set `git config status.showUntrackedFiles no` in large repos to skip
|
||||||
|
# the expensive untracked-files scan.
|
||||||
|
test -n "$(command git status --porcelain --ignore-submodules 2>/dev/null)"
|
||||||
|
and echo "true"
|
||||||
|
)
|
||||||
|
if test -n "$is_git_dirty" # untracked or un-commited files
|
||||||
|
set git_dirty_symbol "$pure_symbol_git_dirty"
|
||||||
|
set git_dirty_color (_pure_set_color $pure_color_git_dirty)
|
||||||
|
end
|
||||||
|
|
||||||
|
echo "$git_dirty_color$git_dirty_symbol"
|
||||||
|
end
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
function _pure_prompt_git_pending_commits
|
||||||
|
set --local git_unpushed_commits
|
||||||
|
set --local git_unpulled_commits
|
||||||
|
|
||||||
|
set --local has_upstream (command git rev-parse --abbrev-ref '@{upstream}' 2>/dev/null)
|
||||||
|
if test -n "$has_upstream" # check there is an upstream repo configured
|
||||||
|
and test "$has_upstream" != '@{upstream}' # Fixed #179, dont check the empty repo
|
||||||
|
command git rev-list --left-right --count 'HEAD...@{upstream}' \
|
||||||
|
| read --local --array git_status
|
||||||
|
set --local commit_to_push $git_status[1]
|
||||||
|
set --local commit_to_pull $git_status[2]
|
||||||
|
|
||||||
|
if test "$commit_to_push" -gt 0 # upstream is behind local repo
|
||||||
|
set --local git_unpushed_commits_color \
|
||||||
|
(_pure_set_color $pure_color_git_unpushed_commits)
|
||||||
|
set git_unpushed_commits "$git_unpushed_commits_color$pure_symbol_git_unpushed_commits"
|
||||||
|
if test "$pure_show_numbered_git_indicator" = true
|
||||||
|
set git_unpushed_commits "$git_unpushed_commits$commit_to_push"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if test "$commit_to_pull" -gt 0 # upstream is ahead of local repo
|
||||||
|
set --local git_unpulled_commits_color \
|
||||||
|
(_pure_set_color $pure_color_git_unpulled_commits)
|
||||||
|
set git_unpulled_commits "$git_unpulled_commits_color$pure_symbol_git_unpulled_commits"
|
||||||
|
if test "$pure_show_numbered_git_indicator" = true
|
||||||
|
set git_unpulled_commits "$git_unpulled_commits$commit_to_pull"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
echo "$git_unpushed_commits$git_unpulled_commits"
|
||||||
|
end
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
function _pure_prompt_git_stash
|
||||||
|
set --local git_stash_symbol
|
||||||
|
set --local git_stash_color
|
||||||
|
set --local git_stash_number
|
||||||
|
|
||||||
|
set --local git_stash_count (
|
||||||
|
command git rev-list --walk-reflogs --count refs/stash 2> /dev/null
|
||||||
|
or echo "0"
|
||||||
|
)
|
||||||
|
if test "$git_stash_count" -gt 0 # has git stash
|
||||||
|
set git_stash_symbol " $pure_symbol_git_stash"
|
||||||
|
set git_stash_color (_pure_set_color $pure_color_git_stash)
|
||||||
|
if test "$pure_show_numbered_git_indicator" = true
|
||||||
|
set git_stash_number "$git_stash_count"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
echo "$git_stash_color$git_stash_symbol$git_stash_number"
|
||||||
|
end
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
function _pure_prompt_jobs --description "Display number of running jobs"
|
||||||
|
if set --query pure_show_jobs; and test "$pure_show_jobs" = true
|
||||||
|
set --local njobs (count (jobs -p))
|
||||||
|
set --local jobs_color (_pure_set_color $pure_color_jobs)
|
||||||
|
if test "$njobs" -gt 0
|
||||||
|
echo "$jobs_color"[$njobs]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
function _pure_prompt_k8s
|
||||||
|
if set --query pure_enable_k8s;
|
||||||
|
and test "$pure_enable_k8s" = true;
|
||||||
|
and _pure_check_availability pure_enable_k8s kubectl
|
||||||
|
and test -n (_pure_k8s_context) # todo: use $(cmd) syntax when Fish 3.3.1 is dropped
|
||||||
|
|
||||||
|
set --local context (_pure_set_color $pure_color_k8s_context)(_pure_k8s_context)
|
||||||
|
|
||||||
|
if test -n "$context"
|
||||||
|
set --local symbol (_pure_set_color $pure_color_k8s_prefix)$pure_symbol_k8s_prefix
|
||||||
|
set --local namespace (_pure_set_color $pure_color_k8s_namespace)(_pure_k8s_namespace)
|
||||||
|
|
||||||
|
echo "$symbol $context/$namespace"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
function _pure_prompt_new_line \
|
||||||
|
--description "Do not add a line break to a brand new session" \
|
||||||
|
--on-event fish_prompt
|
||||||
|
|
||||||
|
set --local new_line ''
|
||||||
|
if not _pure_is_single_line_prompt; and test "$_pure_fresh_session" = false
|
||||||
|
set new_line "\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
echo -e -n (_pure_prompt_beginning)"$new_line"
|
||||||
|
end
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
function _pure_prompt_nixdevshell \
|
||||||
|
--description "Indicate if nix develop shell is activated"
|
||||||
|
|
||||||
|
if set --query pure_enable_nixdevshell;
|
||||||
|
and test "$pure_enable_nixdevshell" = true;
|
||||||
|
and test -n "$IN_NIX_SHELL"
|
||||||
|
|
||||||
|
set --local prefix (_pure_set_color $pure_color_nixdevshell_prefix)$pure_symbol_nixdevshell_prefix
|
||||||
|
set --local symbol (_pure_set_color $pure_color_nixdevshell_status)$IN_NIX_SHELL
|
||||||
|
|
||||||
|
echo "$prefix$symbol"
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
function _pure_prompt_ssh
|
||||||
|
if test "$SSH_CONNECTION" != ""
|
||||||
|
echo "$pure_symbol_ssh_prefix"(_pure_user_at_host)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
function _pure_prompt_symbol \
|
||||||
|
--description 'Print prompt symbol' \
|
||||||
|
--argument-names exit_code
|
||||||
|
|
||||||
|
set --local prompt_symbol (_pure_get_prompt_symbol)
|
||||||
|
set --local symbol_color_success (_pure_set_color $pure_color_prompt_on_success)
|
||||||
|
set --local symbol_color_error (_pure_set_color $pure_color_prompt_on_error)
|
||||||
|
set --local command_succeed 0
|
||||||
|
|
||||||
|
set --local symbol_color $symbol_color_success # default pure symbol color
|
||||||
|
if set --query exit_code; and test "$exit_code" -ne $command_succeed
|
||||||
|
set symbol_color $symbol_color_error # different pure symbol color when previous command failed
|
||||||
|
|
||||||
|
if set --query pure_separate_prompt_on_error; and test "$pure_separate_prompt_on_error" = true
|
||||||
|
set symbol_color "$symbol_color_error$prompt_symbol$symbol_color_success"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
echo "$symbol_color$prompt_symbol"
|
||||||
|
end
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
function _pure_prompt_system_time --description "Display system time"
|
||||||
|
if set --query pure_show_system_time; and test "$pure_show_system_time" = true
|
||||||
|
set --local time_color (_pure_set_color $pure_color_system_time)
|
||||||
|
echo "$time_color"(date $pure_system_time_format)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
function _pure_prompt_transient \
|
||||||
|
--description 'Print simplified transient prompt for scrollback history' \
|
||||||
|
--argument-names exit_code
|
||||||
|
|
||||||
|
set --local pure_symbol (_pure_prompt_symbol $exit_code)
|
||||||
|
|
||||||
|
echo (\
|
||||||
|
_pure_print_prompt \
|
||||||
|
$pure_symbol \
|
||||||
|
)
|
||||||
|
end
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
function _pure_prompt_vimode
|
||||||
|
if set --query pure_reverse_prompt_symbol_in_vimode;
|
||||||
|
and test "$pure_reverse_prompt_symbol_in_vimode" = false
|
||||||
|
echo (fish_default_mode_prompt)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
function _pure_prompt_virtualenv --description "Display virtualenv directory"
|
||||||
|
|
||||||
|
if set --query pure_enable_virtualenv;
|
||||||
|
and test "$pure_enable_virtualenv" = true
|
||||||
|
|
||||||
|
set --local virtualenv ''
|
||||||
|
set --local virtualenv_color (_pure_set_color $pure_color_virtualenv)
|
||||||
|
if test -n "$VIRTUAL_ENV_PROMPT"
|
||||||
|
set virtualenv "$VIRTUAL_ENV_PROMPT"
|
||||||
|
else if test -n "$VIRTUAL_ENV"
|
||||||
|
set virtualenv (basename "$VIRTUAL_ENV")
|
||||||
|
else if test -n "$CONDA_DEFAULT_ENV"
|
||||||
|
set virtualenv (basename "$CONDA_DEFAULT_ENV")
|
||||||
|
end
|
||||||
|
|
||||||
|
if test -n $virtualenv
|
||||||
|
echo "$pure_symbol_virtualenv_prefix$virtualenv_color$virtualenv"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
function _pure_set_color \
|
||||||
|
--description 'Set color' \
|
||||||
|
--argument-names var
|
||||||
|
|
||||||
|
set --local color $var
|
||||||
|
# Backwards compatibility for colors defined as control sequencies instead of fish colors
|
||||||
|
if not string match --quiet --all --regex '\e\[[^m]*m' $color[1]
|
||||||
|
and set -q $color
|
||||||
|
set color $$var
|
||||||
|
end
|
||||||
|
|
||||||
|
set --local result $color
|
||||||
|
if not string match --quiet --all --regex '\e\[[^m]*m' $result[1]
|
||||||
|
and not test -z $result[1]
|
||||||
|
set result (set_color $color)
|
||||||
|
end
|
||||||
|
|
||||||
|
echo "$result"
|
||||||
|
end
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
function _pure_set_default \
|
||||||
|
--description 'Set default value for configuration variable' \
|
||||||
|
--argument-names var default
|
||||||
|
|
||||||
|
set is_available_universally (not set --query --universal $var; or test -z $$var; echo $status)
|
||||||
|
set is_available_globally (not set --query --global $var; or test -z $$var; echo $status)
|
||||||
|
|
||||||
|
if test "$is_available_universally" -eq 0 -a $is_available_globally -eq 0
|
||||||
|
set --universal $var "$default"
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
function _pure_string_width \
|
||||||
|
--description 'returns raw string length, i.e. ignore ANSI-color' \
|
||||||
|
--argument-names prompt
|
||||||
|
|
||||||
|
set --local empty ''
|
||||||
|
set --local raw_prompt (string replace --all --regex '\e\[[^m]*m' $empty -- $prompt)
|
||||||
|
|
||||||
|
string length -- $raw_prompt
|
||||||
|
end
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
function _pure_user_at_host
|
||||||
|
set --local username (id -u -n) # current user name
|
||||||
|
set --local at_sign "@"
|
||||||
|
set --local at_sign_color (_pure_set_color $pure_color_at_sign)
|
||||||
|
set --local hostname_color (_pure_set_color $pure_color_hostname)
|
||||||
|
|
||||||
|
set --local username_color (_pure_set_color $pure_color_username_normal) # default color
|
||||||
|
if test "$username" = root
|
||||||
|
set username_color (_pure_set_color $pure_color_username_root) # different color for root
|
||||||
|
end
|
||||||
|
|
||||||
|
echo "$username_color$username$at_sign_color$at_sign$hostname_color$hostname"
|
||||||
|
end
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
function fish_mode_prompt
|
||||||
|
end
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# a called to `_pure_prompt_new_line` is triggered by an event
|
||||||
|
function fish_prompt
|
||||||
|
set --local exit_codes $pipestatus # save previous exit codes
|
||||||
|
|
||||||
|
# Handle transient prompt (Fish 4.1.0+)
|
||||||
|
# When --final-rendering is passed, show simplified prompt for scrollback
|
||||||
|
if contains -- --final-rendering $argv
|
||||||
|
set --local last_status $exit_codes[-1]
|
||||||
|
|
||||||
|
echo -e -n (_pure_prompt_transient $last_status)
|
||||||
|
echo -e -n (_pure_prompt_ending)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
_pure_print_prompt_rows # manage default vs. compact prompt
|
||||||
|
_pure_place_iterm2_prompt_mark # place iTerm shell integration mark
|
||||||
|
echo -e -n (_pure_prompt $exit_codes) # print prompt
|
||||||
|
echo -e -n (_pure_prompt_ending) # reset colors and end prompt
|
||||||
|
|
||||||
|
set _pure_fresh_session false
|
||||||
|
end
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
function fish_title \
|
||||||
|
--description "Set title to current folder and shell name" \
|
||||||
|
--argument-names last_command
|
||||||
|
|
||||||
|
set --local current_folder (fish_prompt_pwd_dir_length=$pure_shorten_window_title_current_directory_length prompt_pwd)
|
||||||
|
set --local current_command (status current-command 2>/dev/null; or echo $_)[1] # we use index to ignore extraneous item, see #360
|
||||||
|
|
||||||
|
set --local prompt "$current_folder: $last_command $pure_symbol_title_bar_separator $current_command"
|
||||||
|
|
||||||
|
if test -z "$last_command"
|
||||||
|
set prompt "$current_folder $pure_symbol_title_bar_separator $current_command"
|
||||||
|
end
|
||||||
|
|
||||||
|
echo $prompt
|
||||||
|
end
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
function fish_user_key_bindings
|
||||||
|
fzf_key_bindings
|
||||||
|
end
|
||||||
@@ -0,0 +1,251 @@
|
|||||||
|
function fisher --argument-names cmd --description "A plugin manager for Fish"
|
||||||
|
set --query fisher_path || set --local fisher_path $__fish_config_dir
|
||||||
|
set --local fisher_version 4.4.8
|
||||||
|
set --local fish_plugins $__fish_config_dir/fish_plugins
|
||||||
|
|
||||||
|
switch "$cmd"
|
||||||
|
case -v --version
|
||||||
|
echo "fisher, version $fisher_version"
|
||||||
|
case "" -h --help
|
||||||
|
echo "Usage: fisher install <plugins...> Install plugins"
|
||||||
|
echo " fisher remove <plugins...> Remove installed plugins"
|
||||||
|
echo " fisher uninstall <plugins...> Remove installed plugins (alias)"
|
||||||
|
echo " fisher update <plugins...> Update installed plugins"
|
||||||
|
echo " fisher update Update all installed plugins"
|
||||||
|
echo " fisher list [<regex>] List installed plugins matching regex"
|
||||||
|
echo "Options:"
|
||||||
|
echo " -v, --version Print version"
|
||||||
|
echo " -h, --help Print this help message"
|
||||||
|
echo "Variables:"
|
||||||
|
echo " \$fisher_path Plugin installation path. Default: $__fish_config_dir" | string replace --regex -- $HOME \~
|
||||||
|
case ls list
|
||||||
|
string match --entire --regex -- "$argv[2]" $_fisher_plugins
|
||||||
|
case install update remove uninstall
|
||||||
|
isatty || read --local --null --array stdin && set --append argv $stdin
|
||||||
|
|
||||||
|
test "$cmd" = uninstall && set cmd remove
|
||||||
|
|
||||||
|
set --local install_plugins
|
||||||
|
set --local update_plugins
|
||||||
|
set --local remove_plugins
|
||||||
|
set --local arg_plugins $argv[2..-1]
|
||||||
|
set --local old_plugins $_fisher_plugins
|
||||||
|
set --local new_plugins
|
||||||
|
|
||||||
|
test -e $fish_plugins && set --local file_plugins (string match --regex -- '^[^\s]+$' <$fish_plugins | string replace -- \~ ~)
|
||||||
|
|
||||||
|
if ! set --query argv[2]
|
||||||
|
if test "$cmd" != update
|
||||||
|
echo "fisher: Not enough arguments for command: \"$cmd\"" >&2 && return 1
|
||||||
|
else if ! set --query file_plugins
|
||||||
|
echo "fisher: \"$fish_plugins\" file not found: \"$cmd\"" >&2 && return 1
|
||||||
|
end
|
||||||
|
set arg_plugins $file_plugins
|
||||||
|
else if test "$cmd" = install && ! set --query old_plugins[1]
|
||||||
|
set --append arg_plugins $file_plugins
|
||||||
|
end
|
||||||
|
|
||||||
|
for plugin in $arg_plugins
|
||||||
|
set plugin (test -e "$plugin" && realpath $plugin || string lower -- $plugin)
|
||||||
|
contains -- "$plugin" $new_plugins || set --append new_plugins $plugin
|
||||||
|
end
|
||||||
|
|
||||||
|
if set --query argv[2]
|
||||||
|
for plugin in $new_plugins
|
||||||
|
if contains -- "$plugin" $old_plugins
|
||||||
|
test "$cmd" = remove &&
|
||||||
|
set --append remove_plugins $plugin ||
|
||||||
|
set --append update_plugins $plugin
|
||||||
|
else if test "$cmd" = install
|
||||||
|
set --append install_plugins $plugin
|
||||||
|
else
|
||||||
|
echo "fisher: Plugin not installed: \"$plugin\"" >&2 && return 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for plugin in $new_plugins
|
||||||
|
contains -- "$plugin" $old_plugins &&
|
||||||
|
set --append update_plugins $plugin ||
|
||||||
|
set --append install_plugins $plugin
|
||||||
|
end
|
||||||
|
|
||||||
|
for plugin in $old_plugins
|
||||||
|
contains -- "$plugin" $new_plugins || set --append remove_plugins $plugin
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
set --local pid_list
|
||||||
|
set --local source_plugins
|
||||||
|
set --local fetch_plugins $update_plugins $install_plugins
|
||||||
|
set --local fish_path (status fish-path)
|
||||||
|
|
||||||
|
echo (set_color --bold)fisher $cmd version $fisher_version(set_color normal)
|
||||||
|
|
||||||
|
for plugin in $fetch_plugins
|
||||||
|
set --local source (command mktemp -d)
|
||||||
|
set --append source_plugins $source
|
||||||
|
|
||||||
|
command mkdir -p $source/{completions,conf.d,themes,functions}
|
||||||
|
|
||||||
|
$fish_path --command "
|
||||||
|
if test -e $plugin
|
||||||
|
command cp -Rf $plugin/* $source
|
||||||
|
else
|
||||||
|
set resp (command mktemp)
|
||||||
|
set temp (command mktemp -d)
|
||||||
|
set repo (string split -- \@ $plugin) || set repo[2] HEAD
|
||||||
|
|
||||||
|
if set path (string replace --regex -- '^(https://)?gitlab.com/' '' \$repo[1])
|
||||||
|
set name (string split -- / \$path)[-1]
|
||||||
|
set url https://gitlab.com/\$path/-/archive/\$repo[2]/\$name-\$repo[2].tar.gz
|
||||||
|
else
|
||||||
|
set url https://api.github.com/repos/\$repo[1]/tarball/\$repo[2]
|
||||||
|
end
|
||||||
|
|
||||||
|
echo Fetching (set_color --underline)\$url(set_color normal)
|
||||||
|
|
||||||
|
set http (command curl -q --silent -L -o \$resp -w %{http_code} \$url)
|
||||||
|
|
||||||
|
if test \"\$http\" = 200 && command tar -xzC \$temp -f \$resp 2>/dev/null
|
||||||
|
command cp -Rf \$temp/*/* $source
|
||||||
|
else if test \"\$http\" = 403
|
||||||
|
echo fisher: GitHub API rate limit exceeded \(HTTP 403\) >&2
|
||||||
|
command rm -rf $source
|
||||||
|
else
|
||||||
|
echo fisher: Invalid plugin name or host unavailable: \\\"$plugin\\\" >&2
|
||||||
|
command rm -rf $source
|
||||||
|
end
|
||||||
|
|
||||||
|
command rm -rf \$temp
|
||||||
|
end
|
||||||
|
|
||||||
|
set files $source/* && string match --quiet --regex -- .+\.fish\\\$ \$files
|
||||||
|
" &
|
||||||
|
|
||||||
|
set --append pid_list (jobs --last --pid)
|
||||||
|
end
|
||||||
|
|
||||||
|
wait $pid_list 2>/dev/null
|
||||||
|
|
||||||
|
for plugin in $fetch_plugins
|
||||||
|
if set --local source $source_plugins[(contains --index -- "$plugin" $fetch_plugins)] && test ! -e $source
|
||||||
|
if set --local index (contains --index -- "$plugin" $install_plugins)
|
||||||
|
set --erase install_plugins[$index]
|
||||||
|
else
|
||||||
|
set --erase update_plugins[(contains --index -- "$plugin" $update_plugins)]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for plugin in $update_plugins $remove_plugins
|
||||||
|
if set --local index (contains --index -- "$plugin" $_fisher_plugins)
|
||||||
|
set --local plugin_files_var _fisher_(string escape --style=var -- $plugin)_files
|
||||||
|
|
||||||
|
if contains -- "$plugin" $remove_plugins
|
||||||
|
for name in (string replace --filter --regex -- '.+/conf\.d/([^/]+)\.fish$' '$1' $$plugin_files_var)
|
||||||
|
emit {$name}_uninstall
|
||||||
|
end
|
||||||
|
printf "%s\n" Removing\ (set_color red --bold)$plugin(set_color normal) " "$$plugin_files_var | string replace -- \~ ~
|
||||||
|
set --erase _fisher_plugins[$index]
|
||||||
|
end
|
||||||
|
|
||||||
|
command rm -rf (string replace -- \~ ~ $$plugin_files_var)
|
||||||
|
|
||||||
|
functions --erase (string replace --filter --regex -- '.+/functions/([^/]+)\.fish$' '$1' $$plugin_files_var)
|
||||||
|
|
||||||
|
for name in (string replace --filter --regex -- '.+/completions/([^/]+)\.fish$' '$1' $$plugin_files_var)
|
||||||
|
complete --erase --command $name
|
||||||
|
end
|
||||||
|
|
||||||
|
set --erase $plugin_files_var
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if set --query update_plugins[1] || set --query install_plugins[1]
|
||||||
|
command mkdir -p $fisher_path/{functions,themes,conf.d,completions}
|
||||||
|
end
|
||||||
|
|
||||||
|
for plugin in $update_plugins $install_plugins
|
||||||
|
set --local source $source_plugins[(contains --index -- "$plugin" $fetch_plugins)]
|
||||||
|
set --local files $source/{functions,themes,conf.d,completions}/*
|
||||||
|
|
||||||
|
if set --local index (contains --index -- $plugin $install_plugins)
|
||||||
|
set --local user_files $fisher_path/{functions,themes,conf.d,completions}/*
|
||||||
|
set --local conflict_files
|
||||||
|
|
||||||
|
for file in (string replace -- $source/ $fisher_path/ $files)
|
||||||
|
contains -- $file $user_files && set --append conflict_files $file
|
||||||
|
end
|
||||||
|
|
||||||
|
if set --query conflict_files[1] && set --erase install_plugins[$index]
|
||||||
|
echo -s "fisher: Cannot install \"$plugin\": please remove or move conflicting files first:" \n" "$conflict_files >&2
|
||||||
|
continue
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for file in (string replace -- $source/ "" $files)
|
||||||
|
command cp -RLf $source/$file $fisher_path/$file
|
||||||
|
end
|
||||||
|
|
||||||
|
set --local plugin_files_var _fisher_(string escape --style=var -- $plugin)_files
|
||||||
|
|
||||||
|
set --query files[1] && set --universal $plugin_files_var (string replace -- $source $fisher_path $files | string replace -- ~ \~)
|
||||||
|
|
||||||
|
contains -- $plugin $_fisher_plugins || set --universal --append _fisher_plugins $plugin
|
||||||
|
contains -- $plugin $install_plugins && set --local event install || set --local event update
|
||||||
|
|
||||||
|
printf "%s\n" Installing\ (set_color --bold)$plugin(set_color normal) " "$$plugin_files_var | string replace -- \~ ~
|
||||||
|
|
||||||
|
for file in (string match --regex -- '.+/[^/]+\.fish$' $$plugin_files_var | string replace -- \~ ~)
|
||||||
|
source $file
|
||||||
|
if set --local name (string replace --regex -- '.+conf\.d/([^/]+)\.fish$' '$1' $file)
|
||||||
|
emit {$name}_$event
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
command rm -rf $source_plugins
|
||||||
|
|
||||||
|
if set --query _fisher_plugins[1]
|
||||||
|
set --local commit_plugins
|
||||||
|
|
||||||
|
for plugin in $file_plugins
|
||||||
|
contains -- (string lower -- $plugin) (string lower -- $_fisher_plugins) && set --append commit_plugins $plugin
|
||||||
|
end
|
||||||
|
|
||||||
|
for plugin in $_fisher_plugins
|
||||||
|
contains -- (string lower -- $plugin) (string lower -- $commit_plugins) || set --append commit_plugins $plugin
|
||||||
|
end
|
||||||
|
|
||||||
|
string replace --regex -- $HOME \~ $commit_plugins >$fish_plugins
|
||||||
|
else
|
||||||
|
set --erase _fisher_plugins
|
||||||
|
command rm -f $fish_plugins
|
||||||
|
end
|
||||||
|
|
||||||
|
set --local total (count $install_plugins) (count $update_plugins) (count $remove_plugins)
|
||||||
|
|
||||||
|
test "$total" != "0 0 0" && echo (string join ", " (
|
||||||
|
test $total[1] = 0 || echo "Installed $total[1]") (
|
||||||
|
test $total[2] = 0 || echo "Updated $total[2]") (
|
||||||
|
test $total[3] = 0 || echo "Removed $total[3]")
|
||||||
|
) plugin/s
|
||||||
|
case \*
|
||||||
|
echo "fisher: Unknown command: \"$cmd\"" >&2 && return 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if ! set --query _fisher_upgraded_to_4_4
|
||||||
|
set --universal _fisher_upgraded_to_4_4
|
||||||
|
if functions --query _fisher_list
|
||||||
|
set --query XDG_DATA_HOME[1] || set --local XDG_DATA_HOME ~/.local/share
|
||||||
|
command rm -rf $XDG_DATA_HOME/fisher
|
||||||
|
functions --erase _fisher_{list,plugin_parse}
|
||||||
|
fisher update >/dev/null 2>/dev/null
|
||||||
|
else
|
||||||
|
for var in (set --names | string match --entire --regex '^_fisher_.+_files$')
|
||||||
|
set $var (string replace -- ~ \~ $$var)
|
||||||
|
end
|
||||||
|
functions --erase _fisher_fish_postexec
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
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
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# ~/.config/fish/functions/fzf.fish
|
||||||
|
function fzf --wraps="fzf"
|
||||||
|
# Paste contents of preferred variant here
|
||||||
|
set -Ux FZF_DEFAULT_OPTS "
|
||||||
|
--color=fg:#797593,bg:#faf4ed,hl:#d7827e
|
||||||
|
--color=fg+:#575279,bg+:#f2e9e1,hl+:#d7827e
|
||||||
|
--color=border:#dfdad9,header:#286983,gutter:#faf4ed
|
||||||
|
--color=spinner:#ea9d34,info:#56949f
|
||||||
|
--color=pointer:#907aa9,marker:#b4637a,prompt:#797593
|
||||||
|
--color=bg:-1,bg+:-1"
|
||||||
|
|
||||||
|
command fzf
|
||||||
|
end
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# ~/.config/fish/functions/pacman.fish
|
||||||
|
#
|
||||||
|
function addpkg
|
||||||
|
# Browse through pacman package and install selection
|
||||||
|
pacman -Slq | fzf --multi --preview 'pacman -Si {1}' | xargs -ro sudo pacman -S
|
||||||
|
end
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
function pathclean --description "Clean up PATH variable"
|
||||||
|
set PATH (printf "%s" "$PATH" | awk -v RS=':' '!a[$1]++ { if (NR > 1) printf RS; printf $1 }')
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user