Bash : Use nix color.
This commit is contained in:
parent
b5ac32db10
commit
3e30a39edf
10
flake.nix
10
flake.nix
|
@ -109,22 +109,28 @@
|
||||||
|
|
||||||
# Colors.
|
# Colors.
|
||||||
nixosModules.color = {
|
nixosModules.color = {
|
||||||
aqua = "689d68";
|
|
||||||
bg = "1d2021";
|
bg = "1d2021";
|
||||||
bg_1 = "504945";
|
bg_1 = "504945";
|
||||||
bg_2 = "3c3836";
|
bg_2 = "3c3836";
|
||||||
blue = "458588";
|
blue = "458588";
|
||||||
blue_faded = "076678";
|
blue_1 = "076678";
|
||||||
darkgray = "282828";
|
darkgray = "282828";
|
||||||
fg = "ebdbb2";
|
fg = "ebdbb2";
|
||||||
fg_1 = "fbf1c7";
|
fg_1 = "fbf1c7";
|
||||||
fg_2 = "d5c4a1";
|
fg_2 = "d5c4a1";
|
||||||
gray = "a89984";
|
gray = "a89984";
|
||||||
green = "98971a";
|
green = "98971a";
|
||||||
|
green_1 = "87af87";
|
||||||
purple = "b16286";
|
purple = "b16286";
|
||||||
red = "cc241d";
|
red = "cc241d";
|
||||||
transparent = "ffffff00";
|
transparent = "ffffff00";
|
||||||
yellow = "b8bb26";
|
yellow = "b8bb26";
|
||||||
|
|
||||||
|
blue_1_rgb = "69;133;136";
|
||||||
|
fg_1_rgb = "251;241;199";
|
||||||
|
green_1_rgb = "135;175;135";
|
||||||
|
red_rgb = "204;36;29";
|
||||||
|
yellow_rgb = "184;187;38";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Common modules used across all hosts.
|
# Common modules used across all hosts.
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
export PROMPT_COMMAND=(__prompt_command "${PROMPT_COMMAND[@]}")
|
export PROMPT_COMMAND=(__prompt_command "${PROMPT_COMMAND[@]}")
|
||||||
export COLOR_BACKGROUND="235"
|
|
||||||
export COLOR_USER_ROOT="203"
|
|
||||||
export COLOR_USER_NORMAL="109"
|
|
||||||
export COLOR_FOREGROUND="230"
|
|
||||||
export COLOR_ACCENT="223"
|
|
||||||
export COLOR_ERROR="203"
|
|
||||||
export COLOR_PATH="108"
|
|
||||||
export COLOR_GIT="142"
|
|
||||||
|
|
||||||
function __prompt_color() {
|
function __prompt_color() {
|
||||||
local color="${1}"
|
local color="${1}"
|
||||||
[[ "${color}" = "" ]] && color="${COLOR_FOREGROUND}"
|
if [[ "${color}" = "" ]]; then
|
||||||
|
printf "\[\x1b[0m\]"
|
||||||
|
else
|
||||||
|
printf "\[\x1b[38;2;${color}m\]"
|
||||||
|
fi
|
||||||
# echo "\[\033[48;5;${COLOR_BACKGROUND};38;5;${color}m\]" # With backgroud.
|
# echo "\[\033[48;5;${COLOR_BACKGROUND};38;5;${color}m\]" # With backgroud.
|
||||||
echo "\[\033[38;5;${color}m\]" # Only foreground.
|
# echo "\[\033[38;5;${color}m\]" # Only foreground.
|
||||||
}
|
}
|
||||||
|
|
||||||
# Custom terminal prompt format.
|
# Custom terminal prompt format.
|
||||||
|
@ -33,7 +29,7 @@ function __prompt_command() {
|
||||||
|
|
||||||
# Set error red.
|
# Set error red.
|
||||||
if ${is_error}; then
|
if ${is_error}; then
|
||||||
PS1+="$(__prompt_color ${COLOR_ERROR})"
|
PS1+="$(__prompt_color ${red_rgb})"
|
||||||
PS1+="["
|
PS1+="["
|
||||||
else
|
else
|
||||||
PS1+="$(__prompt_color)"
|
PS1+="$(__prompt_color)"
|
||||||
|
@ -41,31 +37,31 @@ function __prompt_command() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add time.
|
# Add time.
|
||||||
PS1+="$(__prompt_color ${COLOR_ACCENT})"
|
PS1+="$(__prompt_color ${fg_1_rgb})"
|
||||||
PS1+="$(date +%H:%M) "
|
PS1+="$(date +%H:%M) "
|
||||||
|
|
||||||
# Set root red.
|
# Set root red.
|
||||||
if ${is_root}; then
|
if ${is_root}; then
|
||||||
PS1+="$(__prompt_color ${COLOR_USER_ROOT})"
|
PS1+="$(__prompt_color ${red_rgb})"
|
||||||
else
|
else
|
||||||
PS1+="$(__prompt_color ${COLOR_USER_NORMAL})"
|
PS1+="$(__prompt_color ${blue_1_rgb})"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add user, host and working dir.
|
# Add user, host and working dir.
|
||||||
PS1+="\u@\h "
|
PS1+="\u@\h "
|
||||||
PS1+="$(__prompt_color ${COLOR_PATH})"
|
PS1+="$(__prompt_color ${green_1_rgb})"
|
||||||
PS1+="\w"
|
PS1+="\w"
|
||||||
# PS1+="\${PWD}"
|
# PS1+="\${PWD}"
|
||||||
|
|
||||||
# Add git branch if available.
|
# Add git branch if available.
|
||||||
local git_branch="$(_git_current_branch)"
|
local git_branch="$(_git_current_branch)"
|
||||||
if [[ "${git_branch}" != "" ]]; then
|
if [[ "${git_branch}" != "" ]]; then
|
||||||
PS1+=" $(__prompt_color ${COLOR_GIT})@${git_branch}"
|
PS1+=" $(__prompt_color ${yellow_rgb})@${git_branch}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set error red.
|
# Set error red.
|
||||||
if ${is_error}; then
|
if ${is_error}; then
|
||||||
PS1+="$(__prompt_color ${COLOR_ERROR})"
|
PS1+="$(__prompt_color ${red_rgb})"
|
||||||
PS1+="] "
|
PS1+="] "
|
||||||
else
|
else
|
||||||
PS1+="$(__prompt_color)"
|
PS1+="$(__prompt_color)"
|
||||||
|
@ -74,7 +70,7 @@ function __prompt_command() {
|
||||||
|
|
||||||
# If error, show code.
|
# If error, show code.
|
||||||
if ${is_error}; then
|
if ${is_error}; then
|
||||||
PS1+="$(__prompt_color ${COLOR_ERROR})("
|
PS1+="$(__prompt_color ${red_rgb})("
|
||||||
PS1+="${last_status}"
|
PS1+="${last_status}"
|
||||||
local error_type="$(_ps1error ${last_status})"
|
local error_type="$(_ps1error ${last_status})"
|
||||||
[[ "${error_type}" != "" ]] && PS1+=" ${error_type}"
|
[[ "${error_type}" != "" ]] && PS1+=" ${error_type}"
|
||||||
|
@ -83,7 +79,7 @@ function __prompt_command() {
|
||||||
|
|
||||||
# Command on new line.
|
# Command on new line.
|
||||||
PS1+="\n"
|
PS1+="\n"
|
||||||
PS1+="$(__prompt_color ${COLOR_ACCENT})"
|
PS1+="$(__prompt_color ${fg_1_rgb})"
|
||||||
|
|
||||||
# Show nix shell name.
|
# Show nix shell name.
|
||||||
if [ -n "${NIX_SHELL}" ]; then
|
if [ -n "${NIX_SHELL}" ]; then
|
||||||
|
|
|
@ -1,19 +1,3 @@
|
||||||
set $aqua 689d68
|
|
||||||
set $bg 1d2021
|
|
||||||
set $bg_1 504945
|
|
||||||
set $blue 458588
|
|
||||||
set $blue_faded 076678
|
|
||||||
set $darkgray 282828
|
|
||||||
set $fg ebdbb2
|
|
||||||
set $fg_1 fbf1c7
|
|
||||||
set $fg_2 d5c4a1
|
|
||||||
set $gray a89984
|
|
||||||
set $green 98971a
|
|
||||||
set $purple b16286
|
|
||||||
set $red cc241d
|
|
||||||
set $transparent ffffff00
|
|
||||||
set $yellow b8bb26
|
|
||||||
|
|
||||||
# Class Border Bground Text Indicator ChildBorder
|
# Class Border Bground Text Indicator ChildBorder
|
||||||
client.focused #$yellow #$yellow #$fg #$yellow #$yellow
|
client.focused #$yellow #$yellow #$fg #$yellow #$yellow
|
||||||
client.focused_inactive #$bg_1 #5f676a #$fg #484e50 #5f676a
|
client.focused_inactive #$bg_1 #5f676a #$fg #484e50 #5f676a
|
||||||
|
|
Loading…
Reference in a new issue