aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/fish_fallback_prompt.fish
diff options
context:
space:
mode:
authorGravatar Fabian Homborg <FHomborg@gmail.com>2015-08-17 17:32:45 +0200
committerGravatar Fabian Homborg <FHomborg@gmail.com>2015-08-30 18:30:03 +0200
commitf71e877f18037f71c00f81e30c1173f51c42a58c (patch)
tree73a88a49c05770d144c14f67e66fb773252eac05 /share/functions/fish_fallback_prompt.fish
parentd6c97a6a1379526bc2c84210efc5f562a61ffb6d (diff)
Improve situation for linux in-kernel VTs (TERM = "linux")
This adds a special colorscheme and prompt function guaranteed to work on a VT and activates them automatically if $TERM = "linux". set_color is overridden to only allow the 8 colors VTs have (under the assumption those are always the same) and the color variables are shadowed with global ones so they don't pollute our nice capable terms.
Diffstat (limited to 'share/functions/fish_fallback_prompt.fish')
-rw-r--r--share/functions/fish_fallback_prompt.fish27
1 files changed, 27 insertions, 0 deletions
diff --git a/share/functions/fish_fallback_prompt.fish b/share/functions/fish_fallback_prompt.fish
new file mode 100644
index 00000000..ae4fa021
--- /dev/null
+++ b/share/functions/fish_fallback_prompt.fish
@@ -0,0 +1,27 @@
+# vim: set noet:
+#
+# Set the default prompt command.
+
+function fish_fallback_prompt --description "A simple fallback prompt without too much color or special characters for linux VTs"
+ # Just calculate this once, to save a few cycles when displaying the prompt
+ if not set -q __fish_prompt_hostname
+ set -g __fish_prompt_hostname (hostname|cut -d . -f 1)
+ end
+
+ set -l color_cwd
+ set -l suffix
+ switch $USER
+ case root toor
+ if set -q fish_color_cwd_root
+ set color_cwd $fish_color_cwd_root
+ else
+ set color_cwd $fish_color_cwd
+ end
+ set suffix '#'
+ case '*'
+ set color_cwd $fish_color_cwd
+ set suffix '>'
+ end
+
+ echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' (set_color $color_cwd) (prompt_pwd) (set_color normal) "$suffix "
+end