parent
e123cb4676
commit
1897ad3dde
@ -0,0 +1,181 @@
|
||||
# Created by thomasba <mail@thomasba·de>
|
||||
|
||||
prompt_tba_help () {
|
||||
cat <<EOH
|
||||
This prompt is color-scheme-able. You can invoke it thus:
|
||||
|
||||
prompt tba [<text-color> [<parentheses-color> [<time-pwd-color>]]]
|
||||
|
||||
The default colors are white cyan. This theme works best with
|
||||
a dark background.
|
||||
EOH
|
||||
}
|
||||
|
||||
prompt_tba_setup () {
|
||||
local text_col=${1:-'white'}
|
||||
local parens_col=${2:-'cyan'}
|
||||
local time_col=${3:-'yellow'}
|
||||
|
||||
local text="%b%F{$text_col}"
|
||||
local parens="%b%F{$parens_col}"
|
||||
local punct="%B%F{black}"
|
||||
local reset="%b%f"
|
||||
|
||||
local lpar="$parens($text"
|
||||
local rpar="$parens)$text"
|
||||
|
||||
local time_color="%b%F{$time_col}"
|
||||
local hostname="%B%F{green}"
|
||||
local user_color="%b%F{green}"
|
||||
if [[ "$(id -u)" = "0" ]] ; then
|
||||
user_color="%B%F{red}"
|
||||
fi
|
||||
|
||||
precmd () {
|
||||
# let's get the current get branch that we are under
|
||||
# ripped from /etc/bash_completion.d/git from the git devs
|
||||
git_ps1 () {
|
||||
if which git > /dev/null; then
|
||||
local g="$(git rev-parse --git-dir 2>/dev/null)"
|
||||
if [ -n "$g" ]; then
|
||||
local r
|
||||
local b
|
||||
local date=$(git log --pretty=format:%cd --date=short -n1)
|
||||
local v=$(git describe --tags --always)
|
||||
if [ -d "$g/rebase-apply" ]; then
|
||||
if test -f "$g/rebase-apply/rebasing"; then
|
||||
r="|REBASE"
|
||||
elif test -f "$g/rebase-apply/applying"; then
|
||||
r="|AM"
|
||||
else
|
||||
r="|AM/REBASE"
|
||||
fi
|
||||
b="$(git symbolic-ref HEAD 2>/dev/null)"
|
||||
elif [ -f "$g/rebase-merge/interactive" ]; then
|
||||
r="|REBASE-i"
|
||||
b="$(cat "$g/rebase-merge/head-name")"
|
||||
elif [ -d "$g/rebase-merge" ]; then
|
||||
r="|REBASE-m"
|
||||
b="$(cat "$g/rebase-merge/head-name")"
|
||||
elif [ -f "$g/MERGE_HEAD" ]; then
|
||||
r="|MERGING"
|
||||
b="$(git symbolic-ref HEAD 2>/dev/null)"
|
||||
else
|
||||
if [ -f "$g/BISECT_LOG" ]; then
|
||||
r="|BISECTING"
|
||||
fi
|
||||
if ! b="$(git symbolic-ref HEAD 2>/dev/null)"; then
|
||||
if ! b="$(git describe --exact-match HEAD 2>/dev/null)"; then
|
||||
b="$(cut -c1-7 "$g/HEAD")..."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ -n "$1" ]; then
|
||||
printf "$1·%s·%s" "${b##refs/heads/}$r" "$date" "$v"
|
||||
else
|
||||
printf "%s·%s·%s" "${b##refs/heads/}$r" "$date" "$v"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
printf ""
|
||||
fi
|
||||
}
|
||||
|
||||
GITBRANCH="$(git_ps1)"
|
||||
if [ -n "$GITBRANCH" ] ; then
|
||||
GITBRANCH=" g:$GITBRANCH"
|
||||
fi
|
||||
|
||||
# The following 9 lines of code comes directly from Phil!'s ZSH prompt
|
||||
# http://aperiodic.net/phil/prompt/
|
||||
local TERMWIDTH
|
||||
(( TERMWIDTH = ${COLUMNS} - 1 ))
|
||||
|
||||
#local PROMPTSIZE=${#${(%):--- %D{%R.%S %a %b %d %Y}\! }}
|
||||
local PROMPTSIZE=${#${(%):----%n-%m----0000-00-00 00:00----}}
|
||||
|
||||
local PWDSIZE=${#${(%):-%~}}
|
||||
|
||||
if [[ "$PROMPTSIZE + $PWDSIZE" -gt $TERMWIDTH ]]; then
|
||||
(( PR_PWDLEN = $TERMWIDTH - $PROMPTSIZE ))
|
||||
fi
|
||||
|
||||
# set a simple variable to show when in screen
|
||||
if [[ -n "${WINDOW}" ]]; then
|
||||
SCREEN=" S:${WINDOW}"
|
||||
else
|
||||
SCREEN=""
|
||||
fi
|
||||
|
||||
# check if jobs are executing
|
||||
if [[ $(jobs | wc -l) -gt 0 ]]; then
|
||||
JOBS=" J:%j"
|
||||
else
|
||||
JOBS=""
|
||||
fi
|
||||
|
||||
# I want to know my battery percentage when running on battery power
|
||||
if which acpi &> /dev/null; then
|
||||
local BATTSTATE="$(acpi -b 2> /dev/null)"
|
||||
local BATTPRCNT="$(echo ${BATTSTATE[(w)4]}|sed -r 's/(^[0-9]+).*/\1/')"
|
||||
if [[ -z "${BATTPRCNT}" ]]; then
|
||||
PR_BATTERY=""
|
||||
elif [[ "${BATTPRCNT}" -lt 20 ]]; then
|
||||
PR_BATTERY=" ${PR_BOLD_RED}B:${BATTPRCNT}%%"
|
||||
elif [[ "${BATTPRCNT}" -lt 40 ]]; then
|
||||
PR_BATTERY=" ${PR_BOLD_YELLOW}B:${BATTPRCNT}%%"
|
||||
else
|
||||
PR_BATTERY=" B:${BATTPRCNT}%%"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
IS_SSH_CONN=""
|
||||
if [ -n "$SSH_CONNECTION" ] ; then
|
||||
IS_SSH_CONN=" ${PR_RED}⚡$PR_NO_COLOR "
|
||||
fi
|
||||
}
|
||||
|
||||
# If I am using vi keys, I want to know what mode I'm currently using.
|
||||
# zle-keymap-select is executed every time KEYMAP changes.
|
||||
# From http://zshwiki.org/home/examples/zlewidgets
|
||||
zle-keymap-select() {
|
||||
VIMODE="${${KEYMAP/vicmd/ vim:command}/(main|viins)}"
|
||||
RPROMPT2="${PR_BOLD_BLUE}${VIMODE}"
|
||||
zle reset-prompt
|
||||
}
|
||||
zle -N zle-keymap-select
|
||||
|
||||
|
||||
PS1="$parens┌─[ $user_color%n$text@$hostname%m$reset $parens]─($reset$time_color%D{%Y-%m-%d %H:%M}$reset$parens)─→ \
|
||||
$reset$time_color%\${PR_PWDLEN}<...<%~%<<\
|
||||
$reset\
|
||||
|
||||
$parens├─($reset\${IS_SSH_CONN}$text\${PR_BATTERY}\${SCREEN}\${JOBS}%(?.. ${PR_RED}E:%?$reset)\
|
||||
\${GITBRANCH} $parens)$reset\
|
||||
|
||||
$parens└─[%(!.#.$)]${text} "
|
||||
PS2="$parens└─[$reset $parens%_$reset $parens]──→$reset "
|
||||
PS3="$parens╶─[$text?#$parens]──→$reset "
|
||||
PS4="$parens├──→$reset "
|
||||
prompt_opts=(cr subst percent)
|
||||
}
|
||||
|
||||
prompt_tba_preview () {
|
||||
local color colors
|
||||
colors=(red yellow green blue magenta)
|
||||
|
||||
if (( ! $#* )); then
|
||||
for (( i = 1; i <= $#colors; i++ )); do
|
||||
color=$colors[$i]
|
||||
prompt_preview_theme tba $color
|
||||
(( i < $#colors )) && print
|
||||
done
|
||||
else
|
||||
prompt_preview_theme tba "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
prompt_tba_setup "$@"
|
||||
|
||||
# Vim: set ft=zsh :
|
@ -1,161 +0,0 @@
|
||||
# prompts for zsh
|
||||
|
||||
setopt ALL_EXPORT
|
||||
|
||||
autoload colors zsh/terminfo
|
||||
|
||||
if [[ "$terminfo[colors]" -ge 8 ]]; then
|
||||
colors
|
||||
fi
|
||||
|
||||
PR_NO_COLOR="$terminfo[sgr0]"
|
||||
|
||||
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE BLACK; do
|
||||
eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
|
||||
eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
|
||||
eval BG_$color='%{$terminfo[bold]$bg[${(L)color}]%}'
|
||||
eval BG_LIGHT_$color='%{$bg[${(L)color}]%}'
|
||||
(( count = $count + 1 ))
|
||||
done
|
||||
PR_NO_COLOR="%{$terminfo[sgr0]%}"
|
||||
|
||||
PR_USER_COLOR=$PR_CYAN
|
||||
if [[ "`whoami`" = "root" ]]; then
|
||||
PR_USER_COLOR=$PR_RED
|
||||
else
|
||||
PR_USER_COLOR=$PR_LIGHT_GREEN
|
||||
fi
|
||||
|
||||
function precmd {
|
||||
# let's get the current get branch that we are under
|
||||
# ripped from /etc/bash_completion.d/git from the git devs
|
||||
git_ps1 () {
|
||||
if which git > /dev/null; then
|
||||
local g="$(git rev-parse --git-dir 2>/dev/null)"
|
||||
if [ -n "$g" ]; then
|
||||
local r
|
||||
local b
|
||||
local date=$(git log --pretty=format:%cd --date=short -n1)
|
||||
local v=$(git describe --tags --always)
|
||||
if [ -d "$g/rebase-apply" ]; then
|
||||
if test -f "$g/rebase-apply/rebasing"; then
|
||||
r="|REBASE"
|
||||
elif test -f "$g/rebase-apply/applying"; then
|
||||
r="|AM"
|
||||
else
|
||||
r="|AM/REBASE"
|
||||
fi
|
||||
b="$(git symbolic-ref HEAD 2>/dev/null)"
|
||||
elif [ -f "$g/rebase-merge/interactive" ]; then
|
||||
r="|REBASE-i"
|
||||
b="$(cat "$g/rebase-merge/head-name")"
|
||||
elif [ -d "$g/rebase-merge" ]; then
|
||||
r="|REBASE-m"
|
||||
b="$(cat "$g/rebase-merge/head-name")"
|
||||
elif [ -f "$g/MERGE_HEAD" ]; then
|
||||
r="|MERGING"
|
||||
b="$(git symbolic-ref HEAD 2>/dev/null)"
|
||||
else
|
||||
if [ -f "$g/BISECT_LOG" ]; then
|
||||
r="|BISECTING"
|
||||
fi
|
||||
if ! b="$(git symbolic-ref HEAD 2>/dev/null)"; then
|
||||
if ! b="$(git describe --exact-match HEAD 2>/dev/null)"; then
|
||||
b="$(cut -c1-7 "$g/HEAD")..."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ -n "$1" ]; then
|
||||
printf "$1·%s·%s" "${b##refs/heads/}$r" "$date" "$v"
|
||||
else
|
||||
printf "%s·%s·%s" "${b##refs/heads/}$r" "$date" "$v"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
printf ""
|
||||
fi
|
||||
}
|
||||
|
||||
GITBRANCH="$(git_ps1)"
|
||||
if [ -n "$GITBRANCH" ] ; then
|
||||
GITBRANCH=" g:$GITBRANCH"
|
||||
fi
|
||||
|
||||
# The following 9 lines of code comes directly from Phil!'s ZSH prompt
|
||||
# http://aperiodic.net/phil/prompt/
|
||||
local TERMWIDTH
|
||||
(( TERMWIDTH = ${COLUMNS} - 1 ))
|
||||
|
||||
#local PROMPTSIZE=${#${(%):--- %D{%R.%S %a %b %d %Y}\! }}
|
||||
local PROMPTSIZE=${#${(%):----%n-%m----%D{%Y-%m-%d %H:%M}----}}
|
||||
|
||||
local PWDSIZE=${#${(%):-%~}}
|
||||
|
||||
if [[ "$PROMPTSIZE + $PWDSIZE" -gt $TERMWIDTH ]]; then
|
||||
(( PR_PWDLEN = $TERMWIDTH - $PROMPTSIZE ))
|
||||
fi
|
||||
|
||||
# set a simple variable to show when in screen
|
||||
if [[ -n "${WINDOW}" ]]; then
|
||||
SCREEN=" S:${WINDOW}"
|
||||
else
|
||||
SCREEN=""
|
||||
fi
|
||||
|
||||
# check if jobs are executing
|
||||
if [[ $(jobs | wc -l) -gt 0 ]]; then
|
||||
JOBS=" J:%j"
|
||||
else
|
||||
JOBS=""
|
||||
fi
|
||||
|
||||
# I want to know my battery percentage when running on battery power
|
||||
if which acpi &> /dev/null; then
|
||||
local BATTSTATE="$(acpi -b)"
|
||||
local BATTPRCNT="$(echo ${BATTSTATE[(w)4]}|sed -r 's/(^[0-9]+).*/\1/')"
|
||||
if [[ -z "${BATTPRCNT}" ]]; then
|
||||
PR_BATTERY=""
|
||||
elif [[ "${BATTPRCNT}" -lt 20 ]]; then
|
||||
PR_BATTERY="${PR_BOLD_RED}B:${BATTPRCNT}%%"
|
||||
elif [[ "${BATTPRCNT}" -lt 50 ]]; then
|
||||
PR_BATTERY="${PR_BOLD_YELLOW}B:${BATTPRCNT}%%"
|
||||
else
|
||||
PR_BATTERY="B:${BATTPRCNT}%%"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# If I am using vi keys, I want to know what mode I'm currently using.
|
||||
# zle-keymap-select is executed every time KEYMAP changes.
|
||||
# From http://zshwiki.org/home/examples/zlewidgets
|
||||
zle-keymap-select() {
|
||||
VIMODE="${${KEYMAP/vicmd/ vim:command}/(main|viins)}"
|
||||
RPROMPT2="${PR_BOLD_BLUE}${VIMODE}"
|
||||
zle reset-prompt
|
||||
}
|
||||
|
||||
zle -N zle-keymap-select
|
||||
|
||||
|
||||
function setprompt() {
|
||||
setopt prompt_subst
|
||||
IS_SSH_CONN=""
|
||||
if [ -n "$SSH_CONNECTION" ] ; then
|
||||
IS_SSH_CONN=" ${PR_RED}⚡$PR_NO_COLOR "
|
||||
fi
|
||||
PROMPT="$PR_LIGHT_CYAN┌─[ $PR_USER_COLOR%n$PR_WHITE@$PR_GREEN%m$PR_NO_COLOR $PR_LIGHT_CYAN]─($PR_NO_COLOR$PR_LIGHT_YELLOW%D{%Y-%m-%d %H:%M}$PR_NO_COLOR$PR_LIGHT_CYAN)─→ \
|
||||
$PR_NO_COLOR$PR_LIGHT_YELLOW%\${PR_PWDLEN}<...<%~%<<\
|
||||
$PR_NO_COLOR\
|
||||
|
||||
$PR_LIGHT_CYAN├─(\${IS_SSH_CONN}$PR_NO_COLOR\${PR_BATTERY}\${SCREEN}\${JOBS}%(?.. ${PR_RED}E:%?${PR_NO_COLOR} )\
|
||||
\${GITBRANCH}$PR_LIGHT_CYAN)$PR_NO_COLOR\
|
||||
|
||||
${PR_LIGHT_CYAN}└─[%(!.#.$)]${PR_NO_COLOR} "
|
||||
}
|
||||
setprompt
|
||||
PS2="$PR_LIGHT_CYAN└─[$PR_NO_COLOR $PR_WHITE%_$PR_NO_COLOR $PR_LIGHT_CYAN]──→$PR_NO_COLOR "
|
||||
|
||||
PS3="$PR_LIGHT_CYAN╶─[$PR_NO_COLOR?#$PR_LIGHT_CYAN]──→$PR_NO_COLOR "
|
||||
PS4="$fg[${cyan}]├──→$terminfo[sgr0] "
|
||||
|
||||
# vim: ft=zsh :
|
@ -1,99 +0,0 @@
|
||||
# Set name of the theme to load.
|
||||
# Look in ~/.oh-my-zsh/themes/
|
||||
# Optionally, if you set this to "random", it'll load a random theme each
|
||||
# time that oh-my-zsh is loaded.
|
||||
#ZSH_THEME="mortalscumbag"
|
||||
#ZSH_THEME="af-magic"
|
||||
ZSH_THEME="../../../zsh/thomasba"
|
||||
|
||||
# Uncomment the following line to use case-sensitive completion.
|
||||
# CASE_SENSITIVE="true"
|
||||
|
||||
# Uncomment the following line to disable bi-weekly auto-update checks.
|
||||
# DISABLE_AUTO_UPDATE="true"
|
||||
|
||||
# Uncomment the following line to change how often to auto-update (in days).
|
||||
# export UPDATE_ZSH_DAYS=13
|
||||
|
||||
# Uncomment the following line to disable colors in ls.
|
||||
# DISABLE_LS_COLORS="true"
|
||||
|
||||
# Uncomment the following line to disable auto-setting terminal title.
|
||||
# DISABLE_AUTO_TITLE="true"
|
||||
|
||||
# Uncomment the following line to enable command auto-correction.
|
||||
ENABLE_CORRECTION="true"
|
||||
|
||||
# Uncomment the following line to display red dots whilst waiting for completion.
|
||||
COMPLETION_WAITING_DOTS="true"
|
||||
|
||||
# Uncomment the following line if you want to disable marking untracked files
|
||||
# under VCS as dirty. This makes repository status check for large repositories
|
||||
# much, much faster.
|
||||
# DISABLE_UNTRACKED_FILES_DIRTY="true"
|
||||
|
||||
# Uncomment the following line if you want to change the command execution time
|
||||
# stamp shown in the history command output.
|
||||
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
|
||||
HIST_STAMPS="yyyy-mm-dd"
|
||||
|
||||
# Would you like to use another custom folder than $ZSH/custom?
|
||||
# ZSH_CUSTOM=/path/to/new-custom-folder
|
||||
|
||||
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
|
||||
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
|
||||
# Example format: plugins=(rails git textmate ruby lighthouse)
|
||||
# Add wisely, as too many plugins slow down shell startup.
|
||||
plugins=(git docker rand-quote sublime sudo web-search pass)
|
||||
|
||||
# User configuration
|
||||
|
||||
export PATH="$PATH:$HOME/.gem/ruby/2.1.0/bin"
|
||||
# export MANPATH="/usr/local/man:$MANPATH"
|
||||
|
||||
source $ZSH/oh-my-zsh.sh
|
||||
source $HOME/.zsh/programs
|
||||
source $HOME/.zsh/commands
|
||||
case "$MTYPE" in
|
||||
"PC")
|
||||
source $HOME/.zsh/commands-pc
|
||||
;;
|
||||
"SERVER")
|
||||
source $HOME/.zsh/commands-server
|
||||
;;
|
||||
esac
|
||||
if [ -f "$HOME/.zsh/rbenv" -a -d "$HOME/.rbenv" ] ; then
|
||||
source $HOME/.zsh/rbenv
|
||||
fi
|
||||
if [ -d "$HOME/bin" ] ; then
|
||||
export PATH="$PATH:$HOME/bin"
|
||||
fi
|
||||
|
||||
source $HOME/.zsh/git-commands
|
||||
# You may need to manually set your language environment
|
||||
# export LANG=en_US.UTF-8
|
||||
|
||||
# Preferred editor for local and remote sessions
|
||||
# if [[ -n $SSH_CONNECTION ]]; then
|
||||
export EDITOR='vim'
|
||||
# else
|
||||
# export EDITOR='mvim'
|
||||
# fi
|
||||
|
||||
# Compilation flags
|
||||
# export ARCHFLAGS="-arch x86_64"
|
||||
|
||||
# Set personal aliases, overriding those provided by oh-my-zsh libs,
|
||||
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
|
||||
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
|
||||
# For a full list of active aliases, run `alias`.
|
||||
#
|
||||
# Example aliases
|
||||
alias zshconfig="vim ~/.zsh"
|
||||
alias ohmyzsh="vim ~/.zsh/oh-my-zsh"
|
||||
|
||||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
|
||||
zstyle ':completion:*:*:kill:*:processes' command 'ps --forest -A -o pid,user,cmd'
|
||||
zstyle ':completion:*:processes-names' command 'ps axho command'
|
||||
|
||||
# vim: ft=zsh :
|
@ -0,0 +1,27 @@
|
||||
source $HOME/.zsh/commands
|
||||
source $HOME/.zsh/programs
|
||||
case "$MTYPE" in
|
||||
"PC")
|
||||
source $HOME/.zsh/commands-pc
|
||||
;;
|
||||
"SERVER")
|
||||
source $HOME/.zsh/commands-server
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -f "$HOME/.zsh/rbenv" -a -d "$HOME/.rbenv" ] ; then
|
||||
source $HOME/.zsh/rbenv
|
||||
fi
|
||||
|
||||
if [ -d "$HOME/bin" ] ; then
|
||||
export PATH="$PATH:$HOME/bin"
|
||||
fi
|
||||
|
||||
if [ -f "/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ] ; then
|
||||
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
else
|
||||
printf "-!- zsh-syntax-highlighting not installed!"
|
||||
fi
|
||||
|
||||
export EDITOR='vim'
|
||||
|
Loading…
Reference in new issue