.zshrc 5.4 KB

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