aboutsummaryrefslogtreecommitdiff
path: root/config/all/zsh/20-appearance.zsh
diff options
context:
space:
mode:
authorMatt Singleton <matt@xcolour.net>2023-02-03 14:39:07 -0600
committerMatt Singleton <matt@xcolour.net>2023-02-03 14:39:07 -0600
commite9dc4c1090abb01317847c417b75d3960f3da34d (patch)
tree2fb84cf24675f1294f9f7a33ea949d514844c6f1 /config/all/zsh/20-appearance.zsh
parent969f76a8238e2d43a25740c8272bf635d436f0d3 (diff)
only install platform-appropriate configs based on uname
Diffstat (limited to 'config/all/zsh/20-appearance.zsh')
-rw-r--r--config/all/zsh/20-appearance.zsh79
1 files changed, 79 insertions, 0 deletions
diff --git a/config/all/zsh/20-appearance.zsh b/config/all/zsh/20-appearance.zsh
new file mode 100644
index 0000000..4f7c8d9
--- /dev/null
+++ b/config/all/zsh/20-appearance.zsh
@@ -0,0 +1,79 @@
+#
+# colorize shell programs
+
+if ls -Z . &>/dev/null 2>&1; then
+ # gnu coreutils?
+ alias ls='ls --color=auto'
+ eval `dircolors ${XDG_CONFIG_HOME:-${HOME}/.config}/dircolors.conf`
+elif (( $+commands[gls] )); then
+ # prefixed gnu coreutils?
+ alias ls='gls --color=auto'
+ eval `gdircolors ${XDG_CONFIG_HOME:-${HOME}/.config}/dircolors.conf`
+else
+ # assume bsd ls
+ alias ls='ls -G'
+ export LSCOLORS="exgxbxdxcxegedxbxgxcxd"
+fi
+
+# grep
+export GREP_COLOR='1;32'
+alias grep='grep --color=auto'
+alias egrep='egrep --color=auto'
+alias fgrep='fgrep --color=auto'
+
+# less
+export LESS_TERMCAP_mb=$'\e[0;31m' # begin blinking - red
+export LESS_TERMCAP_md=$'\e[0;34m' # begin bold - blue
+export LESS_TERMCAP_me=$'\e[0m' # end mode
+export LESS_TERMCAP_so=$'\e[30;46m' # begin standout mode - black on cyan
+export LESS_TERMCAP_se=$'\e[0m' # end standout mode
+export LESS_TERMCAP_us=$'\e[4;33m' # begin underline - yellow underline
+export LESS_TERMCAP_ue=$'\e[0m' # end underline
+
+#
+# make a sweet prompt
+
+autoload colors; colors;
+setopt prompt_subst # expansion of color codes, etc. in the prompt
+
+# print the fully resolved shell command with time stamp
+# to be run from zsh's builtin 'preexec' with all arguments passed through ($*)
+function theme_preexec () {
+ echo "($fg[magenta]`date +%r`$reset_color) $fg[cyan]$3$reset_color"
+}
+
+# print the prompt char in red if the last command exited non-zero
+function prompt_char {
+ echo "%(?.$.%{$fg[red]%}$%{$reset_color%})"
+}
+
+function repo_prompt_info {
+ # git
+ ref=$(git symbolic-ref HEAD 2> /dev/null || git rev-parse --short HEAD 2> /dev/null)
+ if [ $? -eq 0 ]; then
+ #repo=$(basename $(git rev-parse --show-toplevel))
+ echo "%{$fg[cyan]%}%{\e[1m%}${ref#refs/heads/}%{$reset_color%}"
+ return
+ fi
+}
+
+function workspace_prompt_info {
+ repo=$(repo_prompt_info)
+ if [ "$repo" ]; then
+ echo "[$repo] "
+ return
+ fi
+}
+
+# print the hostname in green if local, else red
+function hostname_info {
+ if [[ $ZSH_LOCAL_ENV == "true" ]]; then
+ echo "%{$fg[green]%}%{$ZSH_HOST_PREFIX%}%m%{$ZSH_HOST_SUFFIX%}%{$reset_color%}"
+ else
+ echo "%{$fg[red]%}%{$ZSH_HOST_PREFIX%}%m%{$ZSH_HOST_SUFFIX%}%{$reset_color%}"
+ fi
+}
+
+# a colorful multiline prompt using the above defined functions
+PROMPT=$'%{$fg[yellow]%}%n%{$reset_color%}@$(hostname_info):%{$fg[blue]%}%~%{$reset_color%}
+$(workspace_prompt_info)$(prompt_char)%{$reset_color%} '