🐧 One more repository with f*cking dot files...
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.

140 lines
3.4 KiB

  1. # .zshrc -- Samuel FORESTIER
  2. # Enable Powerlevel10k instant prompt before anything else.
  3. if [ -r "${XDG_CACHE_HOME:-${HOME}/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]; then
  4. source "${XDG_CACHE_HOME:-${HOME}/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
  5. fi
  6. ## Oh My ZSH auto-update
  7. UPDATE_ZSH_DAYS=7
  8. DISABLE_UPDATE_PROMPT="true"
  9. ## Some personal ZSH parameters
  10. ENABLE_CORRECTION="true"
  11. HYPHEN_INSENSITIVE="true"
  12. COMPLETION_WAITING_DOTS="true"
  13. HIST_STAMPS="dd.mm.yyyy"
  14. ## Antigen stuffs
  15. source "${HOME}"/.antigen.zsh
  16. antigen use oh-my-zsh
  17. antigen bundle adb
  18. antigen bundle common-aliases
  19. antigen bundle composer
  20. antigen bundle copybuffer
  21. antigen bundle copydir
  22. antigen bundle copyfile
  23. antigen bundle docker
  24. antigen bundle emoji
  25. antigen bundle encode64
  26. antigen bundle extract
  27. antigen bundle gem
  28. antigen bundle git
  29. antigen bundle gitignore
  30. antigen bundle jsontools
  31. antigen bundle man
  32. antigen bundle nmap
  33. antigen bundle npm
  34. antigen bundle pip
  35. antigen bundle safe-paste
  36. antigen bundle sublime
  37. antigen bundle python
  38. antigen bundle torrent
  39. antigen bundle transfer
  40. antigen bundle urltools
  41. antigen bundle zsh_reload
  42. antigen bundle zsh-users/zsh-syntax-highlighting
  43. antigen bundle supercrabtree/k
  44. antigen theme romkatv/powerlevel10k
  45. antigen apply
  46. ## Personal old stuffs ported there
  47. setopt dotglob # Makes `*` match hidden files too
  48. export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
  49. ## Let's setup beautiful CLI tools here !
  50. if command -v bat > /dev/null 2>&1; then
  51. alias cat='bat'
  52. export PAGER="bat -p"
  53. export MANPAGER="sh -c 'col -b | bat -l man -p'"
  54. if command -v fzf > /dev/null 2>&1; then
  55. source /usr/share/doc/fzf/examples/key-bindings.zsh
  56. alias preview="fzf --preview 'bat --color \"always\" {}'"
  57. export FZF_DEFAULT_OPTS="--height 90% --no-reverse"
  58. export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -200'"
  59. export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:hidden:wrap --bind '?:toggle-preview'"
  60. export FZF_CTRL_T_OPTS="--preview '((test -f {} && bat --color always {}) || tree -C {}) 2> /dev/null | head -200'"
  61. fi
  62. fi
  63. if command -v prettyping > /dev/null 2>&1; then
  64. alias ping='prettyping --nolegend'
  65. fi
  66. # Enforce Powerlevel10k configuration.
  67. if [ -f "${HOME}"/.p10k.zsh ]; then
  68. source "${HOME}"/.p10k.zsh
  69. fi
  70. alias ll="k"
  71. alias ip="ip -color"
  72. alias zsh_reload="src"
  73. ## Personal shell macros
  74. # Personal SSH keys handler
  75. keys()
  76. {
  77. if [[ "$1" == "up" ]]; then
  78. # Let's load the keys into the SSH agent, for 1 hour
  79. ssh-add -t 3600
  80. elif [[ "$1" == "down" ]]; then
  81. # Let's unload the keys (why would you do that ?)
  82. ssh-add -D
  83. else
  84. # Just print out the loaded keys...
  85. ssh-add -l
  86. fi
  87. }
  88. # BigEndian to LittleEndian conversion (ZSH-compatible)
  89. betole()
  90. {
  91. if [ -z "$1" ]; then
  92. >&2 echo "Address needed !"
  93. return 2
  94. fi
  95. echo -n "$1" | python3 -c 'import sys; a = sys.stdin.readlines()[0].replace("0x", ""); print("".join(["\\x" + a[i - 1] + a[i] for i in range(len(a) - 1, 0, -2)]))'
  96. }
  97. # String "sanitization" ("sluggifying" procedure)
  98. strsan()
  99. {
  100. if [ -z "$1" ]; then
  101. >&2 echo "String needed !"
  102. return 2
  103. fi
  104. echo -n "$1" | python3 -c 'import re; import sys; print(re.sub(r"\W+", "-", sys.stdin.readlines()[0].strip().lower()).strip("-"))'
  105. }
  106. # Adds required padding to a given Base64 blob and decodes it !
  107. pad64()
  108. {
  109. if [ -z "$1" ]; then
  110. >&2 echo "Blob needed !"
  111. return 2
  112. fi
  113. echo -n "$1" | python3 -c 'import sys; a = sys.stdin.readlines()[0].strip().rstrip("="); print(a + "=" * (4 - (len(a) % 4)))' | base64 -d
  114. }