Repository: simnalamburt/shellder Branch: master Commit: fcfef62c86fe Files: 7 Total size: 28.9 KB Directory structure: gitextract_zz3w78ge/ ├── COPYRIGHT ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── fish_mode_prompt.fish ├── fish_prompt.fish └── shellder.zsh-theme ================================================ FILE CONTENTS ================================================ ================================================ FILE: COPYRIGHT ================================================ Short version for non-laywers: The shellder project is dual-licensed under Apache 2.0 and MIT terms. Longer version: Copyright 2015-2020 Hyeon Kim Licensed under the Apache License, Version 2.0 or the MIT license , at your option. This file may not be copied, modified, or distributed except according to those terms. ================================================ FILE: LICENSE-APACHE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: LICENSE-MIT ================================================ Copyright (c) 2015-2020, Hyeon Kim Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ **UNMAINTAINED**: I don't use MSYS2 anymore so I don't maintain this project anymore. If you want to use shellder, consider the alternatives below: 1. [powerlevel10k](https://github.com/romkatv/powerlevel10k) - Lowest latency. Utilizes async tasks and gitstatusd. - Only for ZSH - Not suits with MSYS2 or Cygwin since it's a big shell scripts. (But who uses MSYS2/Cygwin while we have WSL2?) 2. [starship](https://starship.rs/) - Higher latency than powerlevel10k, but still it's faster than most shell themes. - Compatible with many shell environments (i.e. Powershell, bash, tcsh, fish, ...) - No slowdown in MSYS2 or Cygwin since it's a Rust binary not a shell script.   --------   shellder ======== 1. **No solarized** ― xterm256 colors are beautiful enough 2. **zsh** + **fish** support 3. **Speed** ― Carefully optimized for slow environments like MSYS2   ![screenshot image of shellder](https://raw.githubusercontent.com/simnalamburt/i/master/shellder/screenshot.png) Installation -------- You can install shellder via various plugin managers. ### Zsh, [zinit] ```zsh # ~/.zshrc zinit light simnalamburt/shellder ``` ### Fish, [chips] ```yaml # ~/.config/chips/plugin.yaml github: - simnalamburt/shellder ``` ### Fish, [oh-my-fish] ```yaml # ~/.config/chips/plugin.yaml github: - simnalamburt/shellder ```   Configuration ------- You can turn off Fish-like path shrinking by adding the following to your `~/.zshrc`: ```zsh # ~/.zshrc export SHELLDER_KEEP_PATH=1 ``` To control path shrinking in fish shell, set `fish_prompt_pwd_dir_length` or `fish_prompt_pwd_full_dirs` environment variable. See [prompt_pwd](https://fishshell.com/docs/current/cmds/prompt_pwd.html) for the further details.   ## Fonts You'll need a powerline patched font. If you don't have one, download one or patch some fonts on you own. - https://github.com/powerline/fonts - https://github.com/ryanoasis/nerd-fonts   -------- *shellder* is primarily distributed under the terms of both the [MIT license] and the [Apache License (Version 2.0)]. See [COPYRIGHT] for details. [zinit]: https://github.com/zdharma/zinit [chips]: https://github.com/xtendo-org/chips [oh-my-fish]: https://github.com/oh-my-fish/oh-my-fish [MIT license]: LICENSE-MIT [Apache License (Version 2.0)]: LICENSE-APACHE [COPYRIGHT]: COPYRIGHT ================================================ FILE: fish_mode_prompt.fish ================================================ function fish_mode_prompt if test "$fish_key_bindings" = "fish_vi_key_bindings" or test "$fish_key_bindings" = "fish_hybrid_key_bindings" switch $fish_bind_mode case default prompt_segment blue black "N" case insert prompt_segment green black "I" case replace_one prompt_segment red black "R" case visual prompt_segment magenta black "V" end end end ================================================ FILE: fish_prompt.fish ================================================ # Set these options in your config.fish (if you want to :]) # # set -g theme_display_user yes # set -g theme_hostname never # set -g theme_hostname always # set -g default_user your_normal_user # Backward compatibility # # Note: Do not depend on these behavior. These can be removed in anytime by the # author in the name of code readability. if set -q theme_hide_hostname # Existing $theme_hostname will always override $theme_hide_hostname if not set -q theme_hostname if [ "theme_hide_hostname" = "yes" ] set -g theme_hostname never end if [ "theme_hide_hostname" = "no" ] set -g theme_hostname always end end end # # Segments functions # set -g current_bg NONE set -g segment_separator \uE0B0 function prompt_segment -d "Function to draw a segment" set -l bg set -l fg if [ -n "$argv[1]" ] set bg $argv[1] else set bg normal end if [ -n "$argv[2]" ] set fg $argv[2] else set fg normal end if [ "$current_bg" != 'NONE' -a "$argv[1]" != "$current_bg" ] set_color -b $bg set_color $current_bg echo -n "$segment_separator " set_color -b $bg set_color $fg else set_color -b $bg set_color $fg echo -n " " end set current_bg $argv[1] if [ -n "$argv[3]" ] echo -n -s $argv[3] " " end end function prompt_finish -d "Close open segments" if [ -n $current_bg ] set_color -b normal set_color $current_bg echo -n "$segment_separator " end set_color normal set -g current_bg NONE end # # Components # function prompt_virtual_env -d "Display Python virtual environment" if test "$VIRTUAL_ENV" prompt_segment white black (basename $VIRTUAL_ENV) end end function prompt_user -d "Display current user if different from $default_user" set -l BG 444444 set -l FG BCBCBC if [ "$theme_display_user" = "yes" ] if [ "$USER" != "$default_user" -o -n "$SSH_CLIENT" ] set USER (whoami) get_hostname if [ $HOSTNAME_PROMPT ] set USER_PROMPT $USER@$HOSTNAME_PROMPT else set USER_PROMPT $USER end prompt_segment $BG $FG $USER_PROMPT end else get_hostname if [ $HOSTNAME_PROMPT ] prompt_segment $BG $FG $HOSTNAME_PROMPT end end end function get_hostname -d "Set current hostname to prompt variable $HOSTNAME_PROMPT if connected via SSH" set -g HOSTNAME_PROMPT "" if [ "$theme_hostname" = "always" -o \( "$theme_hostname" != "never" -a -n "$SSH_CLIENT" \) ] set -g HOSTNAME_PROMPT (hostname) end end function prompt_dir -d "Display the current directory" prompt_segment 1C1C1C FFFFFF (prompt_pwd) end function prompt_hg -d "Display mercurial state" set -l branch set -l state if command hg id >/dev/null 2>&1 if command hg prompt >/dev/null 2>&1 set branch (command hg prompt "{branch}") set state (command hg prompt "{status}") set branch_symbol \uE0A0 if [ "$state" = "!" ] prompt_segment red white "$branch_symbol $branch ±" else if [ "$state" = "?" ] prompt_segment yellow black "$branch_symbol $branch ±" else prompt_segment green black "$branch_symbol $branch" end end end end function prompt_git -d "Display the current git state" set -l ref if command git rev-parse --is-inside-work-tree >/dev/null 2>&1 set ref (command git symbolic-ref HEAD 2> /dev/null) if [ $status -gt 0 ] set -l branch (command git show-ref --head -s --abbrev |head -n1 2> /dev/null) set ref "➦ $branch " end set branch_symbol \uE0A0 set -l branch (echo $ref | sed "s-refs/heads/-$branch_symbol -") set -l BG PROMPT set -l dirty (command git status --porcelain --ignore-submodules=dirty 2> /dev/null) if [ "$dirty" = "" ] set BG green set PROMPT "$branch" else set BG yellow set dirty '' # Check if there's any commit in the repo set -l empty 0 git rev-parse --quiet --verify HEAD > /dev/null 2>&1; or set empty 1 set -l target if [ $empty = 1 ] # The repo is empty set target '4b825dc642cb6eb9a060e54bf8d69288fbee4904' else # The repo is not emtpy set target 'HEAD' # Check for unstaged change only when the repo is not empty set -l unstaged 0 git diff --no-ext-diff --ignore-submodules=dirty --quiet --exit-code; or set unstaged 1 if [ $unstaged = 1 ]; set dirty $dirty'●'; end end # Check for staged change set -l staged 0 git diff-index --cached --quiet --exit-code --ignore-submodules=dirty $target; or set staged 1 if [ $staged = 1 ]; set dirty $dirty'✚'; end # Check for dirty if [ "$dirty" = "" ] set PROMPT "$branch" else set PROMPT "$branch $dirty" end end prompt_segment $BG black $PROMPT end end function prompt_svn -d "Display the current svn state" set -l ref if command svn ls . >/dev/null 2>&1 set branch (svn_get_branch) set branch_symbol \uE0A0 set revision (svn_get_revision) prompt_segment green black "$branch_symbol $branch:$revision" end end function svn_get_branch -d "get the current branch name" svn info 2> /dev/null | awk -F/ \ '/^URL:/ { \ for (i=0; i<=NF; i++) { \ if ($i == "branches" || $i == "tags" ) { \ print $(i+1); \ break;\ }; \ if ($i == "trunk") { print $i; break; } \ } \ }' end function svn_get_revision -d "get the current revision number" svn info 2> /dev/null | sed -n 's/Revision:\ //p' end function prompt_status -d "the symbols for a non zero exit status, root and background jobs" if [ $RETVAL -ne 0 ] prompt_segment black red "✘" end # if superuser (uid == 0) set -l uid (id -u $USER) if [ $uid -eq 0 ] prompt_segment black yellow "⚡" end # Jobs display if [ (jobs -l | wc -l) -gt 0 ] prompt_segment black cyan "⚙" end end if printf '%s\n' '2.2.0' $FISH_VERSION | sort --check=silent --version-sort # Current version ≥ 2.2.0 function __exists -a name -d "Check if a function or program does exist." command -v "$name" ^/dev/null >&2 end else # Current version < 2.2.0 function __exists -a name -d "Check if a function or program does exist." type "$name" ^/dev/null >&2 end end # # Prompt # function fish_prompt set -g RETVAL $status prompt_status prompt_virtual_env prompt_user prompt_dir __exists hg; and prompt_hg __exists git; and prompt_git __exists svn; and prompt_svn prompt_finish end ================================================ FILE: shellder.zsh-theme ================================================ # vim:ft=zsh ts=2 sw=2 sts=2 # # Segment drawing # CURRENT_BG='NONE' # # color scheme # SHELLDER_CONTEXT_BG=${SHELLDER_CONTEXT_BG:-238} SHELLDER_CONTEXT_FG=${SHELLDER_CONTEXT_FG:-250} SHELLDER_DIRECTORY_BG=${SHELLDER_DIRECTORY_BG:-234} SHELLDER_DIRECTORY_FG=${SHELLDER_DIRECTORY_FG:-231} SHELLDER_GIT_CLEAN_BG=${SHELLDER_GIT_CLEAN_BG:-034} SHELLDER_GIT_CLEAN_FG=${SHELLDER_GIT_CLEAN_FG:-'black'} SHELLDER_GIT_UNTRACKED_BG=${SHELLDER_GIT_UNTRACKED_BG:-226} SHELLDER_GIT_UNTRACKED_FG=${SHELLDER_GIT_UNTRACKED_FG:-'black'} SHELLDER_GIT_UNPUSHED_BG=${SHELLDER_GIT_UNPUSHED_BG:-48} SHELLDER_GIT_UNPUSHED_FG=${SHELLDER_GIT_UNPUSHED_FG:-'black'} SHELLDER_GIT_MODIFIED_BG=${SHELLDER_GIT_MODIFIED_BG:-172} SHELLDER_GIT_MODIFIED_FG=${SHELLDER_GIT_MODIFIED_FG:-'black'} SHELLDER_GIT_STAGED_BG=${SHELLDER_GIT_STAGED_BG:-166} SHELLDER_GIT_STAGED_FG=${SHELLDER_GIT_STAGED_FG:-'black'} SHELLDER_GIT_ADDED_BG=${SHELLDER_GIT_ADDED_BG:-218} SHELLDER_GIT_ADDED_FG=${SHELLDER_GIT_ADDED_FG:-'black'} SHELLDER_VIRTUALENV_BG=${SHELLDER_VIRTUALENV_BG:-017} SHELLDER_VIRTUALENV_FG=${SHELLDER_VIRTUALENV_FG:-189} SHELLDER_STATUS_BG=${SHELLDER_STATUS_BG:-236} SHELLDER_STATUS_FG=${SHELLDER_STATUS_FG:-'default'} # Special Powerline characters set_separator() { local LC_ALL='' LC_CTYPE='en_US.UTF-8' SEGMENT_SEPARATOR=$'\ue0b0' } set_separator # 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 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 functions # # Context: user@hostname (who am I and where am I) prompt_context() { local prompt if [[ -n "$SSH_CLIENT" ]]; then if [[ "$USER" != "$DEFAULT_USER" ]]; then prompt="%(!.%{%F{yellow}%}.)$USER@%m" else prompt='%(!.%{%F{yellow}%}.)%m' fi prompt_segment "$SHELLDER_CONTEXT_BG" "$SHELLDER_CONTEXT_FG" "$prompt" fi } # Git: branch/detached head, dirty status prompt_git() { local repo_path local GIT_STATUS repo_path=$(git rev-parse --git-dir 2>/dev/null) if [[ -n $repo_path ]]; then local PL_BRANCH_CHAR dirty bgcolor fgcolor mode ref set_branch_char() { local LC_ALL='' LC_CTYPE='en_US.UTF-8' PL_BRANCH_CHAR=$'\ue0a0' #  } set_branch_char GIT_STATUS=$( command git status --porcelain --ignore-submodules=dirty 2>/dev/null | sed -e 's/^ //g' ) modified=$(<<< "$GIT_STATUS" grep '^M') untracked=$(<<< "$GIT_STATUS" grep '^?') added=$(<<< "$GIT_STATUS" grep '^A') staged=$(git diff --name-only --cached) unpushed=$(command git cherry 2>/dev/null) if [[ -n $added ]]; then bgcolor=$SHELLDER_GIT_ADDED_BG fgcolor=$SHELLDER_GIT_ADDED_FG elif [[ -n $staged ]]; then bgcolor=$SHELLDER_GIT_STAGED_BG fgcolor=$SHELLDER_GIT_STAGED_FG elif [[ -n $modified ]]; then bgcolor=$SHELLDER_GIT_MODIFIED_BG fgcolor=$SHELLDER_GIT_MODIFIED_FG elif [[ -n $untracked ]]; then bgcolor=$SHELLDER_GIT_UNTRACKED_BG fgcolor=$SHELLDER_GIT_UNTRACKED_FG elif [[ -n $unpushed ]]; then bgcolor=$SHELLDER_GIT_UNPUSHED_BG fgcolor=$SHELLDER_GIT_UNPUSHED_FG else bgcolor=$SHELLDER_GIT_CLEAN_BG fgcolor=$SHELLDER_GIT_CLEAN_FG fi prompt_segment "$bgcolor" "$fgcolor" if [[ -e "${repo_path}/BISECT_LOG" ]]; then mode=' ' 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 # vcs_info is too slow with MSYS2 (~300ms with i7-6770K + SSD) if [[ -z $MSYS ]]; then autoload -Uz vcs_info zstyle ':vcs_info:*' enable git 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 else if [[ -n $dirty ]]; then vcs_info_msg_0_=' !' fi fi ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}" fi } prompt_hg() { local rev 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 } # Turn '/some/quite/very/long/path' into '/s/q/v/l/path' function shrinked_path() { local paths=(${PWD/$HOME/\~}) 'cur_dir' paths=(${(s:/:)paths}) for idx in {1..$#paths}; do if [[ idx -lt $#paths ]]; then cur_dir+="${paths[idx]:0:1}" else cur_dir+="${paths[idx]}" fi cur_dir+='/' done echo "${cur_dir: :-1}" } # Dir: current working directory prompt_dir() { local dir if [[ -n $SHELLDER_KEEP_PATH ]]; then dir='%~' else dir=$(shrinked_path) fi prompt_segment "$SHELLDER_DIRECTORY_BG" "$SHELLDER_DIRECTORY_FG" "$dir" } # Virtualenv: current working virtualenv prompt_virtualenv() { local virtualenv_path="$VIRTUAL_ENV" if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then prompt_segment "$SHELLDER_VIRTUALENV_BG" "$SHELLDER_VIRTUALENV_FG" "$(basename "$virtualenv_path")" fi } # Status: error + root + background jobs prompt_status() { local symbols symbols=() [[ $RETVAL -ne 0 ]] && symbols+="%{%F{yellow}%}$RETVAL" [[ $UID -eq 0 ]] && symbols+='%{%F{yellow}%}⚡' [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+='%{%F{cyan}%}⚙' [[ -n "$symbols" ]] && prompt_segment "$SHELLDER_STATUS_BG" "$SHELLDER_STATUS_FG" "$symbols" } # # Prompt # build_prompt() { RETVAL=$? prompt_status prompt_virtualenv prompt_context prompt_dir prompt_git prompt_hg prompt_end } export VIRTUAL_ENV_DISABLE_PROMPT='true' PROMPT='%{%f%b%k%}$(build_prompt) '