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
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
|
||||||
set -g __done_version 1.8.0
|
set -g __done_version 1.10.0
|
||||||
|
|
||||||
function __done_get_focused_window_id
|
function __done_get_focused_window_id
|
||||||
if type -q lsappinfo
|
if type -q lsappinfo
|
||||||
lsappinfo info -only bundleID (lsappinfo front) | cut -d '"' -f4
|
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
|
else if type -q xprop
|
||||||
and test $DISPLAY
|
and test -n "$DISPLAY"
|
||||||
xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2
|
xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -55,11 +58,12 @@ end
|
|||||||
|
|
||||||
# verify that the system has graphical capabilites before initializing
|
# verify that the system has graphical capabilites before initializing
|
||||||
if test -z "$SSH_CLIENT" # not over ssh
|
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 -g __done_initial_window_id ''
|
||||||
set -q __done_min_cmd_duration; or set -g __done_min_cmd_duration 5000
|
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_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
|
function __done_started --on-event fish_preexec
|
||||||
set __done_initial_window_id (__done_get_focused_window_id)
|
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 message "$wd/ $history[1]"
|
||||||
set -l sender $__done_initial_window_id
|
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
|
if test $exit_status -ne 0
|
||||||
set title "Failed ($exit_status) after $humanized_duration"
|
set title "Failed ($exit_status) after $humanized_duration"
|
||||||
end
|
end
|
||||||
|
|
||||||
if set -q __done_notification_command
|
if set -q __done_notification_command
|
||||||
eval $__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
|
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
|
else if type -q osascript # AppleScript
|
||||||
osascript -e "display notification \"$message\" with title \"$title\""
|
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
|
else if type -q notify-send # Linux notify-send
|
||||||
set -l urgency
|
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"
|
set urgency "--urgency=critical"
|
||||||
end
|
end
|
||||||
notify-send $urgency --icon=terminal --app-name=fish "$title" "$message"
|
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
|
else if type -q notify-desktop # Linux notify-desktop
|
||||||
set -l urgency
|
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"
|
set urgency "--urgency=critical"
|
||||||
end
|
end
|
||||||
notify-desktop $urgency --icon=terminal --app-name=fish "$title" "$message"
|
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
|
else # anything else
|
||||||
echo -e "\a" # bell sound
|
echo -e "\a" # bell sound
|
||||||
|
|||||||
@ -15,20 +15,20 @@ if test "$FZF_LEGACY_KEYBINDINGS" -eq 1
|
|||||||
bind -M insert \co '__fzf_open --editor'
|
bind -M insert \co '__fzf_open --editor'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
bind \cf '__fzf_find_file'
|
bind \co '__fzf_find_file'
|
||||||
bind \cr '__fzf_reverse_isearch'
|
bind \cr '__fzf_reverse_isearch'
|
||||||
bind \eo '__fzf_cd'
|
bind \ec '__fzf_cd'
|
||||||
bind \eO '__fzf_cd --hidden'
|
bind \eC '__fzf_cd --hidden'
|
||||||
bind \cg '__fzf_open'
|
bind \eO '__fzf_open'
|
||||||
bind \co '__fzf_open --editor'
|
bind \eo '__fzf_open --editor'
|
||||||
|
|
||||||
if bind -M insert >/dev/null 2>/dev/null
|
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 \cr '__fzf_reverse_isearch'
|
||||||
bind -M insert \eo '__fzf_cd'
|
bind -M insert \ec '__fzf_cd'
|
||||||
bind -M insert \eO '__fzf_cd --hidden'
|
bind -M insert \eC '__fzf_cd --hidden'
|
||||||
bind -M insert \cg '__fzf_open'
|
bind -M insert \eO '__fzf_open'
|
||||||
bind -M insert \co '__fzf_open --editor'
|
bind -M insert \eo '__fzf_open --editor'
|
||||||
end
|
end
|
||||||
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
|
# Base colors
|
||||||
_pure_set_default pure_color_primary (set_color blue)
|
_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
|
_pure_set_default pure_color_current_directory $pure_color_primary
|
||||||
|
|
||||||
# Git
|
# Git
|
||||||
|
_pure_set_default pure_enable_git true
|
||||||
_pure_set_default pure_symbol_git_unpulled_commits "⇣"
|
_pure_set_default pure_symbol_git_unpulled_commits "⇣"
|
||||||
_pure_set_default pure_symbol_git_unpushed_commits "⇡"
|
_pure_set_default pure_symbol_git_unpushed_commits "⇡"
|
||||||
_pure_set_default pure_symbol_git_dirty "*"
|
_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_threshold_command_duration 5
|
||||||
_pure_set_default pure_color_command_duration $pure_color_warning
|
_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
|
# VI mode indicator
|
||||||
# true (default): indicate a non-insert mode by reversing the prompt symbol (❮)
|
# true (default): indicate a non-insert mode by reversing the prompt symbol (❮)
|
||||||
# false: indicate vi mode with [I], [N], [V]
|
# false: indicate vi mode with [I], [N], [V]
|
||||||
|
|||||||
@ -6,3 +6,5 @@ fzf_key_bindings
|
|||||||
set -gx EDITOR vi
|
set -gx EDITOR vi
|
||||||
set -gx XDG_RUNTIME_DIR /run/user/(id -u)
|
set -gx XDG_RUNTIME_DIR /run/user/(id -u)
|
||||||
eval (python -m virtualfish)
|
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_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
|
||||||
SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan
|
SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan
|
||||||
SETUVAR fish_user_paths:/Users/colinpowell/\x2efzf/bin
|
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
|
return 1
|
||||||
end
|
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 \
|
set --local prompt (_pure_print_prompt \
|
||||||
(_pure_prompt_ssh) \
|
$prompt_ssh \
|
||||||
(_pure_prompt_git) \
|
$prompt_git \
|
||||||
(_pure_prompt_command_duration)
|
$prompt_command_duration
|
||||||
)
|
)
|
||||||
set --local prompt_width (_pure_string_width $prompt)
|
set --local prompt_width (_pure_string_width $prompt)
|
||||||
set --local current_folder (_pure_prompt_current_folder $prompt_width)
|
set --local current_folder (_pure_prompt_current_folder $prompt_width)
|
||||||
@ -16,16 +19,16 @@ function _pure_prompt_first_line \
|
|||||||
set --local prompt_components
|
set --local prompt_components
|
||||||
if test $pure_begin_prompt_with_current_directory = true
|
if test $pure_begin_prompt_with_current_directory = true
|
||||||
set prompt_components \
|
set prompt_components \
|
||||||
(_pure_prompt_current_folder $prompt_width) \
|
$current_folder \
|
||||||
(_pure_prompt_git) \
|
$prompt_git \
|
||||||
(_pure_prompt_ssh) \
|
$prompt_ssh \
|
||||||
(_pure_prompt_command_duration)
|
$prompt_command_duration
|
||||||
else
|
else
|
||||||
set prompt_components \
|
set prompt_components \
|
||||||
(_pure_prompt_ssh) \
|
$prompt_ssh \
|
||||||
(_pure_prompt_current_folder $prompt_width) \
|
$current_folder \
|
||||||
(_pure_prompt_git) \
|
$prompt_git \
|
||||||
(_pure_prompt_command_duration)
|
$prompt_command_duration
|
||||||
end
|
end
|
||||||
|
|
||||||
echo (_pure_print_prompt $prompt_components)
|
echo (_pure_print_prompt $prompt_components)
|
||||||
|
|||||||
@ -1,6 +1,10 @@
|
|||||||
function _pure_prompt_git \
|
function _pure_prompt_git \
|
||||||
--description 'Print git repository informations: branch name, dirty, upstream ahead/behind'
|
--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)
|
set --local is_git_repository (command git rev-parse --is-inside-work-tree 2>/dev/null)
|
||||||
|
|
||||||
if test -n "$is_git_repository"
|
if test -n "$is_git_repository"
|
||||||
|
|||||||
@ -2,7 +2,13 @@ function _pure_prompt_git_dirty
|
|||||||
set --local git_dirty_symbol
|
set --local git_dirty_symbol
|
||||||
set --local git_dirty_color
|
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
|
if test -n "$is_git_dirty" # untracked or un-commited files
|
||||||
set git_dirty_symbol "$pure_symbol_git_dirty"
|
set git_dirty_symbol "$pure_symbol_git_dirty"
|
||||||
set git_dirty_color "$pure_color_git_dirty"
|
set git_dirty_color "$pure_color_git_dirty"
|
||||||
|
|||||||
@ -1,27 +1,25 @@
|
|||||||
function bass
|
function bass
|
||||||
set __bash_args $argv
|
set -l bash_args $argv
|
||||||
if test "$__bash_args[1]_" = '-d_'
|
set -l bass_debug
|
||||||
set __bass_debug
|
if test "$bash_args[1]_" = '-d_'
|
||||||
set -e __bash_args[1]
|
set bass_debug true
|
||||||
|
set -e bash_args[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
python (dirname (status -f))/__bass.py $__bash_args | read -z __script
|
set -l script_file (mktemp)
|
||||||
set __errorflag (string sub -s 1 -l 7 "$__script")
|
python (dirname (status -f))/__bass.py $bash_args 3>$script_file
|
||||||
if test "$__script" = '__usage'
|
set -l bass_status $status
|
||||||
echo "Usage: bass [-d] <bash-command>"
|
if test $bass_status -ne 0
|
||||||
else if test "x$__errorflag" = 'x__error'
|
return $bass_status
|
||||||
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
|
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
@ -3,6 +3,7 @@ function fish_prompt
|
|||||||
|
|
||||||
echo -e -n (_pure_prompt_beginning) # init prompt context (clear current line, etc.)
|
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
|
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 -n (_pure_prompt $exit_code) # print prompt
|
||||||
echo -e (_pure_prompt_ending) # reset colors and end 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