From 7fd2092f9fb542309b831498262a03d999d23272 Mon Sep 17 00:00:00 2001 From: thomasba Date: Thu, 17 Sep 2015 22:19:41 +0200 Subject: [PATCH] new zsh-config: 2nd step --- install | 27 ++++++++++++++++----------- zsh/commands | 2 ++ zsh/prompt_tba_setup | 12 +++++++----- zsh/zshrc.local | 9 +++++++++ 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/install b/install index 352bad2..aa25770 100755 --- a/install +++ b/install @@ -81,14 +81,21 @@ fi cecho cyan "Installing zsh config" backup_file "~/.zsh" backup_file "~/.zshrc" -symlink "~/.zsh" "${MY_PATH}/zsh" -if [ -d "${MY_PATH}/opt/oh-my-zsh/.git" ] ; then - cecho green " + Pulling oh-my-zsh ..." - (cd "${MY_PATH}/opt/oh-my-zsh" && git pull -q) + +# check if grml is installed +grep grml\.org /etc/zsh/zshrc > /dev/null +if [ $? -ne 0 ] ; then + echo " + Installing grml ..." + wget -O ~/.zshrc http://git.grml.org/f/grml-etc-core/etc/zsh/zshrc + cecho yellow " ! You might wanna install grml-zsh-config using your packet manager" + cecho yellow " ! and remove the .zshrc file in your home directory. " else - cecho green " + Cloning oh-my-zsh ..." - git clone -q https://github.com/robbyrussell/oh-my-zsh.git "${MY_PATH}/opt/oh-my-zsh" + cecho green " . grml-zsh-config is already installed :-)" fi + + +symlink "~/.zsh" "${MY_PATH}/zsh" +symlink "~/.zshrc.local" "${MY_PATH}/zsh/zshrc.local" while [ ! "$MTYPE" == "PC" -a ! "$MTYPE" == "SERVER" ] ; do cecho ask " ? Is this a server of a PC? [s|p] > " read mt @@ -101,17 +108,15 @@ while [ ! "$MTYPE" == "PC" -a ! "$MTYPE" == "SERVER" ] ; do cecho red " ! Invalid input";; esac done -cecho green " + Creating .zshrc ... " +cecho green " + Creating .zshrc.pre ... " ( echo "# Path to your oh-my-zsh configuration." - echo "ZSH=${CONFIG_MY_PATH}/opt/oh-my-zsh" + echo "ZSH=${CONFIG_MY_PATH}/.zsh" echo "# current user" echo "export DEFAULT_USER=\"\$(whoami)\"" echo "# machine type" echo "export MTYPE=\"$MTYPE\"" - echo "# load zshrc" - echo "source \${HOME}/.zsh/zshrc" -) > ~/.zshrc +) > ~/.zshrc.pre ######## # tmux # diff --git a/zsh/commands b/zsh/commands index 2cc3698..e35f5b5 100644 --- a/zsh/commands +++ b/zsh/commands @@ -17,6 +17,8 @@ alias logo='exit' alias logout='exit' alias -g NUL="> /dev/null 2>&1" +alias -g V="|vim -" +alias -g R="|tr N-ZA-Mn-za-m A-Za-z" # functions diff --git a/zsh/prompt_tba_setup b/zsh/prompt_tba_setup index ee268d8..61d3acc 100644 --- a/zsh/prompt_tba_setup +++ b/zsh/prompt_tba_setup @@ -25,6 +25,8 @@ prompt_tba_setup () { local rpar="$parens)$text" local time_color="%b%F{$time_col}" + local red="%B%F{red}" + local yellow="%B%F{yellow}" local hostname="%B%F{green}" local user_color="%b%F{green}" if [[ "$(id -u)" = "0" ]] ; then @@ -121,9 +123,9 @@ prompt_tba_setup () { if [[ -z "${BATTPRCNT}" ]]; then PR_BATTERY="" elif [[ "${BATTPRCNT}" -lt 20 ]]; then - PR_BATTERY=" ${PR_BOLD_RED}B:${BATTPRCNT}%%" + PR_BATTERY=" $redB:${BATTPRCNT}%%" elif [[ "${BATTPRCNT}" -lt 40 ]]; then - PR_BATTERY=" ${PR_BOLD_YELLOW}B:${BATTPRCNT}%%" + PR_BATTERY=" $yellowB:${BATTPRCNT}%%" else PR_BATTERY=" B:${BATTPRCNT}%%" fi @@ -132,7 +134,7 @@ prompt_tba_setup () { IS_SSH_CONN="" if [ -n "$SSH_CONNECTION" ] ; then - IS_SSH_CONN=" ${PR_RED}⚡$PR_NO_COLOR " + IS_SSH_CONN=" $red⚡$PR_NO_COLOR " fi } @@ -151,7 +153,7 @@ prompt_tba_setup () { $reset$time_color%\${PR_PWDLEN}<...<%~%<<\ $reset\ -$parens├─($reset\${IS_SSH_CONN}$text\${PR_BATTERY}\${SCREEN}\${JOBS}%(?.. ${PR_RED}E:%?$reset)\ +$parens├─($reset\${IS_SSH_CONN}$text\${PR_BATTERY}\${SCREEN}\${JOBS}%(?.. ${red}E:%?$reset)\ \${GITBRANCH} $parens)$reset\ $parens└─[%(!.#.$)]${text} " @@ -176,6 +178,6 @@ prompt_tba_preview () { fi } -prompt_tba_setup "$@" +#prompt_tba_setup "$@" # Vim: set ft=zsh : diff --git a/zsh/zshrc.local b/zsh/zshrc.local index 3eedd98..015707d 100644 --- a/zsh/zshrc.local +++ b/zsh/zshrc.local @@ -1,3 +1,12 @@ +if zrcautoload promptinit && promptinit 2>/dev/null ; then + source ~/.zsh/prompt_tba_setup + prompt_themes+=( tba ) + prompt_themes=( "${(@on)prompt_themes}" ) + prompt tba +else + print '-!- Notice: no promptinit available :(' +fi + source $HOME/.zsh/commands source $HOME/.zsh/programs case "$MTYPE" in