Advertisement
Native2904

Powerline-prompt

Apr 16th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.60 KB | None | 0 0
  1. ## Path to oh-my-zsh installation. ##
  2. export PATH=/usr/local/bin:/usr/local/sbin:~/bin:$PATH
  3. fpath=(/usr/local/share/zsh-completions $fpath)
  4.  
  5. ## Path to oh-my-zsh installation. ##
  6. export ZSH=$HOME/.oh-my-zsh
  7. export TERM=screen-256color
  8.  
  9.  
  10. ## Theme in use. ##
  11.  
  12. POWERLEVEL9K_MODE='nerdfont-complete"
  13. ZSH_THEME="powerlevel9k/powerlevel9k"
  14.  
  15. ## Wifi signal config. ##
  16.  
  17. zsh_wifi_signal(){
  18.        local output=$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I)
  19.        local airport=$(echo $output | grep 'AirPort' | awk -F': ' '{print $2}')
  20.  
  21.        if [ "$airport" = "Off" ]; then
  22.                local color='%F{yellow}'
  23.                echo -n "%{$color%}Wifi Off"
  24.        else
  25.                local ssid=$(echo $output | grep ' SSID' | awk -F': ' '{print $2}')
  26.                local speed=$(echo $output | grep 'lastTxRate' | awk -F': ' '{print $2}')
  27.                local color='%F{yellow}'
  28.  
  29.                [[ $speed -gt 100 ]] && color='%F{blue}'
  30.                [[ $speed -lt 50 ]] && color='%F{red}'
  31.  
  32.                echo -n "%{$color%}$ssid $speed Mb/s%{%f%}" # removed char not in my PowerLine font
  33.        fi
  34. }
  35.  
  36. ## PowerlinePromtConfigArea. ##
  37.  
  38. zsh_internet_signal(){
  39.  #Try to ping google DNS to see if you have internet
  40.  local net=$(ping 8.8.8.8 -c 1| grep transmitted | awk '{print $6}' | grep 0)
  41.  local color='%F{red}'
  42.  local symbol="\uf0e8"
  43.  if [[ ! -z "$net" ]] ;
  44.  then color='%F{green}' ; symbol="\uf1e6" ;
  45.  fi
  46.  
  47.  echo -n "%{$color%}$symbol" # \f1eb is wifi bars
  48. }
  49.  
  50. ##Get the weather information from https://www.apixu.com/.Just create a free account to have an API key. Download jq do convert json. ##
  51.  
  52. zsh_weather(){
  53.  local weather=$(curl -s "https://api.apixu.com/v1/current.json?key=e16fc4806872490f85f140155181404&q"="Aachen"")
  54.  local temp=$(echo $weather | jq .current.temp_c)
  55.  local condition=$(echo $weather | jq .current.condition.text)
  56.  #Default value
  57.  local color='%F{green}'
  58.  local symbol="\ue339"
  59.  
  60.  if [[ $condition == *"rain"* ]] ;
  61.  then symbol="\ue306" ; color='%F{blue}'
  62.  fi
  63.  
  64.  if [[ $condition == *"cloudy"* || $condition == *"Overcast"* ]] ;
  65.  then symbol="\uf0c2" ; color='%F{grey}';
  66.  fi
  67.  
  68.  if [[ $condition == *"Sunny"* ]] ;
  69.  then symbol="\ue368" ; color='%F{yellow}';
  70.  fi
  71.  
  72.  echo -n "%{$color%}$temp\ue34f  $symbol"
  73. }
  74.  
  75. POWERLEVEL9K_PROMPT_ON_NEWLINE=true
  76.  
  77. POWERLEVEL9K_DIR_PATH_SEPARATOR=
  78. POWERLEVEL9K_DIR_HOME_ICON="\uf286"
  79. POWERLEVEL9K_DIR_HOME_SUB_ICON="\ue203"
  80. POWERLEVEL9K_DIR_FOLDER_ICON="\uf413"
  81.  
  82. POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
  83. POWERLEVEL9K_CONTEXT_DEFAULT_FOREGROUND="green"
  84. POWERLEVEL9K_CONTEXT_TEMPLATE="%F{cyan}%n%f"
  85. POWERLEVEL9K_CONTEXT_DEFAULT_BACKGROUND="black"
  86.  
  87. POWERLEVEL9K_SHORTEN_STRATEGY="truncate_middle"
  88. POWERLEVEL9K_SHORTEN_DIR_LENGTH=3
  89. POWERLEVEL9K_SHORTEN_DELIMITE="\uf557"
  90. POWERLEVEL9K_SHORTEN_ICON="\uE203"
  91.  
  92. POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR="\uE0B0"
  93. POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR="\uE0B2"
  94. POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR="\uE0B1"
  95. POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR="\uE0B3"
  96.  
  97. POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX=""
  98. POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%K{black}%F{black} `zsh_weather` %f%k%F{black}%f "
  99.  
  100. POWERLEVEL9K_CUSTOM_INTERNET_SIGNAL="zsh_internet_signal"
  101. POWERLEVEL9K_CUSTOM_WIFI_SIGNAL="zsh_wifi_signal"
  102. POWERLEVEL9K_CUSTOM_WIFI_SIGNAL_BACKGROUND="145"
  103. POWERLEVEL9K_CUSTOM_WIFI_SIGNAL_FOREGROUND="228"
  104.  
  105. POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=('os_icon' 'custom_internet_signal' 'dir' 'dir_writable' 'root_indicator' 'command_execution_time')
  106. POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=('status' 'ram_free' 'disk_usage' 'time' 'custom_wifi_signal')
  107.  
  108. POWERLEVEL9K_ROOT_INDICATOR_ICON="\uf023"
  109.  
  110. POWERLEVEL9K_OS_ICON_BACKGROUND="238"
  111. POWERLEVEL9K_OS_ICON_FOREGROUND="white"
  112.  
  113. POWERLEVEL9K_DISK_USAGE_ONLY_WARNING=false
  114. POWERLEVEL9K_DISK_USAGE_ICON="\ue240"
  115. POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=90
  116. POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=95
  117.  
  118. POWERLEVEL9K_DIR_SHOW_WRITABLE=true
  119. POWERLEVEL9K_DIR_WRITABLE_FORBIDDEN_BACKGROUND="clear"
  120. POWERLEVEL9K_DIR_WRITABLE_FORBIDDEN_FOREGROUND="red"
  121. POWERLEVEL9K_DIR_WRITEABLE_BACKGROUND="102"
  122. POWERLEVEL9K_DIR_WRITEABLE_FOREGROUND="184"
  123. POWERLEVEL9K_DIR_WRITEABLE_VISUAL_IDENTIFIER_COLOR="197"
  124.  
  125. POWERLEVEL9K_DIR_DEFAULT_FOREGROUND="white"
  126. POWERLEVEL9K_DIR_DEFAULT_BACKGROUND="green"
  127.  
  128. POWERLEVEL9K_DIR_HOME_FOREGROUND="015"
  129. POWERLEVEL9K_DIR_HOME_BACKGROUND="033"
  130. POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND="197"
  131. POWERLEVEL9K_DIR_HOME_SUBFOLDER_BACKGROUND="020"
  132.  
  133. POWERLEVEL9K_STATUS_VERBOSE=false
  134. POWERLEVEL9K_STATUS_OK_BACKGROUND="clear"
  135. POWERLEVEL9K_STATUS_OK_FOREGROUND="green"
  136. POWERLEVEL9K_STATUS_ERROR_BACKGROUND="clear"
  137. POWERLEVEL9K_STATUS_ERROR_FOREGROUND="red"
  138.  
  139. POWERLEVEL9K_TIME_FORMAT="%D{%H:%M:%S \uf252  %d.%m.%y}"
  140. POWERLEVEL9K_TIME_FOREGROUND="033"
  141. POWERLEVEL9K_TIME_BACKGROUND="188"
  142.  
  143. POWERLEVEL9K_RAM_ICON="\uf2db"
  144. POWERLEVEL9K_RAM_ELEMENTS="ram_free"
  145. POWERLEVEL9K_RAM_BACKGROUND="069"
  146. POWERLEVEL9K_RAM_FOREGROUND="152"
  147.  
  148. POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
  149.  
  150. POWERLEVEL9K_EXECUTION_TIME_ICON="\ue755"
  151. POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION="2"
  152. POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND="blue"
  153. POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND="white"
  154.  
  155.  
  156. ## use hyphen-insensitive completion. ##
  157. HYPHEN_INSENSITIVE="true"
  158.  
  159. ## Red Dots  while waiting for input. ##
  160. COMPLETION_WAITING_DOTS="true"
  161.  
  162. ## Uncomment the following line to enable command auto-correction. ##
  163. ENABLE_CORRECTION="true"
  164.  
  165. ## ZSH Update Cycle. ##
  166. export UPDATE_ZSH_DAYS=3
  167.  
  168. ## Enable Autoupdate oh-my-zsh.  ##
  169. DISABLE_UPDATE_PROMPT="true"
  170.  
  171. ## Disable Autosetting Terminal Title. ##
  172. DISABLE_AUTO_TITLE="true"
  173.  
  174. ## Plugins Path $HOME/.oh-my-zsh/plugins/ ##Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
  175. plugins=( python extract brew sublime thefuck colored-man-pages iterm2 colorize zsh-autosuggestions zsh-syntax-highlighting.zsh)
  176.  
  177.  
  178. ## Source. ##
  179. source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
  180.  
  181. source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  182.  
  183. source $ZSH/oh-my-zsh.sh
  184.  
  185. source ~/.fonts/*.sh
  186.  
  187. source "$(pluc-cli --destinationPath)"   ##function pluc-cli aka Aliasforever
  188.  
  189.  
  190. ## Language environment ##
  191. # export LANG=de_DE@euro
  192. export LANG=de_DE
  193.  
  194.  
  195. ## Alias ##
  196.  
  197. alias sublmyzshrc="subl ~/.zshrc"
  198. alias sublohmyzsh="subl ~/.oh-my-zsh"
  199. alias to=". gotodir"
  200. alias brewup='brew update; brew upgrade; brew prune; brew cleanup; brew doctor'
  201.  
  202.  
  203.  
  204. ## function ##
  205.  
  206. # function dependent to powerline-shell.
  207. ffunction powerline_precmd() {
  208.    PS1="$(powerline-shell --shell zsh $?)"
  209. }
  210.  
  211. function install_powerline_precmd() {
  212.  for s in "${precmd_functions[@]}"; do
  213.    if [ "$s" = "powerline_precmd" ]; then
  214.      return
  215.    fi
  216.  done
  217.  precmd_functions+=(powerline_precmd)
  218. }
  219.  
  220. if [ "$TERM" != "linux" ]; then
  221.    install_powerline_precmd
  222. fi
  223.  
  224. # function options to see which plugins run.
  225. function options(){
  226.    PLUGIN_PATH="$HOME/.oh-my-zsh/plugins/"
  227.    for plugin in $plugins; do
  228.        echo "\n\nPlugin: $plugin"; grep -r "^function \w*" $PLUGIN_PATH$plugin | awk '{print $2}' | sed 's/()//'| tr '\n' ', '; grep -r "^alias" $PLUGIN_PATH$plugin | awk '{print $2}' | sed 's/=.*//' |  tr '\n' ', '
  229.    done
  230. }
  231.  
  232. #function for pluc.
  233.  
  234. function pluc(){
  235.  pluc-cli "$@"
  236.  source "$(pluc-cli --destinationPath)"
  237.  
  238. }
  239.  
  240. # This will give you nicely formatted, line-numbered output.
  241.  
  242. lno() {
  243.    if [ $# == 0 ]; then
  244.        echo "No filename provided."
  245.    else
  246.        sed = "$1" | paste -s -d '\t\n' - -
  247.    fi
  248. }
  249.  
  250.  
  251. # output a quick markdown list from stdin to stdout.
  252.  
  253. qlist() {
  254.    sed -E '/^[     ]*$/d'|sed -E 's/^([    ]*)/\1* /'
  255. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement