Dotfiles for different machines on different branches.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
3.1 KiB

  1. # Disable ctrl-s and ctrl-q.
  2. stty -ixon
  3. setopt autocd autopushd \
  4. # Enable colors and change prompt
  5. autoload -U colors && colors
  6. autoload -Uz vcs_info
  7. precmd_vcs_info() { vcs_info }
  8. precmd_functions+=( precmd_vcs_info )
  9. zstyle ':vcs_info:*' enable git
  10. zstyle ':vcs_info:git*:*' get-revision true
  11. zstyle ':vcs_info:git*:*' check-for-changes true
  12. zstyle ':vcs_info:git*' formats "(%s) %c%u %b%m"
  13. zstyle ':vcs_info:git*' actionformats "(%s|%a) %12.12i %c%u %b%m"
  14. setopt prompt_subst
  15. # Show remote ref name and number of commits ahead-of or behind
  16. function +vi-git-st() {
  17. local ahead behind remote
  18. local -a gitstatus
  19. # Are we on a remote-tracking branch?
  20. remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} \
  21. --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
  22. if [[ -n ${remote} ]] ; then
  23. # for git prior to 1.7
  24. # ahead=$(git rev-list origin/${hook_com[branch]}..HEAD | wc -l)
  25. ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
  26. (( $ahead )) && gitstatus+=( " ${c3}+${ahead}${c2}" )
  27. # for git prior to 1.7
  28. # behind=$(git rev-list HEAD..origin/${hook_com[branch]} | wc -l)
  29. behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
  30. (( $behind )) && gitstatus+=( "${c4}-${behind}${c2}" )
  31. hook_com[branch]="${hook_com[branch]} [${remote}${(j:/:)gitstatus}]"
  32. fi
  33. }
  34. # Show count of stashed changes
  35. function +vi-git-stash() {
  36. local -a stashes
  37. if [[ -s ${hook_com[base]}/.git/refs/stash ]] ; then
  38. stashes=$(git stash list 2>/dev/null | wc -l)
  39. hook_com[misc]+=" (${stashes} stashed)"
  40. fi
  41. }
  42. zstyle ':vcs_info:git*+set-message:*' hooks git-st git-stash
  43. PS1='%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}#%b '
  44. RPROMPT='%B%{$fg[magenta]%}$vcs_info_msg_0_%{$reset_color%}%b'
  45. # History in cache directory
  46. HISTSIZE=10000
  47. SAVEHIST=10000
  48. HISTFILE=~/.cache/shhistory
  49. # Basic auto/tab complete
  50. autoload -U compinit
  51. zstyle ':completion:*' menu select
  52. zmodload zsh/complist
  53. compinit
  54. _comp_options+=(globdots) # Include hidden files
  55. # Enable vi mode
  56. bindkey -v
  57. export KEYTIMEOUT=1
  58. # Vim bindings in tab mode
  59. bindkey -M menuselect 'h' vi-backward-char
  60. bindkey -M menuselect 'k' vi-up-line-or-history
  61. bindkey -M menuselect 'l' vi-forward-char
  62. bindkey -M menuselect 'j' vi-down-line-or-history
  63. bindkey -v '^?' backward-delete-char
  64. # Vim Cursor shape
  65. function zle-keymap-select {
  66. if [[ ${KEYMAP} == vicmd ]] ||
  67. [[ $1 = 'block' ]]; then
  68. echo -ne '\e[1 q'
  69. elif [[ ${KEYMAP} == main ]] ||
  70. [[ ${KEYMAP} == viins ]] ||
  71. [[ ${KEYMAP} == '' ]]; then
  72. echo -ne '\e[5 q'
  73. fi
  74. }
  75. zle -N zle-keymap-select
  76. zle-line-init() {
  77. zle -K viins
  78. echo -ne "\e[5 q"
  79. }
  80. zle -N zle-line-init
  81. echo -ne '\e[5 q'
  82. preexec() { echo -ne '\e[5 q' ;}
  83. [ -f "$HOME/.config/aliasrc" ] && source "$HOME/.config/aliasrc" # Load aliases
  84. source $HOME/.profile 2>/dev/null # Load .profile
  85. if [[ -n "$PS1" ]] && [[ -z "$TMUX" ]] && [[ -n "$SSH_CONNECTION" ]]; then
  86. tmux attach-session -t $USER || tmux new-session -s $USER
  87. fi
  88. pfetch