Compare commits

...

19 Commits

Author SHA1 Message Date
Achim D. Brucker 2d288281ea Added prompt for bazar. 2017-07-13 07:29:32 +01:00
Achim D. Brucker d67abc3685 Added git_prompt. 2017-07-12 07:54:43 +01:00
Achim D. Brucker 654bd88e41 Show Isabelle version at an earlier position in the prompt. 2017-07-12 07:38:19 +01:00
Achim D. Brucker e3e6ad3848 Improved separator for segments of same color (reset color after separator). 2017-07-11 07:32:25 +01:00
Achim D. Brucker c29d74ca50 Introduced separator for segments of same color. 2017-07-11 07:14:32 +01:00
Achim D. Brucker 9a370d8b6d Fixed color setup. 2017-07-10 05:14:19 +01:00
Achim D. Brucker e9298f0e62 Fixed LHORANGE. 2017-07-10 05:03:32 +01:00
Achim D. Brucker abb5fa42fc Fixed and activated prompt_isabelle_env. 2017-07-10 05:02:55 +01:00
Achim D. Brucker 385668f407 Removed double definition of prompt_dir. 2017-07-10 04:21:45 +01:00
Achim D. Brucker 1e8ecfbb67 Prompt: working directory. 2017-07-10 04:15:48 +01:00
Achim D. Brucker 41823a0bef Added logo to prompt and initial color setup. 2017-07-09 22:18:17 +01:00
Achim D. Brucker 92f022e970 Added skeleton for prompt setup (and added keybinding for inactive prompt). 2017-07-08 23:20:15 +01:00
Achim D. Brucker 96b358d303 Prompt: Isabelle version. 2017-07-06 23:07:19 +01:00
Achim D. Brucker 6ed43087ee Prompt: LogicalHacking Logo. 2017-07-05 21:23:29 +01:00
Achim D. Brucker 38840e689e Fixed PL_LARROW name. 2017-07-04 21:48:49 +01:00
Achim D. Brucker aa36d147eb Added basic prompt rendering. 2017-07-03 22:30:13 +01:00
Achim D. Brucker 8b9f3dc24c Defined PowerLine symbols. 2017-07-03 22:19:29 +01:00
Achim D. Brucker 226b81abb8 Added promptpwd(). 2017-07-02 23:06:36 +01:00
Achim D. Brucker e73b0eb486 Initial commit. 2017-07-02 22:52:49 +01:00
1 changed files with 243 additions and 0 deletions

243
themes/logicalhacking.zsh-theme Executable file
View File

