Add new #fishshell features
This commit is contained in:
@ -20,13 +20,16 @@
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
set -g __done_version 1.8.0
|
||||
set -g __done_version 1.10.0
|
||||
|
||||
function __done_get_focused_window_id
|
||||
if type -q lsappinfo
|
||||
lsappinfo info -only bundleID (lsappinfo front) | cut -d '"' -f4
|
||||
else if test -n "$SWAYSOCK"
|
||||
and type -q jq
|
||||
swaymsg --type get_tree | jq '.. | objects | select(.focused == true) | .id'
|
||||
else if type -q xprop
|
||||
and test $DISPLAY
|
||||
and test -n "$DISPLAY"
|
||||
xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2
|
||||
end
|
||||
end
|
||||
@ -55,11 +58,12 @@ end
|
||||
|
||||
# verify that the system has graphical capabilites before initializing
|
||||
if test -z "$SSH_CLIENT" # not over ssh
|
||||
and test -n __done_get_focused_window_id # is able to get window id
|
||||
and count (__done_get_focused_window_id) > /dev/null # is able to get window id
|
||||
|
||||
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)'
|
||||
set -q __done_notify_sound; or set -g __done_notify_sound 0
|
||||
|
||||
function __done_started --on-event fish_preexec
|
||||
set __done_initial_window_id (__done_get_focused_window_id)
|
||||
@ -84,23 +88,27 @@ and test -n __done_get_focused_window_id # is able to get window id
|
||||
set -l message "$wd/ $history[1]"
|
||||
set -l sender $__done_initial_window_id
|
||||
|
||||
# workarout terminal notifier bug when sending notifications from inside tmux
|
||||
# https://github.com/julienXX/terminal-notifier/issues/216
|
||||
if test $TMUX
|
||||
set sender "tmux"
|
||||
end
|
||||
|
||||
if test $exit_status -ne 0
|
||||
set title "Failed ($exit_status) after $humanized_duration"
|
||||
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 type -q terminal-notifier # https://github.com/julienXX/terminal-notifier
|
||||
terminal-notifier -message "$message" -title "$title" -sender "$sender" -activate "$__done_initial_window_id"
|
||||
if test "$__done_notify_sound" -eq 1
|
||||
terminal-notifier -message "$message" -title "$title" -sender "$__done_initial_window_id" -sound default
|
||||
else
|
||||
terminal-notifier -message "$message" -title "$title" -sender "$__done_initial_window_id"
|
||||
end
|
||||
|
||||
else if type -q osascript # AppleScript
|
||||
osascript -e "display notification \"$message\" with title \"$title\""
|
||||
if test "$__done_notify_sound" -eq 1
|
||||
echo -e "\a" # bell sound
|
||||
end
|
||||
|
||||
else if type -q notify-send # Linux notify-send
|
||||
set -l urgency
|
||||
@ -108,6 +116,9 @@ and test -n __done_get_focused_window_id # is able to get window id
|
||||
set urgency "--urgency=critical"
|
||||
end
|
||||
notify-send $urgency --icon=terminal --app-name=fish "$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
|
||||
@ -115,6 +126,9 @@ and test -n __done_get_focused_window_id # is able to get window id
|
||||
set urgency "--urgency=critical"
|
||||
end
|
||||
notify-desktop $urgency --icon=terminal --app-name=fish "$title" "$message"
|
||||
if test "$__done_notify_sound" -eq 1
|
||||
echo -e "\a" # bell sound
|
||||
end
|
||||
|
||||
else # anything else
|
||||
echo -e "\a" # bell sound
|
||||
|
||||
@ -15,20 +15,20 @@ if test "$FZF_LEGACY_KEYBINDINGS" -eq 1
|
||||
bind -M insert \co '__fzf_open --editor'
|
||||
end
|
||||
else
|
||||
bind \cf '__fzf_find_file'
|
||||
bind \co '__fzf_find_file'
|
||||
bind \cr '__fzf_reverse_isearch'
|
||||
bind \eo '__fzf_cd'
|
||||
bind \eO '__fzf_cd --hidden'
|
||||
bind \cg '__fzf_open'
|
||||
bind \co '__fzf_open --editor'
|
||||
bind \ec '__fzf_cd'
|
||||
bind \eC '__fzf_cd --hidden'
|
||||
bind \eO '__fzf_open'
|
||||
bind \eo '__fzf_open --editor'
|
||||
|
||||
if bind -M insert >/dev/null 2>/dev/null
|
||||
bind -M insert \cf '__fzf_find_file'
|
||||
bind -M insert \co '__fzf_find_file'
|
||||
bind -M insert \cr '__fzf_reverse_isearch'
|
||||
bind -M insert \eo '__fzf_cd'
|
||||
bind -M insert \eO '__fzf_cd --hidden'
|
||||
bind -M insert \cg '__fzf_open'
|
||||
bind -M insert \co '__fzf_open --editor'
|
||||
bind -M insert \ec '__fzf_cd'
|
||||
bind -M insert \eC '__fzf_cd --hidden'
|
||||
bind -M insert \eO '__fzf_open'
|
||||
bind -M insert \eo '__fzf_open --editor'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
set --universal pure_version 2.1.8 # used for bug report
|
||||
set --universal pure_version 2.3.1 # used for bug report
|
||||
|
||||
# Base colors
|
||||
_pure_set_default pure_color_primary (set_color blue)
|
||||
@ -21,6 +21,7 @@ _pure_set_default pure_color_prompt_on_success $pure_color_success
|
||||
_pure_set_default pure_color_current_directory $pure_color_primary
|
||||
|
||||
# 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 "*"
|
||||
@ -52,10 +53,6 @@ _pure_set_default pure_separate_prompt_on_error false
|
||||
_pure_set_default pure_threshold_command_duration 5
|
||||
_pure_set_default pure_color_command_duration $pure_color_warning
|
||||
|
||||
# Right Prompt variables
|
||||
_pure_set_default pure_right_prompt ""
|
||||
_pure_set_default pure_color_right_prompt $pure_color_normal
|
||||
|
||||
# VI mode indicator
|
||||
# true (default): indicate a non-insert mode by reversing the prompt symbol (❮)
|
||||
# false: indicate vi mode with [I], [N], [V]
|
||||
|
||||
@ -6,3 +6,5 @@ fzf_key_bindings
|
||||
set -gx EDITOR vi
|
||||
set -gx XDG_RUNTIME_DIR /run/user/(id -u)
|
||||
eval (python -m virtualfish)
|
||||
|
||||
starship init fish | source
|
||||
|
||||
@ -42,4 +42,4 @@ SETUVAR fish_pager_color_description:B3A06D\x1eyellow
|
||||
SETUVAR fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
|
||||
SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan
|
||||
SETUVAR fish_user_paths:/Users/colinpowell/\x2efzf/bin
|
||||
SETUVAR pure_version:2\x2e1\x2e8
|
||||
SETUVAR pure_version:2\x2e3\x2e1
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
function _pure_place_iterm2_prompt_mark
|
||||
if functions -q iterm2_prompt_mark
|
||||
iterm2_prompt_mark
|
||||
end
|
||||
end
|
||||
@ -5,10 +5,13 @@ function _pure_prompt_first_line \
|
||||
return 1
|
||||
end
|
||||
|
||||
set --local prompt_ssh (_pure_prompt_ssh)
|
||||
set --local prompt_git (_pure_prompt_git)
|
||||
set --local prompt_command_duration (_pure_prompt_command_duration)
|
||||
set --local prompt (_pure_print_prompt \
|
||||
(_pure_prompt_ssh) \
|
||||
(_pure_prompt_git) \
|
||||
(_pure_prompt_command_duration)
|
||||
$prompt_ssh \
|
||||
$prompt_git \
|
||||
$prompt_command_duration
|
||||
)
|
||||
set --local prompt_width (_pure_string_width $prompt)
|
||||
set --local current_folder (_pure_prompt_current_folder $prompt_width)
|
||||
@ -16,16 +19,16 @@ function _pure_prompt_first_line \
|
||||
set --local prompt_components
|
||||
if test $pure_begin_prompt_with_current_directory = true
|
||||
set prompt_components \
|
||||
(_pure_prompt_current_folder $prompt_width) \
|
||||
(_pure_prompt_git) \
|
||||
(_pure_prompt_ssh) \
|
||||
(_pure_prompt_command_duration)
|
||||
$current_folder \
|
||||
$prompt_git \
|
||||
$prompt_ssh \
|
||||
$prompt_command_duration
|
||||
else
|
||||
set prompt_components \
|
||||
(_pure_prompt_ssh) \
|
||||
(_pure_prompt_current_folder $prompt_width) \
|
||||
(_pure_prompt_git) \
|
||||
(_pure_prompt_command_duration)
|
||||
$prompt_ssh \
|
||||
$current_folder \
|
||||
$prompt_git \
|
||||
$prompt_command_duration
|
||||
end
|
||||
|
||||
echo (_pure_print_prompt $prompt_components)
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
function _pure_prompt_git \
|
||||
--description 'Print git repository informations: branch name, dirty, upstream ahead/behind'
|
||||
|
||||
if test $pure_enable_git != true
|
||||
return
|
||||
end
|
||||
|
||||
set --local is_git_repository (command git rev-parse --is-inside-work-tree 2>/dev/null)
|
||||
|
||||
if test -n "$is_git_repository"
|
||||
|
||||
@ -2,7 +2,13 @@ function _pure_prompt_git_dirty
|
||||
set --local git_dirty_symbol
|
||||
set --local git_dirty_color
|
||||
|
||||
set --local is_git_dirty (command git status --porcelain --ignore-submodules 2>/dev/null)
|
||||
set --local is_git_dirty (
|
||||
# The first checks for staged changes, the second for unstaged ones.
|
||||
# We put them in this order because checking staged changes is *fast*.
|
||||
not command git diff-index --ignore-submodules --cached --quiet HEAD -- >/dev/null 2>&1
|
||||
or not command git diff --ignore-submodules --no-ext-diff --quiet --exit-code >/dev/null 2>&1
|
||||
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_color_git_dirty"
|
||||
|
||||
@ -1,27 +1,25 @@
|
||||
function bass
|
||||
set __bash_args $argv
|
||||
if test "$__bash_args[1]_" = '-d_'
|
||||
set __bass_debug
|
||||
set -e __bash_args[1]
|
||||
set -l bash_args $argv
|
||||
set -l bass_debug
|
||||
if test "$bash_args[1]_" = '-d_'
|
||||
set bass_debug true
|
||||
set -e bash_args[1]
|
||||
end
|
||||
|
||||
python (dirname (status -f))/__bass.py $__bash_args | read -z __script
|
||||
set __errorflag (string sub -s 1 -l 7 "$__script")
|
||||
if test "$__script" = '__usage'
|
||||
echo "Usage: bass [-d] <bash-command>"
|
||||
else if test "x$__errorflag" = 'x__error'
|
||||
echo "Bass encountered an error!"
|
||||
set __exitcode (string sub -s 9 "$__script")
|
||||
set __exitcode (string trim $__exitcode)
|
||||
if test -z $__exitcode
|
||||
return 1
|
||||
else
|
||||
return $__exitcode
|
||||
end
|
||||
else
|
||||
echo -e "$__script" | source -
|
||||
if set -q __bass_debug
|
||||
echo "$__script"
|
||||
end
|
||||
set -l script_file (mktemp)
|
||||
python (dirname (status -f))/__bass.py $bash_args 3>$script_file
|
||||
set -l bass_status $status
|
||||
if test $bass_status -ne 0
|
||||
return $bass_status
|
||||
end
|
||||
|
||||
if test -n "$bass_debug"
|
||||
cat $script_file
|
||||
end
|
||||
source $script_file
|
||||
/bin/rm $script_file
|
||||
end
|
||||
|
||||
function __bass_usage
|
||||
echo "Usage: bass [-d] <bash-command>"
|
||||
end
|
||||
|
||||
@ -3,6 +3,7 @@ function fish_prompt
|
||||
|
||||
echo -e -n (_pure_prompt_beginning) # init prompt context (clear current line, etc.)
|
||||
echo -e (_pure_prompt_first_line) # print current path, git branch/status, command duration
|
||||
_pure_place_iterm2_prompt_mark # place iTerm shell integration mark
|
||||
echo -e -n (_pure_prompt $exit_code) # print prompt
|
||||
echo -e (_pure_prompt_ending) # reset colors and end prompt
|
||||
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
function fish_right_prompt \
|
||||
--description "Let user override prompt"
|
||||
|
||||
printf "%s%s%s" $pure_color_right_prompt "$pure_right_prompt" $pure_color_normal
|
||||
end
|
||||
Reference in New Issue
Block a user