add pure prompt
This commit is contained in:
parent
406034f7a0
commit
bd5c75ba5c
44 changed files with 711 additions and 1 deletions
25
fish/.config/fish/conf.d/_pure_init.fish
Normal file
25
fish/.config/fish/conf.d/_pure_init.fish
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Register `_pure_prompt_new_line` as an event handler fot `fish_prompt`
|
||||||
|
functions --query _pure_prompt_new_line
|
||||||
|
|
||||||
|
function _pure_uninstall --on-event pure_uninstall
|
||||||
|
# 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
|
||||||
|
# delete _pure* files
|
||||||
|
for file in $__fish_config_dir/{functions,conf.d}/_pure_*
|
||||||
|
rm $file
|
||||||
|
end
|
||||||
|
# restore fish_prompt to default
|
||||||
|
cp {$__fish_data_dir,$__fish_config_dir}/functions/fish_prompt.fish
|
||||||
|
end
|
91
fish/.config/fish/conf.d/pure.fish
Normal file
91
fish/.config/fish/conf.d/pure.fish
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
set --global pure_version 4.4.3 # 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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# 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_color_system_time pure_color_mute
|
||||||
|
|
||||||
|
# Virtualenv for Python
|
||||||
|
_pure_set_default pure_color_virtualenv pure_color_mute
|
||||||
|
|
||||||
|
# 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#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
|
||||||
|
|
||||||
|
# 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 -
|
||||||
|
|
||||||
|
# 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 '🔗🔐🔒🌐'
|
|
@ -1,2 +1,3 @@
|
||||||
jorgebucaran/fisher
|
jorgebucaran/fisher
|
||||||
catppuccin/fish
|
catppuccin/fish
|
||||||
|
pure-fish/pure
|
||||||
|
|
|
@ -5,7 +5,8 @@ SETUVAR --export SSH_AUTH_SOCK:/tmp/ssh\x2dXXXXXXDOnz2M/agent\x2e1734
|
||||||
SETUVAR __fish_initialized:3400
|
SETUVAR __fish_initialized:3400
|
||||||
SETUVAR _fisher_catppuccin_2F_fish_files:\x7e/\x2econfig/fish/themes/Catppuccin\x20Frappe\x2etheme\x1e\x7e/\x2econfig/fish/themes/Catppuccin\x20Latte\x2etheme\x1e\x7e/\x2econfig/fish/themes/Catppuccin\x20Macchiato\x2etheme\x1e\x7e/\x2econfig/fish/themes/Catppuccin\x20Mocha\x2etheme
|
SETUVAR _fisher_catppuccin_2F_fish_files:\x7e/\x2econfig/fish/themes/Catppuccin\x20Frappe\x2etheme\x1e\x7e/\x2econfig/fish/themes/Catppuccin\x20Latte\x2etheme\x1e\x7e/\x2econfig/fish/themes/Catppuccin\x20Macchiato\x2etheme\x1e\x7e/\x2econfig/fish/themes/Catppuccin\x20Mocha\x2etheme
|
||||||
SETUVAR _fisher_jorgebucaran_2F_fisher_files:\x7e/\x2econfig/fish/functions/fisher\x2efish\x1e\x7e/\x2econfig/fish/completions/fisher\x2efish
|
SETUVAR _fisher_jorgebucaran_2F_fisher_files:\x7e/\x2econfig/fish/functions/fisher\x2efish\x1e\x7e/\x2econfig/fish/completions/fisher\x2efish
|
||||||
SETUVAR _fisher_plugins:jorgebucaran/fisher\x1ecatppuccin/fish
|
SETUVAR _fisher_plugins:jorgebucaran/fisher\x1ecatppuccin/fish\x1epure\x2dfish/pure
|
||||||
|
SETUVAR _fisher_pure_2D_fish_2F_pure_files:\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_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_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_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_new_line\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_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_greeting\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 _fisher_upgraded_to_4_4:\x1d
|
||||||
SETUVAR fish_color_autosuggestion:6c7086
|
SETUVAR fish_color_autosuggestion:6c7086
|
||||||
SETUVAR fish_color_cancel:f38ba8
|
SETUVAR fish_color_cancel:f38ba8
|
||||||
|
@ -46,3 +47,51 @@ SETUVAR fish_pager_color_selected_background:\x1d
|
||||||
SETUVAR fish_pager_color_selected_completion:\x1d
|
SETUVAR fish_pager_color_selected_completion:\x1d
|
||||||
SETUVAR fish_pager_color_selected_description:\x1d
|
SETUVAR fish_pager_color_selected_description:\x1d
|
||||||
SETUVAR fish_pager_color_selected_prefix:\x1d
|
SETUVAR fish_pager_color_selected_prefix:\x1d
|
||||||
|
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_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_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_light:white
|
||||||
|
SETUVAR pure_color_mute:brblack
|
||||||
|
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_enable_container_detection:true
|
||||||
|
SETUVAR pure_enable_git:true
|
||||||
|
SETUVAR pure_enable_single_line_prompt:false
|
||||||
|
SETUVAR pure_reverse_prompt_symbol_in_vimode:true
|
||||||
|
SETUVAR pure_separate_prompt_on_error:false
|
||||||
|
SETUVAR pure_show_jobs:false
|
||||||
|
SETUVAR pure_show_prefix_root_prompt:false
|
||||||
|
SETUVAR pure_show_subsecond_command_duration:false
|
||||||
|
SETUVAR pure_show_system_time:false
|
||||||
|
SETUVAR pure_symbol_container_prefix:
|
||||||
|
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_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_threshold_command_duration:5
|
||||||
|
|
24
fish/.config/fish/functions/_pure_check_for_new_release.fish
Normal file
24
fish/.config/fish/functions/_pure_check_for_new_release.fish
Normal file
|
@ -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'
|
||||||
|
end
|
||||||
|
end
|
49
fish/.config/fish/functions/_pure_format_time.fish
Normal file
49
fish/.config/fish/functions/_pure_format_time.fish
Normal file
|
@ -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
|
12
fish/.config/fish/functions/_pure_get_prompt_symbol.fish
Normal file
12
fish/.config/fish/functions/_pure_get_prompt_symbol.fish
Normal file
|
@ -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
|
26
fish/.config/fish/functions/_pure_is_inside_container.fish
Normal file
26
fish/.config/fish/functions/_pure_is_inside_container.fish
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
function _pure_is_inside_container \
|
||||||
|
--argument-names cgroup_namespace
|
||||||
|
set --query cgroup_namespace[1]; or set cgroup_namespace /proc/1/cgroup
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
set --local failure 1
|
||||||
|
return $failure
|
||||||
|
end
|
||||||
|
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
|
14
fish/.config/fish/functions/_pure_parse_directory.fish
Normal file
14
fish/.config/fish/functions/_pure_parse_directory.fish
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
function _pure_parse_directory \
|
||||||
|
--description "Replace '$HOME' with '~'" \
|
||||||
|
--argument-names max_path_length
|
||||||
|
|
||||||
|
set --local folder (string replace $HOME '~' $PWD)
|
||||||
|
|
||||||
|
if test -n "$max_path_length";
|
||||||
|
if test (string length $folder) -gt $max_path_length;
|
||||||
|
# If path exceeds maximum symbol limit, use default fish path formating function
|
||||||
|
set folder (prompt_pwd)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
echo $folder
|
||||||
|
end
|
4
fish/.config/fish/functions/_pure_parse_git_branch.fish
Normal file
4
fish/.config/fish/functions/_pure_parse_git_branch.fish
Normal file
|
@ -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
|
11
fish/.config/fish/functions/_pure_prefix_root_prompt.fish
Normal file
11
fish/.config/fish/functions/_pure_prefix_root_prompt.fish
Normal file
|
@ -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
|
13
fish/.config/fish/functions/_pure_print_prompt.fish
Normal file
13
fish/.config/fish/functions/_pure_print_prompt.fish
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
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
|
10
fish/.config/fish/functions/_pure_print_prompt_rows.fish
Normal file
10
fish/.config/fish/functions/_pure_print_prompt_rows.fish
Normal file
|
@ -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
|
27
fish/.config/fish/functions/_pure_prompt.fish
Normal file
27
fish/.config/fish/functions/_pure_prompt.fish
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
function _pure_prompt \
|
||||||
|
--description 'Print prompt symbol' \
|
||||||
|
--argument-names exit_code
|
||||||
|
|
||||||
|
set --local jobs (_pure_prompt_jobs)
|
||||||
|
set --local virtualenv (_pure_prompt_virtualenv) # Python virtualenv name
|
||||||
|
set --local vimode_indicator (_pure_prompt_vimode) # vi-mode indicator
|
||||||
|
set --local pure_symbol (_pure_prompt_symbol $exit_code)
|
||||||
|
set --local system_time (_pure_prompt_system_time)
|
||||||
|
set --local root_prefix (_pure_prefix_root_prompt)
|
||||||
|
set --local space
|
||||||
|
|
||||||
|
if _pure_is_single_line_prompt
|
||||||
|
set space ' '
|
||||||
|
end
|
||||||
|
|
||||||
|
echo (\
|
||||||
|
_pure_print_prompt \
|
||||||
|
$space \
|
||||||
|
$system_time \
|
||||||
|
$root_prefix \
|
||||||
|
$jobs \
|
||||||
|
$virtualenv \
|
||||||
|
$vimode_indicator \
|
||||||
|
$pure_symbol \
|
||||||
|
)
|
||||||
|
end
|
6
fish/.config/fish/functions/_pure_prompt_beginning.fish
Normal file
6
fish/.config/fish/functions/_pure_prompt_beginning.fish
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
function _pure_prompt_beginning
|
||||||
|
# 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
|
5
fish/.config/fish/functions/_pure_prompt_container.fish
Normal file
5
fish/.config/fish/functions/_pure_prompt_container.fish
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
function _pure_prompt_container
|
||||||
|
if _pure_is_inside_container
|
||||||
|
echo "$pure_symbol_container_prefix"(_pure_user_at_host)
|
||||||
|
end
|
||||||
|
end
|
11
fish/.config/fish/functions/_pure_prompt_current_folder.fish
Normal file
11
fish/.config/fish/functions/_pure_prompt_current_folder.fish
Normal file
|
@ -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
|
3
fish/.config/fish/functions/_pure_prompt_ending.fish
Normal file
3
fish/.config/fish/functions/_pure_prompt_ending.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function _pure_prompt_ending
|
||||||
|
echo (set_color normal)" "
|
||||||
|
end
|
37
fish/.config/fish/functions/_pure_prompt_first_line.fish
Normal file
37
fish/.config/fish/functions/_pure_prompt_first_line.fish
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
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_git (_pure_prompt_git)
|
||||||
|
set --local prompt_command_duration (_pure_prompt_command_duration)
|
||||||
|
set --local prompt (_pure_print_prompt \
|
||||||
|
$prompt_ssh \
|
||||||
|
$prompt_container \
|
||||||
|
$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_command_duration
|
||||||
|
else
|
||||||
|
set prompt_components \
|
||||||
|
$prompt_ssh \
|
||||||
|
$prompt_container \
|
||||||
|
$current_folder \
|
||||||
|
$prompt_git \
|
||||||
|
$prompt_command_duration
|
||||||
|
end
|
||||||
|
|
||||||
|
echo (_pure_print_prompt $prompt_components)
|
||||||
|
end
|
26
fish/.config/fish/functions/_pure_prompt_git.fish
Normal file
26
fish/.config/fish/functions/_pure_prompt_git.fish
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
function _pure_prompt_git \
|
||||||
|
--description 'Print git repository informations: 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
|
6
fish/.config/fish/functions/_pure_prompt_git_branch.fish
Normal file
6
fish/.config/fish/functions/_pure_prompt_git_branch.fish
Normal file
|
@ -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
|
18
fish/.config/fish/functions/_pure_prompt_git_dirty.fish
Normal file
18
fish/.config/fish/functions/_pure_prompt_git_dirty.fish
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
function _pure_prompt_git_dirty
|
||||||
|
set --local git_dirty_symbol
|
||||||
|
set --local git_dirty_color
|
||||||
|
|
||||||
|
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_set_color $pure_color_git_dirty)
|
||||||
|
end
|
||||||
|
|
||||||
|
echo "$git_dirty_color$git_dirty_symbol"
|
||||||
|
end
|
|
@ -0,0 +1,27 @@
|
||||||
|
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"
|
||||||
|
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"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
echo "$git_unpushed_commits$git_unpulled_commits"
|
||||||
|
end
|
15
fish/.config/fish/functions/_pure_prompt_git_stash.fish
Normal file
15
fish/.config/fish/functions/_pure_prompt_git_stash.fish
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
function _pure_prompt_git_stash
|
||||||
|
set --local git_stash_symbol
|
||||||
|
set --local git_stash_color
|
||||||
|
|
||||||
|
set --local has_stashed_files (
|
||||||
|
command git rev-list --walk-reflogs --count refs/stash >/dev/null 2>&1
|
||||||
|
and echo "true"
|
||||||
|
)
|
||||||
|
if test -n "$has_stashed_files" # untracked or un-commited files
|
||||||
|
set git_stash_symbol " $pure_symbol_git_stash"
|
||||||
|
set git_stash_color (_pure_set_color $pure_color_git_stash)
|
||||||
|
end
|
||||||
|
|
||||||
|
echo "$git_stash_color$git_stash_symbol"
|
||||||
|
end
|
9
fish/.config/fish/functions/_pure_prompt_jobs.fish
Normal file
9
fish/.config/fish/functions/_pure_prompt_jobs.fish
Normal file
|
@ -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
|
11
fish/.config/fish/functions/_pure_prompt_new_line.fish
Normal file
11
fish/.config/fish/functions/_pure_prompt_new_line.fish
Normal file
|
@ -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 "$new_line"
|
||||||
|
end
|
5
fish/.config/fish/functions/_pure_prompt_ssh.fish
Normal file
5
fish/.config/fish/functions/_pure_prompt_ssh.fish
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
function _pure_prompt_ssh
|
||||||
|
if test "$SSH_CONNECTION" != ""
|
||||||
|
echo "$pure_symbol_ssh_prefix"(_pure_user_at_host)
|
||||||
|
end
|
||||||
|
end
|
20
fish/.config/fish/functions/_pure_prompt_symbol.fish
Normal file
20
fish/.config/fish/functions/_pure_prompt_symbol.fish
Normal file
|
@ -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 '+%T')
|
||||||
|
end
|
||||||
|
end
|
6
fish/.config/fish/functions/_pure_prompt_vimode.fish
Normal file
6
fish/.config/fish/functions/_pure_prompt_vimode.fish
Normal file
|
@ -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
|
13
fish/.config/fish/functions/_pure_prompt_virtualenv.fish
Normal file
13
fish/.config/fish/functions/_pure_prompt_virtualenv.fish
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
function _pure_prompt_virtualenv --description "Display virtualenv directory"
|
||||||
|
if test -n "$VIRTUAL_ENV"
|
||||||
|
set --local virtualenv (basename "$VIRTUAL_ENV")
|
||||||
|
set --local virtualenv_color (_pure_set_color $pure_color_virtualenv)
|
||||||
|
|
||||||
|
echo "$virtualenv_color$virtualenv"
|
||||||
|
else if test -n "$CONDA_DEFAULT_ENV"
|
||||||
|
set --local virtualenv (basename "$CONDA_DEFAULT_ENV")
|
||||||
|
set --local virtualenv_color (_pure_set_color $pure_color_virtualenv)
|
||||||
|
|
||||||
|
echo "$virtualenv_color$virtualenv"
|
||||||
|
end
|
||||||
|
end
|
19
fish/.config/fish/functions/_pure_set_color.fish
Normal file
19
fish/.config/fish/functions/_pure_set_color.fish
Normal file
|
@ -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
|
11
fish/.config/fish/functions/_pure_set_default.fish
Normal file
11
fish/.config/fish/functions/_pure_set_default.fish
Normal file
|
@ -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
|
9
fish/.config/fish/functions/_pure_string_width.fish
Normal file
9
fish/.config/fish/functions/_pure_string_width.fish
Normal file
|
@ -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
|
13
fish/.config/fish/functions/_pure_user_at_host.fish
Normal file
13
fish/.config/fish/functions/_pure_user_at_host.fish
Normal file
|
@ -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
|
3
fish/.config/fish/functions/fish_greeting.fish
Normal file
3
fish/.config/fish/functions/fish_greeting.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function fish_greeting
|
||||||
|
_pure_check_for_new_release
|
||||||
|
end
|
2
fish/.config/fish/functions/fish_mode_prompt.fish
Normal file
2
fish/.config/fish/functions/fish_mode_prompt.fish
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
function fish_mode_prompt
|
||||||
|
end
|
12
fish/.config/fish/functions/fish_prompt.fish
Normal file
12
fish/.config/fish/functions/fish_prompt.fish
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# a called to `_pure_prompt_new_line` is triggered by an event
|
||||||
|
function fish_prompt
|
||||||
|
set --local exit_code $status # save previous exit code
|
||||||
|
|
||||||
|
echo -e -n (_pure_prompt_beginning) # init prompt context (clear current line, etc.)
|
||||||
|
_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_code) # print prompt
|
||||||
|
echo -e (_pure_prompt_ending) # reset colors and end prompt
|
||||||
|
|
||||||
|
set _pure_fresh_session false
|
||||||
|
end
|
16
fish/.config/fish/functions/fish_title.fish
Normal file
16
fish/.config/fish/functions/fish_title.fish
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
function fish_title \
|
||||||
|
--description "Set title to current folder and shell name" \
|
||||||
|
--argument-names last_command
|
||||||
|
|
||||||
|
set --local basename (string replace --regex '^.*/' '' -- $PWD)
|
||||||
|
set --local current_folder (_pure_parse_directory)
|
||||||
|
set --local current_command (status current-command 2>/dev/null; or echo $_)
|
||||||
|
|
||||||
|
set --local prompt "$basename: $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
|
Loading…
Reference in a new issue