Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Bash
Posted by: Сергей Шевченко
Added: May 12, 2020 4:12 PM
Views: 126
Tags: zsh
  1. # If you come from bash you might have to change your $PATH.
  2. # export PATH=$HOME/bin:/usr/local/bin:$PATH
  3.  
  4. # Path to your oh-my-zsh installation.
  5. export ZSH="/Users/administrator/.oh-my-zsh"
  6.  
  7. # Set name of the theme to load --- if set to "random", it will
  8. # load a random theme each time oh-my-zsh is loaded, in which case,
  9. # to know which specific one was loaded, run: echo $RANDOM_THEME
  10. # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
  11. ZSH_THEME="robbyrussell"
  12.  
  13. # Set list of themes to pick from when loading at random
  14. # Setting this variable when ZSH_THEME=random will cause zsh to load
  15. # a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
  16. # If set to an empty array, this variable will have no effect.
  17. # ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
  18.  
  19. # Uncomment the following line to use case-sensitive completion.
  20. # CASE_SENSITIVE="true"
  21.  
  22. # Uncomment the following line to use hyphen-insensitive completion.
  23. # Case-sensitive completion must be off. _ and - will be interchangeable.
  24. # HYPHEN_INSENSITIVE="true"
  25.  
  26. # Uncomment the following line to disable bi-weekly auto-update checks.
  27. # DISABLE_AUTO_UPDATE="true"
  28.  
  29. # Uncomment the following line to automatically update without prompting.
  30. # DISABLE_UPDATE_PROMPT="true"
  31.  
  32. # Uncomment the following line to change how often to auto-update (in days).
  33. # export UPDATE_ZSH_DAYS=13
  34.  
  35. # Uncomment the following line if pasting URLs and other text is messed up.
  36. # DISABLE_MAGIC_FUNCTIONS=true
  37.  
  38. # Uncomment the following line to disable colors in ls.
  39. # DISABLE_LS_COLORS="true"
  40.  
  41. # Uncomment the following line to disable auto-setting terminal title.
  42. # DISABLE_AUTO_TITLE="true"
  43.  
  44. # Uncomment the following line to enable command auto-correction.
  45. # ENABLE_CORRECTION="true"
  46.  
  47. # Uncomment the following line to display red dots whilst waiting for completion.
  48. # COMPLETION_WAITING_DOTS="true"
  49.  
  50. # Uncomment the following line if you want to disable marking untracked files
  51. # under VCS as dirty. This makes repository status check for large repositories
  52. # much, much faster.
  53. # DISABLE_UNTRACKED_FILES_DIRTY="true"
  54.  
  55. # Uncomment the following line if you want to change the command execution time
  56. # stamp shown in the history command output.
  57. # You can set one of the optional three formats:
  58. # "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
  59. # or set a custom format using the strftime function format specifications,
  60. # see 'man strftime' for details.
  61. # HIST_STAMPS="mm/dd/yyyy"
  62.  
  63. # Would you like to use another custom folder than $ZSH/custom?
  64. # ZSH_CUSTOM=/path/to/new-custom-folder
  65.  
  66. # Which plugins would you like to load?
  67. # Standard plugins can be found in ~/.oh-my-zsh/plugins/*
  68. # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
  69. # Example format: plugins=(rails git textmate ruby lighthouse)
  70. # Add wisely, as too many plugins slow down shell startup.
  71. plugins=(git)
  72.  
  73. source $ZSH/oh-my-zsh.sh
  74.  
  75. # User configuration
  76.  
  77. # export MANPATH="/usr/local/man:$MANPATH"
  78.  
  79. # You may need to manually set your language environment
  80. # export LANG=en_US.UTF-8
  81.  
  82. # Preferred editor for local and remote sessions
  83. # if [[ -n $SSH_CONNECTION ]]; then
  84. #   export EDITOR='vim'
  85. # else
  86. #   export EDITOR='mvim'
  87. # fi
  88.  
  89. # Compilation flags
  90. # export ARCHFLAGS="-arch x86_64"
  91.  
  92. # Set personal aliases, overriding those provided by oh-my-zsh libs,
  93. # plugins, and themes. Aliases can be placed here, though oh-my-zsh
  94. # users are encouraged to define aliases within the ZSH_CUSTOM folder.
  95. # For a full list of active aliases, run `alias`.
  96. #
  97. # Example aliases
  98. # alias zshconfig="mate ~/.zshrc"
  99. # alias ohmyzsh="mate ~/.oh-my-zsh"
  100. alias ll='ls -lahFG'
  101.  
  102. ZSH_THEME="powerlevel9k/powerlevel9k"
  103. POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir rbenv vcs)
  104. POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time)
  105. # vim:ft=zsh ts=2 sw=2 sts=2
  106. #
  107. # agnoster's Theme - https://gist.github.com/3712874
  108. # A Powerline-inspired theme for ZSH
  109. #
  110. # # README
  111. #
  112. # In order for this theme to render correctly, you will need a
  113. # [Powerline-patched font](https://gist.github.com/1595572).
  114. #
  115. # In addition, I recommend the
  116. # [Solarized theme](https://github.com/altercation/solarized/) and, if you're
  117. # using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app -
  118. # it has significantly better color fidelity.
  119. #
  120. # # Goals
  121. #
  122. # The aim of this theme is to only show you *relevant* information. Like most
  123. # prompts, it will only show git information when in a git working directory.
  124. # However, it goes a step further: everything from the current user and
  125. # hostname to whether the last call exited with an error to whether background
  126. # jobs are running in this shell will all be displayed automatically when
  127. # appropriate.
  128.  
  129. ### Segments of the prompt, default order declaration
  130.  
  131. typeset -aHg AGNOSTER_PROMPT_SEGMENTS=(
  132.     prompt_status
  133.     prompt_context
  134.     prompt_virtualenv
  135.     prompt_dir
  136.     prompt_git
  137.     prompt_end
  138. )
  139.  
  140. ### Segment drawing
  141. # A few utility functions to make it easy and re-usable to draw segmented prompts
  142.  
  143. CURRENT_BG='NONE'
  144. if [[ -z "$PRIMARY_FG" ]]; then
  145.         PRIMARY_FG=black
  146. fi
  147.  
  148. # Characters
  149. SEGMENT_SEPARATOR="\ue0b0"
  150. PLUSMINUS="\u00b1"
  151. BRANCH="\ue0a0"
  152. DETACHED="\u27a6"
  153. CROSS="\u2718"
  154. LIGHTNING="\u26a1"
  155. GEAR="\u2699"
  156.  
  157. # Begin a segment
  158. # Takes two arguments, background and foreground. Both can be omitted,
  159. # rendering default background/foreground.
  160. prompt_segment() {
  161.   local bg fg
  162.   [[ -n $1 ]] && bg="%K{$1}" || bg="%k"
  163.   [[ -n $2 ]] && fg="%F{$2}" || fg="%f"
  164.   if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
  165.     print -n "%{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%}"
  166.   else
  167.     print -n "%{$bg%}%{$fg%}"
  168.   fi
  169.   CURRENT_BG=$1
  170.   [[ -n $3 ]] && print -n $3
  171. }
  172.  
  173. # End the prompt, closing any open segments
  174. prompt_end() {
  175.   if [[ -n $CURRENT_BG ]]; then
  176.     print -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
  177.   else
  178.     print -n "%{%k%}"
  179.   fi
  180.   print -n "%{%f%}"
  181.   CURRENT_BG=''
  182. }
  183.  
  184. ### Prompt components
  185. # Each component will draw itself, and hide itself if no information needs to be shown
  186.  
  187. # Context: user@hostname (who am I and where am I)
  188. prompt_context() {
  189.   local user=`whoami`
  190.  
  191.   if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CONNECTION" ]]; then
  192.     prompt_segment $PRIMARY_FG magenta " %(!.%{%F{magenta}%}.)$user%{%F{cyan}%}@%{%F{yellow}%}%m "
  193.   fi
  194. }
  195.  
  196. # Git: branch/detached head, dirty status
  197. prompt_git() {
  198.   local color ref
  199.   is_dirty() {
  200.     test -n "$(git status --porcelain --ignore-submodules)"
  201.   }
  202.   ref="$vcs_info_msg_0_"
  203.   if [[ -n "$ref" ]]; then
  204.     if is_dirty; then
  205.       color=yellow
  206.       ref="${ref} $PLUSMINUS"
  207.     else
  208.       color=green
  209.       ref="${ref} "
  210.     fi
  211.     if [[ "${ref/.../}" == "$ref" ]]; then
  212.       ref="$BRANCH $ref"
  213.     else
  214.       ref="$DETACHED ${ref/.../}"
  215.     fi
  216.     prompt_segment $color $PRIMARY_FG
  217.     print -n " $ref"
  218.   fi
  219. }
  220.  
  221. # Dir: current working directory
  222. prompt_dir() {
  223.   prompt_segment blue $PRIMARY_FG ' %~ '
  224. }
  225.  
  226. # Status:
  227. # - was there an error
  228. # - am I root
  229. # - are there background jobs?
  230. prompt_status() {
  231.   local symbols
  232.   symbols=()
  233.   [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}$CROSS"
  234.   [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}$LIGHTNING"
  235.   [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}$GEAR"
  236.  
  237.   [[ -n "$symbols" ]] && prompt_segment $PRIMARY_FG default " $symbols "
  238. }
  239.  
  240. # Display current virtual environment
  241. prompt_virtualenv() {
  242.   if [[ -n $VIRTUAL_ENV ]]; then
  243.     color=cyan
  244.     prompt_segment $color $PRIMARY_FG
  245.     print -Pn " $(basename $VIRTUAL_ENV) "
  246.   fi
  247. }
  248.  
  249. ## Main prompt
  250. prompt_agnoster_main() {
  251.   RETVAL=$?
  252.   CURRENT_BG='NONE'
  253.   for prompt_segment in "${AGNOSTER_PROMPT_SEGMENTS[@]}"; do
  254.     [[ -n $prompt_segment ]] && $prompt_segment
  255.   done
  256. }
  257.  
  258. prompt_agnoster_precmd() {
  259.   vcs_info
  260.   PROMPT='%{%f%b%k%}$(prompt_agnoster_main) '
  261. }
  262.  
  263. prompt_agnoster_setup() {
  264.   autoload -Uz add-zsh-hook
  265.   autoload -Uz vcs_info
  266.  
  267.   prompt_opts=(cr subst percent)
  268.  
  269.   add-zsh-hook precmd prompt_agnoster_precmd
  270.  
  271.   zstyle ':vcs_info:*' enable git
  272.   zstyle ':vcs_info:*' check-for-changes false
  273.   zstyle ':vcs_info:git*' formats '%b'
  274.   zstyle ':vcs_info:git*' actionformats '%b (%a)'
  275. }
  276.  
  277. prompt_agnoster_setup "$@"
  278.  
  279.