2020-04-20 21:12:57 +03:00
|
|
|
function lean_install
|
2020-04-30 00:52:58 +03:00
|
|
|
echo 'Installing lean theme...'
|
2020-04-03 03:12:55 +03:00
|
|
|
|
2020-04-20 21:12:57 +03:00
|
|
|
# -----------------Download Functions-----------------
|
2020-04-30 00:52:58 +03:00
|
|
|
set -l tempDir '/tmp/lean_theme'
|
2020-04-03 02:30:40 +03:00
|
|
|
|
2020-04-20 21:12:57 +03:00
|
|
|
# Clone repository into $tempDir
|
|
|
|
if test -e $tempDir
|
|
|
|
rm -rf $tempDir
|
|
|
|
end
|
|
|
|
git clone -q --depth=1 https://github.com/IlanCosman/lean.git $tempDir
|
|
|
|
|
2020-05-10 02:41:29 +03:00
|
|
|
# Remove all files/dirs except functions and lean_theme
|
|
|
|
set -l keepFiles "$tempDir/"{'functions', 'lean_theme'}
|
|
|
|
for file in $tempDir/*
|
|
|
|
if not contains $file $keepFiles
|
|
|
|
rm -rf $file
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rm -rf "$tempDir/.git"
|
2020-04-16 11:48:40 +03:00
|
|
|
|
2020-05-05 00:22:08 +03:00
|
|
|
# Copy remaining directory contents into $__fish_config_dir and cleanup
|
2020-04-20 21:12:57 +03:00
|
|
|
cp -rf "$tempDir/." $__fish_config_dir
|
|
|
|
rm -rf $tempDir
|
2020-04-16 11:48:40 +03:00
|
|
|
|
2020-04-20 21:12:57 +03:00
|
|
|
# ----------------Set Theme Variables----------------
|
2020-05-04 18:24:09 +03:00
|
|
|
set -U lean_dir "$__fish_config_dir/lean_theme"
|
2020-04-25 23:32:44 +03:00
|
|
|
# --------------Colors--------------
|
|
|
|
set -U lean_color_green 5FD700
|
|
|
|
set -U lean_color_light_blue 00AFFF
|
|
|
|
set -U lean_color_dark_blue 0087AF
|
|
|
|
set -U lean_color_gold D7AF00
|
2020-05-02 06:25:59 +03:00
|
|
|
set -U lean_color_lilac 8787AF
|
2020-04-20 21:12:57 +03:00
|
|
|
# ---------------Pwd---------------
|
2020-04-29 07:19:32 +03:00
|
|
|
set -U lean_pwd_shorten_margin 5
|
2020-04-30 00:52:58 +03:00
|
|
|
set -U lean_pwd_unwritable_icon '' # Lock
|
2020-04-20 21:12:57 +03:00
|
|
|
# ------------Git prompt------------
|
|
|
|
set -U __fish_git_prompt_show_informative_status true
|
|
|
|
set -U __fish_git_prompt_showstashstate true
|
|
|
|
# -------Symbols-------
|
2020-04-30 00:52:58 +03:00
|
|
|
set -U __fish_git_prompt_char_stateseparator ''
|
|
|
|
set -U __fish_git_prompt_char_cleanstate ''
|
|
|
|
set -U __fish_git_prompt_char_upstream_ahead ' ⇡'
|
|
|
|
set -U __fish_git_prompt_char_upstream_behind ' ⇣'
|
|
|
|
set -U __fish_git_prompt_char_stagedstate ' +'
|
|
|
|
set -U __fish_git_prompt_char_dirtystate ' !'
|
|
|
|
set -U __fish_git_prompt_char_untrackedfiles ' ?'
|
|
|
|
set -U __fish_git_prompt_char_stashstate ' *'
|
2020-04-20 21:12:57 +03:00
|
|
|
# --------Colors--------
|
|
|
|
set -U __fish_git_prompt_color_branch $lean_color_green
|
|
|
|
set -U __fish_git_prompt_color_upstream $lean_color_green
|
|
|
|
set -U __fish_git_prompt_color_stagedstate $lean_color_gold
|
|
|
|
set -U __fish_git_prompt_color_dirtystate $lean_color_gold
|
|
|
|
set -U __fish_git_prompt_color_untrackedfiles $lean_color_light_blue
|
|
|
|
set -U __fish_git_prompt_color_stashstate $lean_color_green
|
2020-04-03 02:30:40 +03:00
|
|
|
|
2020-04-28 01:37:08 +03:00
|
|
|
# ----------------Right Prompt Items----------------
|
2020-04-30 03:06:11 +03:00
|
|
|
set -U lean_right_prompt_items 'status' 'cmd_duration' 'context' 'jobs'
|
2020-04-29 22:32:59 +03:00
|
|
|
# --------------Status--------------
|
2020-04-30 00:52:58 +03:00
|
|
|
set -U lean_status_success_icon '✔'
|
2020-04-29 22:32:59 +03:00
|
|
|
set -U lean_status_success_color 5FAF00
|
2020-04-30 00:52:58 +03:00
|
|
|
set -U lean_status_failure_icon '✘'
|
2020-04-29 22:32:59 +03:00
|
|
|
set -U lean_status_failure_color D70000
|
2020-04-30 03:06:11 +03:00
|
|
|
# --------------Cmd_Duration--------------
|
|
|
|
set -U lean_cmd_duration_color 87875F
|
|
|
|
set -U lean_cmd_duration_decimals 0
|
2020-05-09 08:48:35 +03:00
|
|
|
set -U lean_cmd_duration_threshold 3000
|
2020-04-28 23:46:40 +03:00
|
|
|
# -------------Context-------------
|
|
|
|
set -U lean_context_ssh_color D7AF87
|
|
|
|
set -U lean_context_root_color D7AF00
|
2020-04-29 07:19:32 +03:00
|
|
|
# ---------------Jobs---------------
|
2020-04-30 00:52:58 +03:00
|
|
|
set -U lean_jobs_icon '' # Gear
|
2020-04-29 07:19:32 +03:00
|
|
|
set -U lean_jobs_color 5FAF00
|
2020-04-30 03:40:44 +03:00
|
|
|
# ---------------Time---------------
|
|
|
|
set -U lean_time_color 5F8787
|
2020-04-25 22:21:09 +03:00
|
|
|
|
|
|
|
# -----------------------Finish-----------------------
|
2020-04-20 21:12:57 +03:00
|
|
|
source "$__fish_config_dir/functions/fish_prompt.fish"
|
2020-04-03 03:12:55 +03:00
|
|
|
|
2020-04-20 21:12:57 +03:00
|
|
|
set_color $lean_color_green
|
2020-04-30 00:52:58 +03:00
|
|
|
echo 'Lean theme installed!'
|
2020-04-20 21:12:57 +03:00
|
|
|
set_color $fish_color_normal
|
2020-04-22 06:06:05 +03:00
|
|
|
|
2020-04-30 00:52:58 +03:00
|
|
|
if _user_confirm_defaultYes 'Configure lean prompt?'
|
2020-05-04 07:41:08 +03:00
|
|
|
lean configure
|
2020-04-22 06:06:05 +03:00
|
|
|
else
|
2020-05-04 07:41:08 +03:00
|
|
|
echo -e '\n''Run lean configure to configure your prompt.'
|
2020-04-22 06:06:05 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-26 00:52:39 +03:00
|
|
|
function _user_confirm_defaultYes -a question
|
2020-04-22 06:06:05 +03:00
|
|
|
while true
|
|
|
|
read -P "$question [Y/n] " input
|
|
|
|
|
|
|
|
switch $input
|
|
|
|
case y Y yes Yes
|
|
|
|
return 0
|
|
|
|
case n N no No
|
|
|
|
return 1
|
2020-04-30 00:52:58 +03:00
|
|
|
case ''
|
2020-04-22 06:06:05 +03:00
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end
|
2020-04-20 21:12:57 +03:00
|
|
|
end
|