aboutsummaryrefslogtreecommitdiffstats
path: root/zsh
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2016-11-06 02:44:21 +0100
committerJohannes Löthberg <johannes@kyriasis.com>2017-06-01 18:37:35 +0200
commit9188fba3b14c331744b8593138f9496adea4ea60 (patch)
tree2c7ab948dab8a538ddccbd35c86ffde407ded2a7 /zsh
parentb8934837f867f14d219b3360ce5407aae9dd005e (diff)
downloaddotfiles-9188fba3b14c331744b8593138f9496adea4ea60.tar.xz
zsh: Use the ZSH prompt system for prompt
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Diffstat (limited to 'zsh')
-rw-r--r--zsh/.zshrc4
-rw-r--r--zsh/prompt.zsh67
-rw-r--r--zsh/themes/prompt_kyrias_setup39
3 files changed, 42 insertions, 68 deletions
diff --git a/zsh/.zshrc b/zsh/.zshrc
index 4ed147d..4e21f7e 100644
--- a/zsh/.zshrc
+++ b/zsh/.zshrc
@@ -2,6 +2,7 @@ HISTFILE=~/.config/zsh/.zsh_history
HISTSIZE=500000
SAVEHIST=500000
+fpath+=("$XDG_CONFIG_HOME/zsh/themes")
zstyle :compinstall filename "$ZDOTDIR"/.zshrc
# Menu completion
@@ -42,7 +43,6 @@ zmodload zsh/mapfile
source "$ZDOTDIR"/keybindings.zsh
source "$ZDOTDIR"/aliases.zsh # aliases and functions.
-source "$ZDOTDIR"/prompt.zsh # sets the prompt
if [[ -n "$VTE_VERSION" ]]; then
source /etc/profile.d/vte.sh
@@ -55,3 +55,5 @@ fi
GPG_TTY=$(tty)
export GPG_TTY
+
+prompt kyrias
diff --git a/zsh/prompt.zsh b/zsh/prompt.zsh
deleted file mode 100644
index c83b2da..0000000
--- a/zsh/prompt.zsh
+++ /dev/null
@@ -1,67 +0,0 @@
-# Red
-bg[light_pink]='%K{001}'
-bg[light_red]='%K{196}'
-bg[red]='%K{88}'
-bg[dark_red]='%K{52}'
-
-fg[light_pink]='%F{001}'
-fg[light_red]='%F{196}'
-fg[red]='%F{88}'
-fg[dark_red]='%F{52}'
-
-
-# Yellow
-bg[light_gold]='%K{136}'
-bg[gold]='%K{139}'
-bg[dark_gold]='%K{94}'
-
-fg[light_gold]='%F{136}'
-fg[gold]='%F{139}'
-fg[dark_gold]='%F{94}'
-
-
-# Blue
-bg[light_blue]='%K{blue}'
-bg[blue]='%K{21}'
-
-fg[light_blue]='%F{blue}'
-fg[blue]='%F{21}'
-
-
-# Green
-bg[dark_green]='%K{64}'
-
-function virtualenv_prompt {
- if [[ -n "$VIRTUAL_ENV" ]]; then
- print "$bg[light_blue]$fg[white] $(basename $VIRTUAL_ENV) %f%k"
- fi
-}
-
-if (( UID == 0 )); then
- PROMPT='$bg[light_red] $fg[white]%m%f %k$bg[white]$fg[light_red] %~ %f%k$(virtualenv_prompt)
-$bg[light_blue] λ %k '
-
-else
- case $SHORTHOST in
- "theos")
- PROMPT='$bg[light_pink] $fg[white]%m%f %k$bg[white]$fg[light_pink] %~ %f%k$(virtualenv_prompt)
-$bg[light_blue] λ %k '
- ;;
-
- "lucifer")
- PROMPT='$bg[dark_gold] $fg[white]%m%f %k$bg[white]$fg[dark_gold] %~ %f%k$(virtualenv_prompt)
-$bg[light_blue] λ %k '
- ;;
-
- "nymeria")
- PROMPT='$bg[dark_green] $fg[white]%m%f %k$bg[white]$fg[dark_gold] %~ %f%k$(virtualenv_prompt)
-$bg[light_blue] λ %k '
- ;;
-
- *)
- PROMPT='$bg[black] $fg[white]%m%f %k$bg[white]$fg[black] %~ %f%k$(virtualenv_prompt)
-$bg[light_blue] λ %k '
- ;;
-
- esac
-fi
diff --git a/zsh/themes/prompt_kyrias_setup b/zsh/themes/prompt_kyrias_setup
new file mode 100644
index 0000000..68dbfd8
--- /dev/null
+++ b/zsh/themes/prompt_kyrias_setup
@@ -0,0 +1,39 @@
+prompt_kyrias_help() {
+ cat <<EOF
+kyrias' prompt.
+EOF
+}
+
+prompt_user_color() {
+ if (( ! UID )); then
+ print "red"
+ else
+ print "black"
+ fi
+}
+
+venv_prompt() {
+ if [[ -n "$VIRTUAL_ENV" ]]; then
+ print -P '%{$bg[blue]$fg[white] ${VIRTUAL_ENV##*/} %f%k%}'
+ fi
+}
+
+prompt_kyrias_precmd() {
+ print -Pn "\e];%n %~\a"
+}
+
+prompt_kyrias_setup() {
+ setopt prompt_subst
+ autoload -U colors && colors
+
+ PROMPT='%{$bg[$(prompt_user_color)]$fg[white] %m %k%f$bg[white]$fg[$(prompt_user_color)] %~ %f%k$(venv_prompt)
+$bg[blue]%} λ %k %}'
+}
+
+prompt_kyrias_preview() {
+ prompt_preview_theme kyrias "$@"
+}
+
+prompt_kyrias_setup "$@"
+
+# vim: ft=zsh