4l3xBB

.zshrc

Sep 24th, 2024
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 9.29 KB | Cybersecurity | 0 0
  1. # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
  2. # Initialization code that may require console input (password prompts, [y/n]
  3. # confirmations, etc.) must go above this block; everything else may go below.
  4. #if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  5. #  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
  6. #fi
  7.  
  8. ## ---------------------------- ##
  9. ## ----- Java Problem Fix ----- ##
  10. ## ---------------------------- ##
  11. export _JAVA_AWT_WM_NONREPARENTING=1
  12.  
  13. # Created by newuser for 5.9
  14. source /home/al3xbb/powerlevel10k/powerlevel10k.zsh-theme
  15.  
  16. ###########################################################
  17. ######################  ZSH PLUGINS  ######################
  18. ###########################################################
  19.  
  20. ## -------------------------------------- ##
  21. ## ----- ZSH AutoSuggestions Plugin ----- ##
  22. ## -------------------------------------- ##
  23. #if [[ -f /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh ]]; then
  24. #  source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
  25. #fi
  26.  
  27. ## ------------------------------------------ ##
  28. ## ----- ZSH Syntax Highlighting Plugin ----- ##
  29. ## ------------------------------------------ ##
  30. if [[ -f /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]]; then
  31.   source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
  32.  
  33.   if [[ -f /home/al3xbb/.config/zsh/zsh-syntaxhighlighting/themes/dracula.zsh ]] ; then
  34.     source /home/al3xbb/.config/zsh/zsh-syntaxhighlighting/themes/dracula.zsh
  35.   fi
  36. fi
  37.  
  38. ## --------------------------- ##
  39. ## ----- ZSH Sudo Plugin ----- ##
  40. ## --------------------------- ##
  41. if [[ -f /usr/share/zsh-sudo/sudo.plugin.zsh ]]; then
  42.   source /usr/share/zsh-sudo/sudo.plugin.zsh
  43. fi
  44.  
  45. ##########################################################
  46. ####################  CUSTOM ALIASES  ####################
  47. ##########################################################
  48.  
  49. ## --------------- ##
  50. ## ----- BAT ----- ##
  51. ## --------------- ##
  52. alias cat='bat'
  53. alias catn='bat --style=plain'
  54. alias catnp='bat --style=plain --paging=never'
  55.  
  56. ## --------------- ##
  57. ## ----- lsd ----- ##
  58. ## --------------- ##
  59. alias ll='lsd -lh --group-dirs=first'
  60. alias la='lsd -a --group-dirs=first'
  61. alias l='lsd --group-dirs=first'
  62. alias lla='lsd -lha --group-dirs=first'
  63. alias ls='lsd --group-dirs=first'
  64.  
  65. ###########################################################
  66. ######################  ZSH WIDGETS  ######################
  67. ###########################################################
  68.  
  69. ## --------------------------------------------------- ##
  70. ## ----- Command-line Editor (Bash-like C-x C-e) ----- ##
  71. ## --------------------------------------------------- ##
  72. autoload -U edit-command-line
  73. zle -N edit-command-line
  74. bindkey '\C-x\C-e' edit-command-line
  75.  
  76. ## ---------------------------------------- ##
  77. ## ----- Use modern completion system ----- ##
  78. ## ---------------------------------------- ##
  79. autoload -Uz compinit
  80. compinit
  81.  
  82. zstyle ':completion:*' auto-description 'specify: %d'
  83. zstyle ':completion:*' completer _expand _complete _correct _approximate
  84. zstyle ':completion:*' format 'Completing %d'
  85. zstyle ':completion:*' group-name ''
  86. zstyle ':completion:*' menu select=2
  87. eval "$(dircolors -b)"
  88. zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
  89. zstyle ':completion:*' list-colors ''
  90. zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
  91. zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
  92. zstyle ':completion:*' menu select=long
  93. zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
  94. zstyle ':completion:*' use-compctl false
  95. zstyle ':completion:*' verbose true
  96.  
  97. zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
  98. zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
  99.  
  100. ############################################################
  101. #########################   FZF    #########################
  102. ############################################################
  103.  
  104. [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
  105.  
  106. ## ----------------------------------------------- ##
  107. ## ----- FZF Parameter (C-k Up and C-j Down) ----- ##
  108. ## ----------------------------------------------- ##
  109. #export FZF_DEFAULT_OPTS='--bind=ctrl-r:toggle-sort,ctrl-u:up,ctrl-d:down'
  110.  
  111. ############################################################
  112. #########################   MISC   #########################
  113. ############################################################
  114.  
  115. ## ------------------- ##
  116. ## ----- History ----- ##
  117. ## ------------------- ##
  118. HISTFILE=~/.zsh_history
  119. HISTSIZE=10000
  120. SAVEHIST=10000
  121. setopt histignorealldups sharehistory
  122.  
  123. ## ----------------------- ##
  124. ## ----- Text Editor ----- ##
  125. ## ----------------------- ##
  126. export EDITOR=/opt/nvim/nvim-linux64/bin/nvim
  127.  
  128. ## -------------------------- ##
  129. ## ----- PATH Parameter ----- ##
  130. ## -------------------------- ##
  131. export PATH=/opt/kitty/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/sbin:/opt/nvim/nvim-linux64/bin:/home/al3xbb/.fzf/bin:/home/al3xbb/.cargo/bin
  132.  
  133. ## ------------------------------------ ##
  134. ## ----- LSD Parameter (Non-Bold) ----- ##
  135. ## ------------------------------------ ##
  136. export LS_COLORS='rs=0:di=34:ln=36:mh=00:pi=40;33:so=35:do=35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=00:tw=30;42:ow=34;42:st=37;44:ex=32:*.tar=31:*.tgz=31:*.arc=31:*.arj=31:*.taz=31:*.lha=31:*.lz4=31:*.lzh=31:*.lzma=31:*.tlz=31:*.txz=31:*.tzo=31:*.t7z=31:*.zip=31:*.z=31:*.dz=31:*.gz=31:*.lrz=31:*.lz=31:*.lzo=31:*.xz=31:*.zst=31:*.tzst=31:*.bz2=31:*.bz=31:*.tbz=31:*.tbz2=31:*.tz=31:*.deb=31:*.rpm=31:*.jar=31:*.war=31:*.ear=31:*.sar=31:*.rar=31:*.alz=31:*.ace=31:*.zoo=31:*.cpio=31:*.7z=31:*.rz=31:*.cab=31:*.wim=31:*.swm=31:*.dwm=31:*.esd=31:*.avif=35:*.jpg=35:*.jpeg=35:*.mjpg=35:*.mjpeg=35:*.gif=35:*.bmp=35:*.pbm=35:*.pgm=35:*.ppm=35:*.tga=35:*.xbm=35:*.xpm=35:*.tif=35:*.tiff=35:*.png=35:*.svg=35:*.svgz=35:*.mng=35:*.pcx=35:*.mov=35:*.mpg=35:*.mpeg=35:*.m2v=35:*.mkv=35:*.webm=35:*.webp=35:*.ogm=35:*.mp4=35:*.m4v=35:*.mp4v=35:*.vob=35:*.qt=35:*.nuv=35:*.wmv=35:*.asf=35:*.rm=35:*.rmvb=35:*.flc=35:*.avi=35:*.fli=35:*.flv=35:*.gl=35:*.dl=35:*.xcf=35:*.xwd=35:*.yuv=35:*.cgm=35:*.emf=35:*.ogv=35:*.ogx=35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:*~=00;90:*#=00;90:*.bak=00;90:*.old=00;90:*.orig=00;90:*.part=00;90:*.rej=00;90:*.swp=00;90:*.tmp=00;90:*.dpkg-dist=00;90:*.dpkg-old=00;90:*.ucf-dist=00;90:*.ucf-new=00;90:*.ucf-old=00;90:*.rpmnew=00;90:*.rpmorig=00;90:*.rpmsave=00;90:'
  137.  
  138. ## ---------------------------- ##
  139. ## ----- P10K - ZSH THEME ----- ##
  140. ## ---------------------------- ##
  141. # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
  142. [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
  143.  
  144. ###########################################################
  145. ###################  LOCATE | UPDATEDB  ###################
  146. ###########################################################
  147.  
  148. umountLocate ()
  149. {
  150.   local -- _path=
  151.  
  152.   for _path in /run/user/1000/{gvfs,doc}
  153.   do
  154.     mount | grep --quiet "$_path" && umount "$_path"
  155.   done
  156. }
  157.  
  158. umountLocate
  159.  
  160. ############################################################
  161. ####################  CUSTOM FUNCTIONS  ####################
  162. ############################################################
  163.  
  164. # Inner Module | Right Bar | Polybar
  165. # Validate IP Address
  166.  
  167. validateIP () {
  168.     local _IP=$1 _octet=
  169.     [[ $_IP =~ ^[0-9]+(\.[0-9]+){3}$ ]] || return 1
  170.     while read -rd '.' _octet
  171.     do
  172.         (( _octet > 255 )) && return 1
  173.     done <<< "$_IP".
  174.     return 0
  175. }
  176.  
  177. # Inner Module | Right Bar | Polybar
  178. # Set Target's IP and Hostname
  179.  
  180. setTarget () {
  181.     local -- _IP=$1 _machineName=$2 \
  182.              _targetFile=/home/al3xbb/.config/bin/target
  183.  
  184.     (( $# != 2 )) && {
  185.         /bin/cat <<HELP 1>&2
  186.  
  187.   [!] This function requires two arguments: IP Addresss and Machine Name
  188.  
  189.     Syntax: setTarget XXX.XXX.XXX.XXX "Machine Name"
  190. HELP
  191.         return 1
  192.     }
  193.     validateIP "$_IP" || {
  194.         printf "\n%s\n" '[!] First arg must be a valid IP Address' 1>&2
  195.         return 1
  196.     }
  197.     [[ -n $_IP && -n $_machineName ]] || {
  198.         printf "\n%s\n" '[!] Args cannot be an empty string' 1>&2
  199.         return 1
  200.     }
  201.     printf "%s:%s\n" "$_IP" "$_machineName" > "$_targetFile"
  202. }
  203.  
  204. # Inner Module | Right Bar | Polybar
  205. # Clear Target Host's File
  206.  
  207. clearTarget () {
  208.     local -- _targetFile=/home/al3xbb/.config/bin/target
  209.     [[ -s $_targetFile ]] && : '' > "$_targetFile" || return 1
  210. }
  211.  
  212. # Clear Visible Screen and ScrollBack Bufer | Terminal
  213. # https://unix.stackexchange.com/questions/517025/zsh-clear-scrollback-buffer#answer-531178
  214. # Emulates Bash Functionality -> C + alt + L (Clears Screen and Scrollback Buffer)
  215.  
  216. clearScreenAndScrollback () {
  217.   clear && printf '\e[3J'
  218.   zle && zle .reset-prompt && zle -R
  219. }
  220.  
  221. zle -N clearScreenAndScrollback       # Function Register as New Widget in ZLE (ZSH Line Editor)
  222. bindkey '^L' clearScreenAndScrollback # Keybind -> C + L runs declared function (Buffer ScrollBack Clear)
  223. #bindkey '^[^L' clearScrollbackBuffer # Keybind -> C + alt + L runs declared function (Buffer ScrollBack Clear)
Advertisement
Add Comment
Please, Sign In to add comment