.zshrc 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. ### antibody
  2. autoload -Uz compinit
  3. compinit
  4. . ${HOME}/.config/zsh/antibody.zsh
  5. ### KiTTY completion
  6. if which kitty > /dev/null; then
  7. kitty + complete setup zsh | source /dev/stdin
  8. fi
  9. ### fasd
  10. if which fasd > /dev/null; then
  11. eval "$(fasd --init auto)"
  12. unalias sd
  13. fi
  14. ### Pipenv
  15. if which pipenv > /dev/null; then
  16. if [ -f ${HOME}/.config/zsh/pipenv.zsh ]; then
  17. eval "$(cat ${HOME}/.config/zsh/pipenv.zsh)"
  18. else
  19. eval "$(pipenv --completion)"
  20. fi
  21. fi
  22. ### virtualenvwrapper
  23. if [ -f /usr/bin/virtualenvwrapper_lazy.sh ]; then
  24. source /usr/bin/virtualenvwrapper_lazy.sh
  25. fi
  26. ### FZF
  27. [ -f ${HOME}/.config/zsh/fzf.zsh ] && . ${HOME}/.config/zsh/fzf.zsh
  28. ### ASDF
  29. if [ -d /opt/asdf-vm ]; then
  30. . /opt/asdf-vm/asdf.sh
  31. fi
  32. ### Misc
  33. ## TERM
  34. # Many target machines do not understand TERM=xterm-kitty
  35. if [ "z${TMUX}" = "z" ]; then
  36. function ssh {
  37. TERM=xterm-color /bin/ssh ${@}
  38. }
  39. fi
  40. if [[ ! -z $TMUX ]]; then
  41. export TERM=tmux-256color
  42. fi
  43. ## Editor
  44. export EDITOR=vim
  45. ## Locale
  46. export LANG=.UTF-8
  47. export LANGUAGE=en_US
  48. export LC_CTYPE=en_US.UTF-8
  49. export LC_NUMERIC=en_US.UTF-8
  50. export LC_TIME=it_IT.UTF-8
  51. export LC_COLLATE=en_US.UTF-8
  52. export LC_MONETARY=it_IT.UTF-8
  53. export LC_MESSAGES=en_US.UTF-8
  54. export LC_PAPER=it_IT.UTF-8
  55. export LC_NAME=en_US.UTF-8
  56. export LC_ADDRESS=en_US.UTF-8
  57. export LC_TELEPHONE=en_US.UTF-8
  58. export LC_MEASUREMENT=it_IT.UTF-8
  59. export LC_IDENTIFICATION=en_US.UTF-8
  60. export LC_ALL=
  61. ## Flutter && Dart
  62. export ANDROID_SDK=${HOME}/Android/Sdk
  63. export PATH=${ANDROID_SDK}/emulator:${ANDROID_SDK}/tools:${PATH}
  64. export PATH=$PATH:/opt/flutter/bin/:"$HOME/.pub-cache/bin"
  65. ## Go
  66. export GOPATH=${HOME}/.go
  67. export PATH=$PATH:${GOPATH}/bin
  68. ## Elixir
  69. export ERL_AFLAGS="-kernel shell_history enabled"
  70. ## Aliases
  71. alias t="tmux -2"
  72. alias sy="systemctl"
  73. alias ssy="sudo systemctl"
  74. alias syu="systemctl --user"
  75. alias sl="cmatrix -b -s"
  76. alias cd..="cmatrix -b -s -C yellow"
  77. alias lt="ls -lt"
  78. alias lh="ls -lh"
  79. alias la="ls -la"
  80. alias ll="ls -l"
  81. alias lrt="ls -lrt"
  82. alias wgpg="gpg --homedir /home/leo/.gnupg-work"
  83. alias agpg="gpg --homedir /home/leo/.gnupg-ai"
  84. alias ai_all="cat ${HOME}/Documents/personal/ai/code/prod/hosts.yml|yq '[.hosts|to_entries[]|{"key": .key, "value": .value.groups}]|from_entries'"
  85. alias pacbrowse="pacman -Qq | fzf --preview 'pacman -Qil {}' --layout=reverse --bind 'enter:execute(pacman -Qil {} | less)'"
  86. alias pikbrowse="pikaur -Qq | fzf --preview 'pacman -Qil {}' --layout=reverse --bind 'enter:execute(pikaur -Qil {} | less)'"
  87. alias vf="cd \$(git rev-parse --show-toplevel)"
  88. alias vvf="cd \$(${HOME}/.bin/vvf.sh)"
  89. ## local bin
  90. export PATH=${PATH}:${HOME}/.local/bin:${HOME}/.bin
  91. ## Drone CLI
  92. export DRONE_SERVER=https://drone.troubles.io
  93. export DRONE_TOKEN=MAA6CxziewJZYkHLf5eV5UyEx3Qd26tb
  94. # ensure Git completion
  95. fpath+=/usr/share/git/completion
  96. ## mailbundle
  97. alias mutt="neomutt"
  98. alias mailbundle="/opt/mailbundle/config/bin/autorun"
  99. ## torbrowser
  100. export PATH=$PATH:/opt/tor-browser_en-US
  101. ## platform-tools
  102. export PATH=$PATH:/opt/android-sdk/platform-tools
  103. ## Custom functions
  104. function lookhosts {
  105. if which rg 2>&1 > /dev/null; then
  106. GREP=rg
  107. else
  108. GREP=grep
  109. fi
  110. ${GREP} $@ /etc/hosts
  111. }
  112. function reload_work_gpg {
  113. kill -9 $(ps aux|egrep "gpg-agent.*work"|grep -v grep|awk '{print $2}')
  114. }
  115. function sway-screens {
  116. local screens=$(swaymsg -t get_outputs -r)
  117. local show_active
  118. local show_inactive
  119. local var_style="plain"
  120. local active_screens=()
  121. local inactive_screens=()
  122. while [ $# -ne 0 ]; do
  123. case $1 in
  124. -a|--active)
  125. show_active=1
  126. ;;
  127. -n|--inactive)
  128. show_inactive=1
  129. ;;
  130. -s|--style)
  131. case $2 in
  132. json)
  133. var_style="json"
  134. ;;
  135. plain)
  136. ;;
  137. *)
  138. echo "unknown style ${2}"
  139. return 1
  140. ;;
  141. esac
  142. shift
  143. ;;
  144. esac
  145. shift
  146. done
  147. if [ "z${show_active}" != "z" ]; then
  148. for s in $(echo $screens|jq -r '.[] | select(.active) | .name'); do
  149. active_screens+=($s)
  150. done
  151. fi
  152. if [ "z${show_inactive}" != "z" ]; then
  153. for s in $(echo $screens|jq -r '.[] | select(.active|not) | .name'); do
  154. inactive_screens+=($s)
  155. done
  156. fi
  157. if [ "${var_style}" = "plain" ]; then
  158. if [ ${#active_screens[@]} -gt 0 ]; then
  159. echo "ACTIVE=${active_screens[@]}"
  160. fi
  161. if [ ${#inactive_screens[@]} -gt 0 ]; then
  162. echo "INACTIVE=${inactive_screens[@]}"
  163. fi
  164. else
  165. local active=""
  166. for s in $active_screens; do
  167. active+="\"$s\","
  168. done
  169. active=${active%,}
  170. local inactive=""
  171. for s in $inactive_screens; do
  172. inactive+="\"$s\","
  173. done
  174. inactive=${inactive%,}
  175. local content=""
  176. if [ "z${show_active}" != "z" ]; then
  177. content+="\"active\": [${active}],"
  178. fi
  179. if [ "z${show_inactive}" != "z" ]; then
  180. content+="\"inactive\": [${inactive}],"
  181. fi
  182. content=${content%,}
  183. echo "{${content}}" | jq
  184. fi
  185. }
  186. ## Custom completion
  187. # certo
  188. eval "$(_CERTO_COMPLETE=source_zsh certo)"
  189. # vim: set ft=zsh et sw=0 ts=2 sts=0: