From ebf99b520af78ad8ed6ccc8cf074bfa823f89e80 Mon Sep 17 00:00:00 2001 From: Candifloss Date: Mon, 16 Dec 2024 06:02:22 +0000 Subject: [PATCH] Add fish/config.fish --- fish/config.fish | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 fish/config.fish diff --git a/fish/config.fish b/fish/config.fish new file mode 100644 index 0000000..fad6a12 --- /dev/null +++ b/fish/config.fish @@ -0,0 +1,43 @@ +set -U fish_greeting "" + +function fish_prompt + # Check the last command status and set the error color + if test $status -eq 0 + set error_color "\033[38;2;0;255;180m" # rgb(0, 255, 180) for success + else + set error_color "\033[38;2;255;53;94m" # rgb(255, 53, 94) for error + end + + # Get SSH session status + if test -n "$SSH_CONNECTION" + set ssh_color "\033[38;2;255;149;0m" # rgb(255, 149, 0) for SSH + else + set ssh_color "\033[38;2;82;82;82m" # rgb(82, 82, 82) for non-SSH + end + + # Try to get the git branch, avoid error if not in a git repo + set git_color "\033[38;2;82;82;82m" # Default git color when not in a git repo + if test -d .git + set git_branch (git rev-parse --abbrev-ref HEAD) + if test -n "$git_branch" + switch $git_branch + case 'main' 'master' + set git_color "\033[38;2;178;98;44m" # rgb(178, 98, 44) for main/master + case 'dev' + set git_color "\033[38;2;54;159;150m" # rgb(54, 159, 150) for dev + case '*' + set git_color "\033[38;2;255;255;255m" # rgb(255, 255, 255) for other branches + end + end + end + + # Set the user color + if test $USER = "root" + set user_color "\033[38;2;255;53;94m" # rgb(255, 53, 94) for root + else + set user_color "\033[38;2;0;255;180m" # rgb(0, 255, 180) for non-root users + end + + # Print the custom prompt with the symbol and different colors + echo -n -e "$ssh_color❯$git_color❯$user_color❯$error_color❯\033[0m " +end \ No newline at end of file