summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Schlosser <christoph@linux.com>2025-06-18 19:01:01 +0200
committerChristoph Schlosser <christoph@linux.com>2025-06-18 19:01:01 +0200
commit887655467ff1aea63dbbd612d475677d15e63940 (patch)
treea0a4571dcf731ba04affd382a200e7e74de9de4b
parentad7b9498811a016c654cf7ad894cc1d079110ec0 (diff)
downloadc-star-887655467ff1aea63dbbd612d475677d15e63940.tar.gz
Add powerline styling
-rw-r--r--conf.d/c_star.fish57
-rw-r--r--functions/fish_prompt.fish19
-rw-r--r--functions/fish_right_prompt.fish19
3 files changed, 77 insertions, 18 deletions
diff --git a/conf.d/c_star.fish b/conf.d/c_star.fish
index bea307c..7d42ce6 100644
--- a/conf.d/c_star.fish
+++ b/conf.d/c_star.fish
@@ -1,37 +1,62 @@
-set -q c_star_prompt_symbol || set -g c_star_prompt_symbol ">"
set -q c_star_date_format || set -g c_star_date_format "%Y-%m-%dT%H:%M:%S%z"
+set -q c_star_user_bg || set -g c_star_user_bg a9b7c6
+set -q c_star_user_fg || set -g c_star_user_fg 333333
+set -q c_star_pwd_bg || set -g c_star_pwd_bg $c_star_user_fg
+set -q c_star_pwd_fg || set -g c_star_pwd_fg $c_star_user_bg
+set -q c_star_git_bg || set -g c_star_git_bg $c_star_user_bg
+set -q c_star_git_fg || set -g c_star_git_fg $c_star_user_fg
+set -q c_star_user_marker_default_bg || set -g c_star_user_marker_default_bg $c_star_user_fg
+set -q c_star_user_marker_fg || set -g c_star_user_marker_fg $c_star_user_bg
+set -q c_star_datetime_bg || set -g c_star_datetime_bg $c_star_user_fg
+set -q c_star_datetime_fg || set -g c_star_datetime_fg $c_star_user_bg
+set -q c_star_command_time_bg || set -g c_star_command_time_bg $c_star_user_bg
+set -q c_star_command_time_fg || set -g c_star_command_time_fg $c_star_user_fg
-function c_star_command_time --on-event fish_postexec
- set -g c_star_command_time $CMD_DURATION'ms'
+function c_star_colorize
+ set -l bg $argv[3]
+ set -l fg $argv[4]
+ set -g "$argv[1]" "$(set_color -b $bg $fg) $argv[2] $(set_color normal)"
end
-function c_star_datetime --on-event fish_prompt --on-event fish_postexec --on-variable c_star_date_format
- set -g c_star_datetime (date "+$c_star_date_format")
+# TODO: Clear this after enter?
+function c_star_command_time --on-event fish_postexec --on-variable c_star_command_time_bg --on-variable c_star_command_time_fg
+ c_star_colorize c_star_command_time $CMD_DURATION'ms' $c_star_command_time_bg $c_star_command_time_fg
end
-function c_star_git --on-variable PWD
- set -g c_star_git "$(fish_git_prompt)"
+function c_star_datetime --on-event fish_prompt --on-event fish_postexec --on-variable c_star_date_format --on-variable c_star_datetime_bg --on-variable c_star_datetime_fg
+ c_star_colorize c_star_datetime (date "+$c_star_date_format") $c_star_datetime_bg $c_star_datetime_fg
end
-function c_star_user --on-event fish_prompt
- set -g c_star_user "$(whoami)"
+function c_star_git --on-event fish_prompt --on-variable PWD --on-variable c_star_git_bg --on-variable c_star_git_fg
+ set -lx __fish_git_prompt_show_informative_status 1
+ set -l git_status (fish_git_prompt)
+ if test -n "$git_status"
+ c_star_colorize c_star_git $git_status $c_star_git_bg $c_star_git_fg
+ else
+ set -ge c_star_git
+ end
end
-function c_star_host --on-event fish_prompt
+function c_star_user --on-event fish_prompt --on-variable c_star_user_bg --on-variable c_star_user_fg --on-variable SSH_CONNECTION
+ set -l user_string (whoami)
if test -n "$SSH_CONNECTION"
- set -g c_star_host "@$(hostname)"
+ set -f user_string "$user_string@$(hostname)"
end
+ c_star_colorize c_star_user "$user_string" $c_star_user_bg $c_star_user_fg
end
-function c_star_user_marker --on-event fish_prompt
+function c_star_user_marker --on-event fish_prompt --on-variable c_star_user_marker_default_bg --on-variable c_star_user_marker_fg
switch (whoami)
case "root"
- set -g c_star_user_marker "$(set_color red)#$(set_color normal)"
+ set -g c_star_user_marker_bg red
+ set -f char "#"
case '*'
- set -g c_star_user_marker '$'
+ set -g c_star_user_marker_bg $c_star_user_marker_default_bg
+ set -f char "\$"
end
+ c_star_colorize c_star_user_marker $char $c_star_user_marker_bg $c_star_user_marker_fg
end
-function c_star_pwd --on-variable PWD --on-event fish_prompt
- set -g c_star_pwd "$(prompt_pwd)"
+function c_star_pwd --on-variable PWD --on-event fish_prompt --on-variable c_star_pwd_bg --on-variable c_star_pwd_fg
+ c_star_colorize c_star_pwd (prompt_pwd) $c_star_pwd_bg $c_star_pwd_fg
end \ No newline at end of file
diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish
index 4d29852..832d8e8 100644
--- a/functions/fish_prompt.fish
+++ b/functions/fish_prompt.fish
@@ -1,3 +1,20 @@
+function c_star_segment_divide_left
+ set -l from_var "c_star_$argv[1]"
+ set -l from_name "$from_var""_bg"
+ set -l from $$from_name
+ set -l to_var "c_star_$argv[2]"
+ set -l to_name "$to_var""_bg"
+ set -l to $$to_name
+
+ if test -z "$$from_var"
+ return
+ end
+ if test -z "$$to_var"
+ set -f to normal
+ end
+ echo (set_color -b $to $from)\uE0B0(set_color normal)
+end
+
function fish_prompt --description "The left side of the C-Star prompt"
- echo -e "$c_star_user$c_star_host $c_star_pwd $c_star_git\n$c_star_user_marker$c_star_prompt_symbol "
+ echo -e "$c_star_user$c_star_host$(c_star_segment_divide_left user pwd)$c_star_pwd$(c_star_segment_divide_left pwd git)$c_star_git$(c_star_segment_divide_left git normal)\n$c_star_user_marker$(c_star_segment_divide_left user_marker normal) "
end \ No newline at end of file
diff --git a/functions/fish_right_prompt.fish b/functions/fish_right_prompt.fish
index 34eb6ef..89cc89d 100644
--- a/functions/fish_right_prompt.fish
+++ b/functions/fish_right_prompt.fish
@@ -1,3 +1,20 @@
+function c_star_segment_divide_right
+ set -l from_var "c_star_$argv[1]"
+ set -l from_name "$from_var""_bg"
+ set -l from $$from_name
+ set -l to_var "c_star_$argv[2]"
+ set -l to_name "$to_var""_bg"
+ set -l to $$to_name
+
+ if test -z "$$from_var"
+ return
+ end
+ if test -z "$$to_var"
+ set -f to normal
+ end
+ echo (set_color -b $to $from)\uE0B2(set_color normal)
+end
+
function fish_right_prompt --description "The right side of the C-Star prompt"
- echo -e "$c_star_command_time $c_star_datetime"
+ echo -e "$(c_star_segment_divide_right command_time normal)$c_star_command_time$(c_star_segment_divide_right datetime command_time)$c_star_datetime"
end \ No newline at end of file