@ -0,0 +1,243 @@
# vim:ft=zsh ts=4 sw=2 sts=2
# Copyright (C) 2017 Achim D. Brucker, https://www.brucker.ch
#
# LogicalHacking Theme
# A Agnoster-inspired theme for ZSH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
# Make sure you have a recent version: the code points that Powerline
# uses changed in 2012, and older versions will display incorrectly,
# in confusing ways.
# Generic function for formatting the working directory - in particular,
# it allows zpresto-style shortening of the full path.
promptpwd() {
setopt localoptions extendedglob
local current_pwd="${PWD/#$HOME/~}"
local ret_directory
if [[ "$current_pwd" == (#m)[/~] ]]; then
ret_directory="$MATCH"
unset MATCH
elif zstyle -m ':lh:module:prompt' pwd-length 'full'; then
ret_directory=${PWD}
elif zstyle -m ':lh:module:prompt' pwd-length 'long'; then
ret_directory=${current_pwd}
else
ret_directory="${${${${(@j:/:M)${(@s:/:)current_pwd}##.#?}:h}%/}//\%/%%}/${${current_pwd:t}//\%/%%}"
fi
print "$ret_directory"
}
# Define abstract names for the PowerLine symbols
() {
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
PL_BRANCH=$'\ue0a0' # 
PL_LN=$'\ue0a1' # 
PL_CPADLOCK=$'\ue0a2' # 
PL_BRARROW=$'\ue0b0' # 
PL_RARROW=$'\ue0b1' # 
PL_BLARROW=$'\ue0b2' # 
PL_LARROW=$'\ue0b3' # 
}
# Drawing of segments
CURRENT_BG='NONE'
# Begin a segment
# Takes two arguments, background and foreground. Both can be omitted,
# rendering default background/foreground.
prompt_segment() {
local bg fg
[[ -n $1 ]] && bg="%K{$1}" || bg="%k"
[[ -n $2 ]] && fg="%F{$2}" || fg="%f"
if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} "
else
if [[ $CURRENT_BG != 'NONE' ]]; then
echo -n "%{$bg%}%{$fg%}$SEGMENT_SEPARATOR_SAME_COLOR"
fi
echo -n "%{$bg%}%{$fg%}"
fi
CURRENT_BG=$1
[[ -n $3 ]] && echo -n $3
}
# End the prompt, closing any open segments
prompt_end() {
if [[ -n $CURRENT_BG ]]; then
echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
else
echo -n "%{%k%}"
fi
echo -n "%{%f%}"
CURRENT_BG=''
}
# Prompt: LH Logo
prompt_logo() {
prompt_segment $1 $2 "{*λH*}"
}
# Prompt: working directory
prompt_dir() {
prompt_segment $1 $2 "$(promptpwd)"
}
# Prompt: Isabelle Version
isa_version_cmd (){
echo `Isabelle version | sed -e 's/:.*//' -e 's/Isabelle//'`
}
isa_version_dir() {
echo `which isabelle | sed -e 's/.*Isabelle//' -e 's/.bin.*//'`
}
prompt_isabelle_env() {
ISADIR=false
if [[ -f ROOT || -f ROOTS ]]; then
ISADIR=true
else
if (){ setopt localoptions nonomatch nocshnullglob; [ -f *.thy([1]) ] }
then
ISADIR=true
fi
fi
if [ "$ISADIR" = true ]; then
prompt_segment $1 $2 "(Isabelle $( $ISAVERSION ))"
fi
}
# Prompt: git information (branch/detached head, dirty status)
prompt_git() {
(( $+commands[git] )) || return
local PL_BRANCH_CHAR
() {
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
PL_BRANCH_CHAR=$'\ue0a0' # 
}
local ref dirty mode repo_path
repo_path=$(git rev-parse --git-dir 2>/dev/null)
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
dirty=$(parse_git_dirty)
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"
if [[ -n $dirty ]]; then
prompt_segment "$1" "$3"
else
prompt_segment "$2" "$3"
fi
if [[ -e "${repo_path}/BISECT_LOG" ]]; then
mode=" <B>"
elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then
mode=" >M<"
elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then
mode=" >R>"
fi
setopt promptsubst
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' get-revision true
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' stagedstr '✚'
zstyle ':vcs_info:*' unstagedstr '●'
zstyle ':vcs_info:*' formats ' %u%c'
zstyle ':vcs_info:*' actionformats ' %u%c'
vcs_info
echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
fi
}
# Prompt: Bazar
prompt_bzr() {
(( $+commands[bzr] )) || return
if (bzr status >/dev/null 2>&1); then
status_mod=`bzr status | head -n1 | grep "modified" | wc -m`
status_all=`bzr status | head -n1 | wc -m`
revision=`bzr log | head -n2 | tail -n1 | sed 's/^revno: //'`
if [[ $status_mod -gt 0 ]] ; then
prompt_segment $1 $3
echo -n "bzr@"$revision "✚ "
else
if [[ $status_all -gt 0 ]] ; then
prompt_segment $1 $3
echo -n "bzr@"$revision
else
prompt_segment $2 $3
echo -n "bzr@"$revision
fi
fi
fi
}
# Prompt Setup and key bindings
build_prompt() {
RETVAL=$?
prompt_logo $LHORANGE black
prompt_isabelle_env $LHCYAN black
prompt_dir $LHLIGHTORANGE black
prompt_git $LHYELLOW $LHGREEN black
prompt_bzr $LHYELLOW $LHGREEN black
prompt_end
}
build_inactive_prompt() {
RETVAL=$?
prompt_logo $LHDARKGRAY white
prompt_isabelle_env $LHLIGHTGRAY white
prompt_dir $LHLIGHTGRAY white
prompt_git $LHDARKGRAY $LHDARKGRAY white
prompt_bzr $LHDARKGRAY $LHDARKGRAY white
prompt_end
}
del-prompt-accept-line() {
OLD_PROMPT="$PROMPT"
PROMPT=$INACTIVEPROMPT
zle reset-prompt
PROMPT="$OLD_PROMPT"
zle accept-line
}
zle -N del-prompt-accept-line
bindkey "^M" del-prompt-accept-line
# Actual prompt definition
PROMPT='%{%f%b%k%}$(build_prompt) '
INACTIVEPROMPT='%{%f%b%k%}$(build_inactive_prompt) '
# Default configuration
SEGMENT_SEPARATOR=$PL_BRARROW
SEGMENT_SEPARATOR_SAME_COLOR=" %{$fg[black]%}$PL_RARROW "
ISAVERSION=isa_version_dir
if [[ "$TERM" =~ ".*256.*" ]]; then
LHORANGE="166"
LHLIGHTORANGE="172"
LHDARKGRAY="235"
LHLIGHTGRAY="008"
LHCYAN="014"
LHYELLOW="003"
LHGREEN="002"
else
LHORANGE="068"
LHLIGHTORANGE="016"
LHDARKGRAY="019"
LHLIGHTGRAY="008"
LHCYAN="014"
LHYELLOW="003"
LHGREEN="002"
fi