Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.10 KB | None | 0 0
  1. # =============
  2. # INIT
  3. # =============
  4.  
  5. # Senstive functions which are not pushed to Github
  6. # It contains GOPATH, some functions, aliases etc...
  7. [ -r ~/.zsh_private ] && source ~/.zsh_private
  8.  
  9. # =============
  10. # ALIAS
  11. # =============
  12. alias ..='cd ..'
  13.  
  14. alias t="tig status"
  15. alias tigs="tig status" #old habits don't die
  16. alias d='git diff'
  17. alias vi='vim'
  18.  
  19. case `uname` in
  20. Darwin)
  21. alias flushdns='sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder;say cache flushed'
  22. alias ls='ls -GpF' # Mac OSX specific
  23. alias ll='ls -alGpF' # Mac OSX specific
  24. ;;
  25. Linux)
  26. alias ll='ls -al'
  27. alias ls='ls --color=auto'
  28. ;;
  29. esac
  30.  
  31. alias sq='git rebase -i $(git merge-base $(git rev-parse --abbrev-ref HEAD) master)'
  32. alias co='git checkout master'
  33. alias po='git pull origin $(git rev-parse --abbrev-ref HEAD)'
  34. alias b='git branch'
  35. alias hc='hub compare'
  36. alias hb='hub browse'
  37. alias hp='hub pull-request'
  38.  
  39. alias -s go='go run'
  40. alias hs='hugo server'
  41.  
  42. alias icloud='cd ~/Library/Mobile\ Documents/com~apple~CloudDocs/'
  43.  
  44.  
  45. export LC_ALL="en_US.UTF-8"
  46. export LANG="en_US.UTF-8"
  47.  
  48. # =============
  49. # EXPORT
  50. # =============
  51. #
  52.  
  53. export PATH="/usr/local/go/bin:$GOBIN:$HOME/.cargo/bin:$PATH"
  54.  
  55. export EDITOR="vim"
  56. export LSCOLORS=cxBxhxDxfxhxhxhxhxcxcx
  57. export CLICOLOR=1
  58.  
  59. # support colors in less
  60. export LESS_TERMCAP_mb=$'\E[01;31m'
  61. export LESS_TERMCAP_md=$'\E[01;31m'
  62. export LESS_TERMCAP_me=$'\E[0m'
  63. export LESS_TERMCAP_se=$'\E[0m'
  64. export LESS_TERMCAP_so=$'\E[01;44;33m'
  65. export LESS_TERMCAP_ue=$'\E[0m'
  66. export LESS_TERMCAP_us=$'\E[01;32m'
  67.  
  68. # =============
  69. # HISTORY
  70. # =============
  71.  
  72. ## Command history configuration
  73. HISTFILE=$HOME/.zsh_history
  74. HISTSIZE=1000000
  75. SAVEHIST=1000000
  76.  
  77. setopt append_history
  78. setopt extended_history
  79. setopt hist_expire_dups_first
  80. # ignore duplication command history list
  81. setopt hist_ignore_dups
  82. setopt hist_ignore_space
  83. setopt hist_verify
  84. setopt inc_append_history
  85. # share command history data
  86. setopt share_history
  87.  
  88. # =============
  89. # PROMPT
  90. # =============
  91. autoload -U colors && colors
  92. setopt promptsubst
  93.  
  94. local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[green]%}➜ )"
  95. PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
  96.  
  97. ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
  98. ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
  99. ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
  100. ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
  101.  
  102. # Outputs current branch info in prompt format
  103. function git_prompt_info() {
  104. local ref
  105. if [[ "$(command git config --get customzsh.hide-status 2>/dev/null)" != "1" ]]; then
  106. ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
  107. ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0
  108. echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
  109. fi
  110. }
  111.  
  112. # Checks if working tree is dirty
  113. function parse_git_dirty() {
  114. local STATUS=''
  115. local FLAGS
  116. FLAGS=('--porcelain')
  117.  
  118. if [[ "$(command git config --get customzsh.hide-dirty)" != "1" ]]; then
  119. FLAGS+='--ignore-submodules=dirty'
  120. STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1)
  121. fi
  122.  
  123. if [[ -n $STATUS ]]; then
  124. echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
  125. else
  126. echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
  127. fi
  128. }
  129.  
  130. # ===================
  131. # AUTOCOMPLETION
  132. # ===================
  133. # enable completion
  134. autoload -Uz compinit
  135. compinit
  136.  
  137. autoload bashcompinit
  138. bashcompinit
  139.  
  140. zmodload -i zsh/complist
  141.  
  142. WORDCHARS=''
  143.  
  144. unsetopt menu_complete # do not autoselect the first completion entry
  145. unsetopt flowcontrol
  146. setopt auto_menu # show completion menu on successive tab press
  147. setopt complete_in_word
  148. setopt always_to_end
  149.  
  150. # autocompletion with an arrow-key driven interface
  151. zstyle ':completion:*:*:*:*:*' menu select
  152.  
  153. zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
  154. zstyle ':completion:*' list-colors ''
  155. zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
  156.  
  157. zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w"
  158.  
  159. # Don't complete uninteresting users
  160. zstyle ':completion:*:*:*:users' ignored-patterns \
  161. adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \
  162. clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \
  163. gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \
  164. ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \
  165. named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \
  166. operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \
  167. rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \
  168. usbmux uucp vcsa wwwrun xfs '_*'
  169.  
  170. zstyle '*' single-ignored show
  171.  
  172. # Automatically update PATH entries
  173. zstyle ':completion:*' rehash true
  174.  
  175. # Keep directories and files separated
  176. zstyle ':completion:*' list-dirs-first true
  177.  
  178. # ===================
  179. # KEY BINDINGS
  180. # ===================
  181. # Use emacs-like key bindings by default:
  182. bindkey -e
  183.  
  184. # [Ctrl-r] - Search backward incrementally for a specified string. The string
  185. # may begin with ^ to anchor the search to the beginning of the line.
  186. bindkey '^r' history-incremental-search-backward
  187.  
  188. if [[ "${terminfo[kpp]}" != "" ]]; then
  189. bindkey "${terminfo[kpp]}" up-line-or-history # [PageUp] - Up a line of history
  190. fi
  191.  
  192. if [[ "${terminfo[knp]}" != "" ]]; then
  193. bindkey "${terminfo[knp]}" down-line-or-history # [PageDown] - Down a line of history
  194. fi
  195.  
  196. if [[ "${terminfo[khome]}" != "" ]]; then
  197. bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line
  198. fi
  199.  
  200. if [[ "${terminfo[kend]}" != "" ]]; then
  201. bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line
  202. fi
  203. if [[ "${terminfo[kcbt]}" != "" ]]; then
  204. bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards
  205. fi
  206.  
  207. bindkey '^?' backward-delete-char # [Backspace] - delete backward
  208. if [[ "${terminfo[kdch1]}" != "" ]]; then
  209. bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward
  210. else
  211. bindkey "^[[3~" delete-char
  212. bindkey "^[3;5~" delete-char
  213. bindkey "\e[3~" delete-char
  214. fi
  215.  
  216. # ===================
  217. # MISC SETTINGS
  218. # ===================
  219.  
  220. # automatically remove duplicates from these arrays
  221. typeset -U path PATH cdpath CDPATH fpath FPATH manpath MANPATH
  222.  
  223. # only exit if we're not on the last pane
  224.  
  225. exit() {
  226. if [[ -z $TMUX ]]; then
  227. builtin exit
  228. return
  229. fi
  230.  
  231. panes=$(tmux list-panes | wc -l)
  232. wins=$(tmux list-windows | wc -l)
  233. count=$(($panes + $wins - 1))
  234. if [ $count -eq 1 ]; then
  235. tmux detach
  236. else
  237. builtin exit
  238. fi
  239. }
  240.  
  241. function switchgo() {
  242. version=$1
  243. if [ -z $version ]; then
  244. echo "Usage: switchgo [version]"
  245. return
  246. fi
  247.  
  248. if ! command -v "go$version" > /dev/null 2>&1; then
  249. echo "version does not exist, download with: "
  250. echo " go get golang.org/dl/go${version}"
  251. echo " go${version} download"
  252. return
  253. fi
  254.  
  255. go_bin_path=$(command -v "go$version")
  256. ln -sf "$go_bin_path" "$GOBIN/go"
  257. echo "Switched to ${go_bin_path}"
  258. }
  259.  
  260. # ===================
  261. # PLUGINS
  262. # ===================
  263.  
  264. source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  265. source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
  266.  
  267. # ===================
  268. # THIRD PARTY
  269. # ===================
  270. # brew install jump
  271. # https://github.com/gsamokovarov/jump
  272. eval "$(jump shell)"
  273.  
  274. # The next line updates PATH for the Google Cloud SDK.
  275. if [ -f '/Users/fatih/Code/google-cloud-sdk/path.zsh.inc' ]; then . '/Users/fatih/Code/google-cloud-sdk/path.zsh.inc'; fi
  276.  
  277. # The next line enables shell command completion for gcloud.
  278. if [ -f '/Users/fatih/Code/google-cloud-sdk/completion.zsh.inc' ]; then . '/Users/fatih/Code/google-cloud-sdk/completion.zsh.inc'; fi
  279. export PATH="/usr/local/opt/mysql-client/bin:$PATH"
  280.  
  281. # Add programs in the bin to the path
  282. export PATH="/home/dowland/bin:$PATH"
  283.  
  284. [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement