From 1d03499b3bd518bafb6b1dfd7725ba4a2a111a92 Mon Sep 17 00:00:00 2001 From: Ciacho Date: Mon, 7 Mar 2016 12:31:04 +0100 Subject: [PATCH 1/6] New theme - Ciacho --- themes/ciacho.zsh-theme | 139 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 themes/ciacho.zsh-theme diff --git a/themes/ciacho.zsh-theme b/themes/ciacho.zsh-theme new file mode 100644 index 000000000..c361fb097 --- /dev/null +++ b/themes/ciacho.zsh-theme @@ -0,0 +1,139 @@ +CIACHO_VERSION="0.1d" +function my_git_prompt() { + tester=$(git rev-parse --git-dir 2> /dev/null) || return + + INDEX=$(git status --porcelain 2> /dev/null) + STATUS="" + + # is branch ahead? + if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD" + fi + + # is anything staged? + if $(echo "$INDEX" | grep -E -e '^(D[ M]|[MARC][ MD]) ' &> /dev/null); then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED" + fi + + # is anything unstaged? + if $(echo "$INDEX" | grep -E -e '^[ MARC][MD] ' &> /dev/null); then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED" + fi + + # is anything untracked? + if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED" + fi + + # is anything unmerged? + if $(echo "$INDEX" | grep -E -e '^(A[AU]|D[DU]|U[ADU]) ' &> /dev/null); then + STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED" + fi + + if [[ -n $STATUS ]]; then + STATUS=" $STATUS" + fi + + echo "$ZSH_THEME_GIT_PROMPT_PREFIX$(my_current_branch)$STATUS$ZSH_THEME_GIT_PROMPT_SUFFIX" +} + +function my_current_branch() { + echo $(current_branch || echo "(no branch)") +} + +function ssh_connection() { + if [[ -n $SSH_CONNECTION ]]; then + echo "%{$fg_bold[green]%}(ssh)%{$reset_color%} " + elif [[ -n $SUDO_USER ]]; then + echo "%{$fg_bold[red]%}(sudo)%{$reset_color%} " + fi +} + +function vps_check() { + if [[ -f /etc/vps ]]; then + echo "%{$fg_bold[red]%}(VPS)%{$reset_color%} " + fi +} + +function ciacho_version() { + if [[ -n $CIACHO_VERSION ]]; then + echo " %{$fg_bold[blue]%}($CIACHO_VERSION)%{$reset_color%} " + fi +} + +function locale_check() { + if [[ $LANG == "pl_PL.UTF-8" ]]; then + L_CODETITLE="%{$fg_bold[green]%}(UTF)%{$reset_color%} " + elif [[ $LANG == "pl_PL" ]]; then + L_CODETITLE="%{$fg_bold[white]%}(ISO)%{$reset_color%} " +# else +# L_CODETITLE="%{$fg_bold[green]%}(ISO)%{$reset_color%} " + fi + echo $L_CODETITLE +} + + if [[ $( whoami ) == root && -f /etc/vps ]]; then + ## czerwony @ bialy + l_user="%{$fg_bold[red]%}%n%{$reset_color%}" + l_host="%{$fg_bold[white]%}%m%{$reset_color%}" + l_pwd="%{$fg_bold[red]%}%#%{$reset_color%}" + elif [[ $( whoami ) == root ]]; then + ## czerwony @ cyan + l_user="%{$fg_bold[red]%}%n%{$reset_color%}" + l_host="%{$fg_bold[cyan]%}%m%{$reset_color%}" + l_pwd="%{$fg_bold[red]%}%#%{$reset_color%}" + elif [[ $( hostname ) == jail || -f /etc/vps ]]; then + ## bialy @ czerwony + l_user="%{$fg_bold[white]%}%n%{$reset_color%}" + l_host="%{$fg_bold[red]%}%m%{$reset_color%}" + l_pwd="%{$fg_bold[white]%}%#%{$reset_color%}" + elif [[ $( hostname ) == "Varacolaci.local" ]]; then + ## bialy @ czerwony + l_user="%{$fg_bold[blue]%}%n%{$reset_color%}" + l_host="%{$fg_bold[red]%}%m%{$reset_color%}" + l_pwd="%{$fg_bold[white]%}%#%{$reset_color%}" +# elif [[ $( hostname ) == "Varacolaci.local" ]]; then +# l_user=$PR_BLUE"%n"$PR_RESET" "$PR_BOLD_RED"%m"$PR_RESET +# elif [[ $( uname ) == Darwin ]]; then +# l_user=$PR_BLUE"%n"$PR_RESET" "$PR_BLUE"%m"$PR_RESET + else + l_user="%{$fg_bold[green]%}%n%{$reset_color%}" + l_host="%{$fg_bold[green]%}%m%{$reset_color%}" + l_pwd="%{$fg_bold[green]%}%#%{$reset_color%}" + fi +function user_check() { + echo "$l_user@$l_host" +} + + +function ciacho_battery() { + if [[ $(uname) == "Darwin" ]] ; then + if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then + b=$(battery_pct) + if [ $b -gt 50 ] ; then + color='green' + elif [ $b -gt 20 ] ; then + color='yellow' + else + color='red' + fi + echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%} :" + else + echo "%{$fg[yellow]%}[∞]%{$reset_color%} :" + fi + + fi +} + +#PROMPT=$'\n$(ssh_connection)$(vps_check)$(locale_check)$(user_check)%{$reset_color%}$(ciacho_version)$(my_git_prompt) : %~\n%# ' +PROMPT=$'\n$(ssh_connection)$(vps_check)$(locale_check)$(user_check)%{$reset_color%}$(ciacho_version)$(my_git_prompt) : $(ciacho_battery) %~\n$l_pwd ' + +ZSH_THEME_PROMPT_RETURNCODE_PREFIX="%{$fg_bold[red]%}" +ZSH_THEME_GIT_PROMPT_PREFIX=" $fg[white]‹ %{$fg_bold[yellow]%}" +ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg_bold[magenta]%}↑" +ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[green]%}●" +ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[red]%}●" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[white]%}●" +ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg_bold[red]%}✕" +ZSH_THEME_GIT_PROMPT_SUFFIX=" $fg_bold[white]›%{$reset_color%}" + From 1f81403867bc23b7308fdfa72023d9355c5db5d9 Mon Sep 17 00:00:00 2001 From: Ciacho Date: Mon, 7 Mar 2016 12:32:14 +0100 Subject: [PATCH 2/6] new alias for nmap - nmap_ping_scan --- plugins/nmap/README.md | 1 + plugins/nmap/nmap.plugin.zsh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/nmap/README.md b/plugins/nmap/README.md index 5cd646277..66142f899 100644 --- a/plugins/nmap/README.md +++ b/plugins/nmap/README.md @@ -34,4 +34,5 @@ Nmap options are: * nmap_traceroute - Try to traceroute using the most common ports * nmap_full_with_scripts - Same as nmap_full but also runs all the scripts * nmap_web_safe_osscan - Little "safer" scan for OS version as connecting to only HTTP and HTTPS ports doesn't look so attacking. + * nmap_ping_scan - Scan subnets over ICMP diff --git a/plugins/nmap/nmap.plugin.zsh b/plugins/nmap/nmap.plugin.zsh index d09f2c615..613e0fc53 100644 --- a/plugins/nmap/nmap.plugin.zsh +++ b/plugins/nmap/nmap.plugin.zsh @@ -29,4 +29,4 @@ alias nmap_full_udp="nmap -sS -sU -T4 -A -v -PE -PS22,25,80 -PA21,23,80,443,3389 alias nmap_traceroute="nmap -sP -PE -PS22,25,80 -PA21,23,80,3389 -PU -PO --traceroute " alias nmap_full_with_scripts="sudo nmap -sS -sU -T4 -A -v -PE -PP -PS21,22,23,25,80,113,31339 -PA80,113,443,10042 -PO --script all " alias nmap_web_safe_osscan="sudo nmap -p 80,443 -O -v --osscan-guess --fuzzy " - +alias nmap_ping_scan="nmap -n -sP" From d5eab2ec71d08ade9565f148e65631e542b4d079 Mon Sep 17 00:00:00 2001 From: Ciacho Date: Mon, 7 Mar 2016 16:15:56 +0100 Subject: [PATCH 3/6] Update theme ciacho --- themes/ciacho.zsh-theme | 321 +++++++++++++++++++++++++--------------- 1 file changed, 205 insertions(+), 116 deletions(-) diff --git a/themes/ciacho.zsh-theme b/themes/ciacho.zsh-theme index c361fb097..464dc275e 100644 --- a/themes/ciacho.zsh-theme +++ b/themes/ciacho.zsh-theme @@ -1,112 +1,66 @@ -CIACHO_VERSION="0.1d" -function my_git_prompt() { - tester=$(git rev-parse --git-dir 2> /dev/null) || return - - INDEX=$(git status --porcelain 2> /dev/null) - STATUS="" +# vim:ft=zsh ts=2 sw=2 sts=2 +# +# Ciacho Theme +# Based on agnoster theme +# 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. - # is branch ahead? - if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD" + +CIACHO_VERSION="0.2" + + +### Segment drawing +# A few utility functions to make it easy and re-usable to draw segmented prompts + +CURRENT_BG='NONE' +PRIMARY_FG=black + +#SEGMENT_SEPARATOR=" " +SEGMENT_SEPARATOR="\ue0b0" + +PLUSMINUS="\u00b1" +BRANCH="\ue0a0" +BRANCH_BEGIN="‹ \ue0a0" +BRANCH_END="›" +DETACHED="\u27a6" +CROSS="\u2718" +LIGHTNING="\u26a1" +GEAR="\u2699" + + +# 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 -ne "%{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%}" + else + echo -ne "%{$bg%}%{$fg%}" fi - - # is anything staged? - if $(echo "$INDEX" | grep -E -e '^(D[ M]|[MARC][ MD]) ' &> /dev/null); then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED" - fi - - # is anything unstaged? - if $(echo "$INDEX" | grep -E -e '^[ MARC][MD] ' &> /dev/null); then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED" - fi - - # is anything untracked? - if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED" - fi - - # is anything unmerged? - if $(echo "$INDEX" | grep -E -e '^(A[AU]|D[DU]|U[ADU]) ' &> /dev/null); then - STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED" - fi - - if [[ -n $STATUS ]]; then - STATUS=" $STATUS" - fi - - echo "$ZSH_THEME_GIT_PROMPT_PREFIX$(my_current_branch)$STATUS$ZSH_THEME_GIT_PROMPT_SUFFIX" + CURRENT_BG=$1 + [[ -n $3 ]] && echo -n $3 } -function my_current_branch() { - echo $(current_branch || echo "(no branch)") -} - -function ssh_connection() { - if [[ -n $SSH_CONNECTION ]]; then - echo "%{$fg_bold[green]%}(ssh)%{$reset_color%} " - elif [[ -n $SUDO_USER ]]; then - echo "%{$fg_bold[red]%}(sudo)%{$reset_color%} " - fi -} - -function vps_check() { - if [[ -f /etc/vps ]]; then - echo "%{$fg_bold[red]%}(VPS)%{$reset_color%} " +# End the prompt, closing any open segments +prompt_end() { + if [[ -n $CURRENT_BG ]]; then + echo -ne "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" + else + echo -ne "%{%k%}" fi + echo -ne "%{%f%}" + CURRENT_BG='' } -function ciacho_version() { - if [[ -n $CIACHO_VERSION ]]; then - echo " %{$fg_bold[blue]%}($CIACHO_VERSION)%{$reset_color%} " - fi -} - -function locale_check() { - if [[ $LANG == "pl_PL.UTF-8" ]]; then - L_CODETITLE="%{$fg_bold[green]%}(UTF)%{$reset_color%} " - elif [[ $LANG == "pl_PL" ]]; then - L_CODETITLE="%{$fg_bold[white]%}(ISO)%{$reset_color%} " -# else -# L_CODETITLE="%{$fg_bold[green]%}(ISO)%{$reset_color%} " - fi - echo $L_CODETITLE -} - - if [[ $( whoami ) == root && -f /etc/vps ]]; then - ## czerwony @ bialy - l_user="%{$fg_bold[red]%}%n%{$reset_color%}" - l_host="%{$fg_bold[white]%}%m%{$reset_color%}" - l_pwd="%{$fg_bold[red]%}%#%{$reset_color%}" - elif [[ $( whoami ) == root ]]; then - ## czerwony @ cyan - l_user="%{$fg_bold[red]%}%n%{$reset_color%}" - l_host="%{$fg_bold[cyan]%}%m%{$reset_color%}" - l_pwd="%{$fg_bold[red]%}%#%{$reset_color%}" - elif [[ $( hostname ) == jail || -f /etc/vps ]]; then - ## bialy @ czerwony - l_user="%{$fg_bold[white]%}%n%{$reset_color%}" - l_host="%{$fg_bold[red]%}%m%{$reset_color%}" - l_pwd="%{$fg_bold[white]%}%#%{$reset_color%}" - elif [[ $( hostname ) == "Varacolaci.local" ]]; then - ## bialy @ czerwony - l_user="%{$fg_bold[blue]%}%n%{$reset_color%}" - l_host="%{$fg_bold[red]%}%m%{$reset_color%}" - l_pwd="%{$fg_bold[white]%}%#%{$reset_color%}" -# elif [[ $( hostname ) == "Varacolaci.local" ]]; then -# l_user=$PR_BLUE"%n"$PR_RESET" "$PR_BOLD_RED"%m"$PR_RESET -# elif [[ $( uname ) == Darwin ]]; then -# l_user=$PR_BLUE"%n"$PR_RESET" "$PR_BLUE"%m"$PR_RESET - else - l_user="%{$fg_bold[green]%}%n%{$reset_color%}" - l_host="%{$fg_bold[green]%}%m%{$reset_color%}" - l_pwd="%{$fg_bold[green]%}%#%{$reset_color%}" - fi -function user_check() { - echo "$l_user@$l_host" -} - - -function ciacho_battery() { +function prompt_ciacho_battery() { + local symbols +symbols=() if [[ $(uname) == "Darwin" ]] ; then if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then b=$(battery_pct) @@ -117,23 +71,158 @@ function ciacho_battery() { else color='red' fi - echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%} :" - else - echo "%{$fg[yellow]%}[∞]%{$reset_color%} :" + symbols+="$LIGHTNING %{%F{$color}%}[$(battery_pct_remaining)%%]%}" + prompt_segment red default "$symbols" fi - fi } -#PROMPT=$'\n$(ssh_connection)$(vps_check)$(locale_check)$(user_check)%{$reset_color%}$(ciacho_version)$(my_git_prompt) : %~\n%# ' -PROMPT=$'\n$(ssh_connection)$(vps_check)$(locale_check)$(user_check)%{$reset_color%}$(ciacho_version)$(my_git_prompt) : $(ciacho_battery) %~\n$l_pwd ' -ZSH_THEME_PROMPT_RETURNCODE_PREFIX="%{$fg_bold[red]%}" -ZSH_THEME_GIT_PROMPT_PREFIX=" $fg[white]‹ %{$fg_bold[yellow]%}" -ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg_bold[magenta]%}↑" -ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[green]%}●" -ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[red]%}●" -ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[white]%}●" -ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg_bold[red]%}✕" -ZSH_THEME_GIT_PROMPT_SUFFIX=" $fg_bold[white]›%{$reset_color%}" +function prompt_ciacho_status() { + local symbols + symbols=() + [[ -n $SSH_CLIENT ]] && symbols+="%{%F{cyan}[SSH]" + [[ -f /etc/vps ]] && symbols+="%{%F{yellow}[VPS]" + [[ $UID -eq 0 ]] && symbols+="%{%F{red}%}[ROOT]" + [[ $LANG == "pl_PL.UTF-8" ]] && symbols+="%{%F{green}%}[UTF]" + [[ $LANG == "pl_PL" ]] && symbols+="%{%F{green}%}[ISO]" + + [[ -n "$symbols" ]] && prompt_segment black default "$symbols " +} + +prompt_ciacho_git() { + local color ref + is_dirty() { + test -n "$(git status --porcelain --ignore-submodules)" + } + ref="$vcs_info_msg_0_" + if [[ -n "$ref" ]]; then + if is_dirty; then + color=yellow + ref="${ref} $PLUSMINUS" + else + color=green + ref="${ref} " + fi + if [[ "${ref/.../}" == "$ref" ]]; then + ref="$BRANCH_BEGIN $ref $BRANCH_END" + else + ref="$DETACHED ${ref/.../}" + fi + prompt_segment $color $PRIMARY_FG + print -Pn " $ref" + fi +} + +prompt_ciacho_hg() { + local rev status + if $(hg id >/dev/null 2>&1); then + if $(hg prompt >/dev/null 2>&1); then + if [[ $(hg prompt "{status|unknown}") = "?" ]]; then + # if files are not added + prompt_segment red white + st='±' + elif [[ -n $(hg prompt "{status|modified}") ]]; then + # if any modification + prompt_segment yellow black + st='±' + else + # if working copy is clean + prompt_segment green black + fi + echo -n $(hg prompt "☿ {rev}@{branch}") $st + else + st="" + rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') + branch=$(hg id -b 2>/dev/null) + if `hg st | grep -q "^\?"`; then + prompt_segment red black + st='±' + elif `hg st | grep -q "^[MA]"`; then + prompt_segment yellow black + st='±' + else + prompt_segment green black + fi + echo -n "☿ $rev@$branch" $st + fi + fi +} + +# Dir: current working directory +prompt_ciacho_dir() { + prompt_segment blue $PRIMARY_FG ' %~' +} + + +# Context: user@hostname (who am I and where am I) +prompt_ciacho_context() { + local uid_color + local host_color + + if [[ $(whoami) == root ]]; then + # red @ cyan + uid_color=red + host_color=white + elif [[ $(uname) == Darwin ]]; then + uid_color=cyan + host_color=cyan + elif [[ $(uname) == Darwin && $(whoami) == root ]]; then + uid_color=red + host_color=cyan + else + uid_color=white + host_color=white + fi + prompt_segment black default "%(!.%{%F{$uid_color}%}.)$USER%(!.%{%F{white}%}.)@%(!.%{%F{$host_color}%}.)%m" + +} + +prompt_ciacho_hash() { + if [[ $(whoami) == root ]]; then + prompt_segment red $PRIMARY_FG "\n %#" + else + prompt_segment blue $PRIMARY_FG "\n %#" + fi +} + +prompt_ciacho_main() { + RETVAL=$? + prompt_ciacho_status + prompt_ciacho_battery + prompt_ciacho_context + prompt_ciacho_git + prompt_ciacho_hg + prompt_ciacho_dir + prompt_end + prompt_ciacho_hash + prompt_end + +} + + +prompt_ciacho_precmd() { + vcs_info + PROMPT='%{%f%b%k%}$(prompt_ciacho_main) ' +} + + +prompt_ciacho_setup() { + autoload -Uz add-zsh-hook + autoload -Uz vcs_info + + prompt_opts=(cr subst percent) + + add-zsh-hook precmd prompt_ciacho_precmd + + zstyle ':vcs_info:*' enable git + zstyle ':vcs_info:*' check-for-changes false + zstyle ':vcs_info:git*' formats '%b' + zstyle ':vcs_info:git*' actionformats '%b (%a)' +} + +prompt_ciacho_setup "$@" + + +PROMPT='%{%f%b%k%}$(build_prompt) ' From 2d4822a05ff9abe855263cb1a85e1b8468deb8bc Mon Sep 17 00:00:00 2001 From: Ciacho Date: Tue, 8 Mar 2016 08:57:31 +0100 Subject: [PATCH 4/6] update theme --- themes/ciacho.zsh-theme | 57 ++++++++--------------------------------- 1 file changed, 10 insertions(+), 47 deletions(-) diff --git a/themes/ciacho.zsh-theme b/themes/ciacho.zsh-theme index 464dc275e..364264c04 100644 --- a/themes/ciacho.zsh-theme +++ b/themes/ciacho.zsh-theme @@ -23,7 +23,7 @@ SEGMENT_SEPARATOR="\ue0b0" PLUSMINUS="\u00b1" BRANCH="\ue0a0" -BRANCH_BEGIN="‹ \ue0a0" +BRANCH_BEGIN="‹" BRANCH_END="›" DETACHED="\u27a6" CROSS="\u2718" @@ -39,22 +39,22 @@ prompt_segment() { [[ -n $1 ]] && bg="%K{$1}" || bg="%k" [[ -n $2 ]] && fg="%F{$2}" || fg="%f" if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then - echo -ne "%{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%}" + print -n "%{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%}" else - echo -ne "%{$bg%}%{$fg%}" + print -n "%{$bg%}%{$fg%}" fi CURRENT_BG=$1 - [[ -n $3 ]] && echo -n $3 + [[ -n $3 ]] && print -n $3 } # End the prompt, closing any open segments prompt_end() { if [[ -n $CURRENT_BG ]]; then - echo -ne "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" + print -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" else - echo -ne "%{%k%}" + print -n "%{%k%}" fi - echo -ne "%{%f%}" + print -n "%{%f%}" CURRENT_BG='' } @@ -82,11 +82,11 @@ symbols=() function prompt_ciacho_status() { local symbols symbols=() - [[ -n $SSH_CLIENT ]] && symbols+="%{%F{cyan}[SSH]" - [[ -f /etc/vps ]] && symbols+="%{%F{yellow}[VPS]" [[ $UID -eq 0 ]] && symbols+="%{%F{red}%}[ROOT]" [[ $LANG == "pl_PL.UTF-8" ]] && symbols+="%{%F{green}%}[UTF]" [[ $LANG == "pl_PL" ]] && symbols+="%{%F{green}%}[ISO]" + [[ -n $SSH_CLIENT ]] && symbols+="%{%F{cyan}[SSH]" + [[ -f /etc/vps ]] && symbols+="%{%F{yellow}[VPS]" [[ -n "$symbols" ]] && prompt_segment black default "$symbols " } @@ -106,7 +106,7 @@ prompt_ciacho_git() { ref="${ref} " fi if [[ "${ref/.../}" == "$ref" ]]; then - ref="$BRANCH_BEGIN $ref $BRANCH_END" + ref="$BRANCH_BEGIN $BRANCH $ref $BRANCH_END" else ref="$DETACHED ${ref/.../}" fi @@ -115,41 +115,6 @@ prompt_ciacho_git() { fi } -prompt_ciacho_hg() { - local rev status - if $(hg id >/dev/null 2>&1); then - if $(hg prompt >/dev/null 2>&1); then - if [[ $(hg prompt "{status|unknown}") = "?" ]]; then - # if files are not added - prompt_segment red white - st='±' - elif [[ -n $(hg prompt "{status|modified}") ]]; then - # if any modification - prompt_segment yellow black - st='±' - else - # if working copy is clean - prompt_segment green black - fi - echo -n $(hg prompt "☿ {rev}@{branch}") $st - else - st="" - rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') - branch=$(hg id -b 2>/dev/null) - if `hg st | grep -q "^\?"`; then - prompt_segment red black - st='±' - elif `hg st | grep -q "^[MA]"`; then - prompt_segment yellow black - st='±' - else - prompt_segment green black - fi - echo -n "☿ $rev@$branch" $st - fi - fi -} - # Dir: current working directory prompt_ciacho_dir() { prompt_segment blue $PRIMARY_FG ' %~' @@ -193,7 +158,6 @@ prompt_ciacho_main() { prompt_ciacho_battery prompt_ciacho_context prompt_ciacho_git - prompt_ciacho_hg prompt_ciacho_dir prompt_end prompt_ciacho_hash @@ -225,4 +189,3 @@ prompt_ciacho_setup() { prompt_ciacho_setup "$@" -PROMPT='%{%f%b%k%}$(build_prompt) ' From 4f40c9bc981741df98b225409f719efc31d967a3 Mon Sep 17 00:00:00 2001 From: Ciacho Date: Tue, 8 Mar 2016 09:05:10 +0100 Subject: [PATCH 5/6] update context --- themes/ciacho.zsh-theme | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/themes/ciacho.zsh-theme b/themes/ciacho.zsh-theme index 364264c04..cafaaa3d9 100644 --- a/themes/ciacho.zsh-theme +++ b/themes/ciacho.zsh-theme @@ -129,18 +129,12 @@ prompt_ciacho_context() { if [[ $(whoami) == root ]]; then # red @ cyan uid_color=red - host_color=white elif [[ $(uname) == Darwin ]]; then uid_color=cyan - host_color=cyan - elif [[ $(uname) == Darwin && $(whoami) == root ]]; then - uid_color=red - host_color=cyan else uid_color=white - host_color=white fi - prompt_segment black default "%(!.%{%F{$uid_color}%}.)$USER%(!.%{%F{white}%}.)@%(!.%{%F{$host_color}%}.)%m" + prompt_segment black $uid_color "$USER@%m" } From 053ca76e2d02224036c558cf7151519e683b6c03 Mon Sep 17 00:00:00 2001 From: Ciacho Date: Wed, 9 Mar 2016 10:59:28 +0100 Subject: [PATCH 6/6] remove theme ciacho --- themes/ciacho.zsh-theme | 185 ---------------------------------------- 1 file changed, 185 deletions(-) delete mode 100644 themes/ciacho.zsh-theme diff --git a/themes/ciacho.zsh-theme b/themes/ciacho.zsh-theme deleted file mode 100644 index cafaaa3d9..000000000 --- a/themes/ciacho.zsh-theme +++ /dev/null @@ -1,185 +0,0 @@ -# vim:ft=zsh ts=2 sw=2 sts=2 -# -# Ciacho Theme -# Based on agnoster theme -# 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. - - -CIACHO_VERSION="0.2" - - -### Segment drawing -# A few utility functions to make it easy and re-usable to draw segmented prompts - -CURRENT_BG='NONE' -PRIMARY_FG=black - -#SEGMENT_SEPARATOR=" " -SEGMENT_SEPARATOR="\ue0b0" - -PLUSMINUS="\u00b1" -BRANCH="\ue0a0" -BRANCH_BEGIN="‹" -BRANCH_END="›" -DETACHED="\u27a6" -CROSS="\u2718" -LIGHTNING="\u26a1" -GEAR="\u2699" - - -# 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 - print -n "%{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%}" - else - print -n "%{$bg%}%{$fg%}" - fi - CURRENT_BG=$1 - [[ -n $3 ]] && print -n $3 -} - -# End the prompt, closing any open segments -prompt_end() { - if [[ -n $CURRENT_BG ]]; then - print -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" - else - print -n "%{%k%}" - fi - print -n "%{%f%}" - CURRENT_BG='' -} - -function prompt_ciacho_battery() { - local symbols -symbols=() - if [[ $(uname) == "Darwin" ]] ; then - if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then - b=$(battery_pct) - if [ $b -gt 50 ] ; then - color='green' - elif [ $b -gt 20 ] ; then - color='yellow' - else - color='red' - fi - symbols+="$LIGHTNING %{%F{$color}%}[$(battery_pct_remaining)%%]%}" - prompt_segment red default "$symbols" - fi - fi -} - - - -function prompt_ciacho_status() { - local symbols - symbols=() - [[ $UID -eq 0 ]] && symbols+="%{%F{red}%}[ROOT]" - [[ $LANG == "pl_PL.UTF-8" ]] && symbols+="%{%F{green}%}[UTF]" - [[ $LANG == "pl_PL" ]] && symbols+="%{%F{green}%}[ISO]" - [[ -n $SSH_CLIENT ]] && symbols+="%{%F{cyan}[SSH]" - [[ -f /etc/vps ]] && symbols+="%{%F{yellow}[VPS]" - - [[ -n "$symbols" ]] && prompt_segment black default "$symbols " -} - -prompt_ciacho_git() { - local color ref - is_dirty() { - test -n "$(git status --porcelain --ignore-submodules)" - } - ref="$vcs_info_msg_0_" - if [[ -n "$ref" ]]; then - if is_dirty; then - color=yellow - ref="${ref} $PLUSMINUS" - else - color=green - ref="${ref} " - fi - if [[ "${ref/.../}" == "$ref" ]]; then - ref="$BRANCH_BEGIN $BRANCH $ref $BRANCH_END" - else - ref="$DETACHED ${ref/.../}" - fi - prompt_segment $color $PRIMARY_FG - print -Pn " $ref" - fi -} - -# Dir: current working directory -prompt_ciacho_dir() { - prompt_segment blue $PRIMARY_FG ' %~' -} - - -# Context: user@hostname (who am I and where am I) -prompt_ciacho_context() { - local uid_color - local host_color - - if [[ $(whoami) == root ]]; then - # red @ cyan - uid_color=red - elif [[ $(uname) == Darwin ]]; then - uid_color=cyan - else - uid_color=white - fi - prompt_segment black $uid_color "$USER@%m" - -} - -prompt_ciacho_hash() { - if [[ $(whoami) == root ]]; then - prompt_segment red $PRIMARY_FG "\n %#" - else - prompt_segment blue $PRIMARY_FG "\n %#" - fi -} - -prompt_ciacho_main() { - RETVAL=$? - prompt_ciacho_status - prompt_ciacho_battery - prompt_ciacho_context - prompt_ciacho_git - prompt_ciacho_dir - prompt_end - prompt_ciacho_hash - prompt_end - -} - - -prompt_ciacho_precmd() { - vcs_info - PROMPT='%{%f%b%k%}$(prompt_ciacho_main) ' -} - - -prompt_ciacho_setup() { - autoload -Uz add-zsh-hook - autoload -Uz vcs_info - - prompt_opts=(cr subst percent) - - add-zsh-hook precmd prompt_ciacho_precmd - - zstyle ':vcs_info:*' enable git - zstyle ':vcs_info:*' check-for-changes false - zstyle ':vcs_info:git*' formats '%b' - zstyle ':vcs_info:git*' actionformats '%b (%a)' -} - -prompt_ciacho_setup "$@" - -