.zshrc 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. # vim:fileencoding=utf-8:foldmethod=marker:foldmarker={{{,}}}
  2. # zo command for open fold
  3. # zc command for close fold
  4. # {{{ Default oh-my-zsh things + powerlevel10k
  5. # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
  6. # Initialization code that may require console input (password prompts, [y/n]
  7. # confirmations, etc.) must go above this block; everything else may go below.
  8. if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  9. source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
  10. fi
  11. # If you come from bash you might have to change your $PATH.
  12. # export PATH=$HOME/bin:/usr/local/bin:$PATH
  13. # Path to your oh-my-zsh installation.
  14. export ZSH="$HOME/.oh-my-zsh"
  15. export EDITOR="/usr/bin/nvim"
  16. # print neofetch when zsh init
  17. #neofetch
  18. # Set name of the theme to load --- if set to "random", it will
  19. # load a random theme each time oh-my-zsh is loaded, in which case,
  20. # to know which specific one was loaded, run: echo $RANDOM_THEME
  21. # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
  22. #ZSH_THEME="robbyrussell"
  23. ZSH_THEME="powerlevel10k/powerlevel10k"
  24. # don't work (why?)
  25. #ZSH_COLORIZE_TOOL=chroma
  26. #ZSH_COLORIZE_CHROMA_FORMATTER=terminal256
  27. # Set list of themes to pick from when loading at random
  28. # Setting this variable when ZSH_THEME=random will cause zsh to load
  29. # a theme from this variable instead of looking in $ZSH/themes/
  30. # If set to an empty array, this variable will have no effect.
  31. # ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
  32. # Uncomment the following line to use case-sensitive completion.
  33. # CASE_SENSITIVE="true"
  34. # Uncomment the following line to use hyphen-insensitive completion.
  35. # Case-sensitive completion must be off. _ and - will be interchangeable.
  36. # HYPHEN_INSENSITIVE="true"
  37. # Uncomment one of the following lines to change the auto-update behavior
  38. # zstyle ':omz:update' mode disabled # disable automatic updates
  39. # zstyle ':omz:update' mode auto # update automatically without asking
  40. zstyle ':omz:update' mode reminder # just remind me to update when it's time
  41. # Uncomment the following line to change how often to auto-update (in days).
  42. zstyle ':omz:update' frequency 14
  43. # Uncomment the following line if pasting URLs and other text is messed up.
  44. # DISABLE_MAGIC_FUNCTIONS="true"
  45. # Uncomment the following line to disable colors in ls.
  46. # DISABLE_LS_COLORS="true"
  47. # Uncomment the following line to disable auto-setting terminal title.
  48. # DISABLE_AUTO_TITLE="true"
  49. # Uncomment the following line to enable command auto-correction.
  50. # ENABLE_CORRECTION="true"
  51. # Uncomment the following line to display red dots whilst waiting for completion.
  52. # You can also set it to another string to have that shown instead of the default red dots.
  53. # e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
  54. # Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
  55. COMPLETION_WAITING_DOTS="true"
  56. # Uncomment the following line if you want to disable marking untracked files
  57. # under VCS as dirty. This makes repository status check for large repositories
  58. # much, much faster.
  59. DISABLE_UNTRACKED_FILES_DIRTY="true"
  60. # Uncomment the following line if you want to change the command execution time
  61. # stamp shown in the history command output.
  62. # You can set one of the optional three formats:
  63. # "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
  64. # or set a custom format using the strftime function format specifications,
  65. # see 'man strftime' for details.
  66. # HIST_STAMPS="mm/dd/yyyy"
  67. HIST_STAMPS="dd.mm.yyyy"
  68. HISTSIZE=100000
  69. SAVEHIST=100000
  70. HISTFILE=~/.cache/zsh/history
  71. # Would you like to use another custom folder than $ZSH/custom?
  72. # ZSH_CUSTOM=/path/to/new-custom-folder
  73. # Which plugins would you like to load?
  74. # Standard plugins can be found in $ZSH/plugins/
  75. # Custom plugins may be added to $ZSH_CUSTOM/plugins/
  76. # Example format: plugins=(rails git textmate ruby lighthouse)
  77. # Add wisely, as too many plugins slow down shell startup.
  78. # }}}
  79. # {{{ Added by sekhali
  80. ##### added by sekhali
  81. # {{{ plugins list with description
  82. ### plugins list
  83. # https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins
  84. ## {{{ alias-finder - find alias for command
  85. # usage
  86. #alias-finder pacman -Q
  87. # this finds all aliases begins from 'pacman -Q'
  88. # }}}
  89. ## {{{ chucknorris - print random Chuck Norris quote
  90. # requires
  91. # fortune (AUR), cowsay
  92. # usage
  93. #chuck
  94. # print random Norris quote
  95. #chuck_cow
  96. # print quote in cow think
  97. # }}}
  98. ## {{{ colored-man-pages - colors man pages
  99. # usage example
  100. #colored git help clone
  101. # }}}
  102. ## {{{ colorize - highlite code syntax (based on file extension)
  103. ##!!!!!!!!!! may be not working (why?)
  104. # requires syntax highlighter
  105. # Chroma (go) or Pygments (Python)
  106. # }}}
  107. ## {{{ command-not-found - provide suggested packages to be installed if a command can't be found
  108. ###!!!!!!!!!! not working (why?)
  109. ###!!!!!!!!!! modified (shebang line)
  110. # }}}
  111. ## {{{ copybuffer - copy current text in command line to system clipboard
  112. # usage
  113. #ctrl+o
  114. # }}}
  115. ## {{{ copyfile - copy full file content to system clipboard
  116. # usage
  117. #copyfile [file/path]
  118. # }}}
  119. ## {{{ emoji - for use Unicode emoji in zsh
  120. # usage
  121. # specific emoji
  122. #echo $emoji[<name>]
  123. #echo $emoji[mouse_face]
  124. # random emoji
  125. #random_emoji
  126. # random emoji from particular group
  127. #random_emoji <group>
  128. #random_emoji fruits
  129. # list all available emoji
  130. #display_emoji
  131. #display_emoji <group>
  132. #display_emoji faces
  133. # }}}
  134. ## {{{ extract - extract archive file, supports wide variety of archive filetypes
  135. # usage
  136. #extract [path/to/archive]
  137. # }}}
  138. ## history-substring-search - type any part of command for search it in history by UP and DOWN keys
  139. ## {{{ man - shortcut for man (learn how to use hotkey [ESC]+command)
  140. # usage
  141. #[ESC]+man (write like command with pushed [ESC])
  142. # }}}
  143. ## zsh-syntax-highlighting - highlight syntax in zsh
  144. ## {{{ zsh-autosuggestions
  145. # usage
  146. #[End] - complete full command
  147. #[Ctrl]+[Right arrow] - complete 1 word in command
  148. # }}}
  149. ##### {{{ may be useful
  150. #autoenv
  151. #autojump (requires autojump package (AUR)
  152. #battery (for notebooks)
  153. #Bower (web sites manager)
  154. #cake && cakephp3 (php framework plugins)
  155. #compleat (autocomplete for parameters) (built-in?)
  156. #composer (dependency manager for php)
  157. #copypath (copy absolute path to directory (usage - 'copypath [path/to/file/or/directory]'))
  158. #cp (addes cpv command that uses rsync for copying)
  159. #deno (javascript runtime)
  160. #direnv (provides using and changing environment variable only in one directory (not in all the system))
  161. #dnote (CLI note book)
  162. #docker
  163. #docker-compose
  164. #docker-machine
  165. #dotnet (.NET Core CLI plugin)
  166. #eecms (auto-completion for eecms(ExpressionEngine CMS (Open-source)))
  167. #encode64 (encoding text/file and decoding text using base64 command) (modified and realized in .zshrc)
  168. #fabric (Python lib to execute shell commands over SSH and returning useful Python objects)
  169. #fancy-ztrl-z (unsuspend suspended process) (realized in .zshrc)
  170. #fastfile (creating shortcuts to dirs/files (works like variables))
  171. #fbterm (runs fbterm in real TTY) (broken?)
  172. #git-auto-fetch (autofetching all changes from all remotes while u working in a git-initialized dir)
  173. #git-escape-magic (adding escape symbol to meta-characters in git commands)
  174. #git-extras (requires git-extras package) (adding some commands to git, that allow input less count of commands)
  175. #ipfs (completion for IPFS) (P2P hypermedia protocol (InterPlanetary File System))
  176. #nmap (aliases for nmap) (learn aliases)
  177. #systemadmin (aliases for sysadmins)
  178. #thefuck (legendary shit. previous command fixer)
  179. #themes (realtime change themes for zsh)
  180. #zsh-interactive-cd (requires fzf) (interactive cd command)
  181. ##### end may be useful
  182. # }}}
  183. # end plugins list with description }}}
  184. ### end added by sekhali
  185. # }}}
  186. # {{{ active plugins
  187. plugins=(
  188. git
  189. alias-finder
  190. chucknorris
  191. colored-man-pages
  192. command-not-found
  193. copybuffer
  194. copyfile
  195. emoji
  196. extract
  197. history-substring-search
  198. man
  199. zsh-syntax-highlighting
  200. zsh-autosuggestions
  201. )
  202. # }}}
  203. # {{{ continue default oh-my-zsh things
  204. source $ZSH/oh-my-zsh.sh
  205. # source for command-not-found
  206. ~/.oh-my-zsh/plugins/command-not-found/command-not-found.plugin.zsh
  207. # User configuration
  208. # export MANPATH="/usr/local/man:$MANPATH"
  209. # You may need to manually set your language environment
  210. # export LANG=en_US.UTF-8
  211. export LANG=ru_RU.UTF-8
  212. # Preferred editor for local and remote sessions
  213. # if [[ -n $SSH_CONNECTION ]]; then
  214. # export EDITOR='vim'
  215. # else
  216. # export EDITOR='mvim'
  217. # fi
  218. # Compilation flags
  219. # export ARCHFLAGS="-arch x86_64"
  220. # Set personal aliases, overriding those provided by oh-my-zsh libs,
  221. # plugins, and themes. Aliases can be placed here, though oh-my-zsh
  222. # users are encouraged to define aliases within the ZSH_CUSTOM folder.
  223. # For a full list of active aliases, run `alias`.
  224. #
  225. # Example aliases
  226. # alias zshconfig="mate ~/.zshrc"
  227. # alias ohmyzsh="mate ~/.oh-my-zsh"
  228. # }}}
  229. ###### {{{ Added by sekhali
  230. ##### {{{ misc functions
  231. # check .inputrc
  232. ##### end misc functions }}}
  233. ##### {{{ aliases
  234. #### {{{ suffix aliases
  235. #### used for open files with prefering editor
  236. alias -s txt=nvim
  237. alias -s cs=nvim
  238. alias -s cpp=nvim
  239. alias -s lua=nvim
  240. alias -s cfg=nvim
  241. alias -s conf=nvim
  242. alias -s zsh=/bin/zsh
  243. alias -s sh=/bin/bash
  244. #### end suffix aliases }}}
  245. #### {{{ global aliases
  246. #### can work in millde or end of command
  247. # syntax is
  248. #alias -g upgdg='sudo pacman -Syu'
  249. # redirection to null
  250. alias -g TN='2>/dev/null'
  251. #### end global aliases }}}
  252. #### {{{ function aliases
  253. ###### list of available keycodes
  254. # https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets
  255. #### using functions as aliases
  256. # {{{ syntax
  257. #[alias-name](){
  258. # command $parameter1 $parameter2
  259. #}
  260. # }}}
  261. # {{{ example
  262. #find_man() {
  263. # man $1 | grep -- $2
  264. #}
  265. # }}}
  266. # {{{ usage example
  267. #find_man kill "SIGTERM"
  268. # }}}
  269. ### {{{ adding pair to symbol
  270. close-square-bracket() {
  271. LBUFFER="${LBUFFER}["
  272. RBUFFER="]${RBUFFER}"
  273. }
  274. zle -N close-square-bracket
  275. bindkey '[' close-square-bracket
  276. close-curly-bracket() {
  277. LBUFFER="${LBUFFER}{"
  278. RBUFFER="}${RBUFFER}"
  279. }
  280. zle -N close-curly-bracket
  281. bindkey '{' close-curly-bracket
  282. close-round-bracket()
  283. {
  284. LBUFFER="${LBUFFER}("
  285. RBUFFER=")${RBUFFER}"
  286. }
  287. zle -N close-round-bracket
  288. bindkey '(' close-round-bracket
  289. close-apostrophe() {
  290. LBUFFER="${LBUFFER}'"
  291. RBUFFER="'${RBUFFER}"
  292. }
  293. zle -N close-apostrophe
  294. bindkey '\047' close-apostrophe
  295. close-tilda-dot() {
  296. LBUFFER="${LBUFFER}\`"
  297. RBUFFER="\`${RBUFFER}"
  298. }
  299. zle -N close-tilda-dot
  300. bindkey '`' close-tilda-dot
  301. close-quotes() {
  302. LBUFFER="${LBUFFER}\""
  303. RBUFFER="\"${RBUFFER}"
  304. }
  305. zle -N close-quotes
  306. bindkey '"' close-quotes
  307. ### end adding pair to symbol }}}
  308. ### {{{ misc
  309. ## {{{ work with base64
  310. encode64() {
  311. if [[ $# -eq 0 ]]; then
  312. #echo "No text to encode"
  313. cat | base64
  314. else
  315. echo $1 | base64
  316. fi
  317. }
  318. encode-file64() {
  319. if [[ $# -eq 0 ]]; then
  320. echo "You must write path to file for encode"
  321. else
  322. base64 $1 > $1.txt
  323. echo "${1}'s content encoded in base64 and saved as ${1}.txt"
  324. fi
  325. }
  326. decode64() {
  327. if [[ $# -eq 0 ]]; then
  328. #echo "No text to decode"
  329. cat | base64 --decode
  330. else
  331. printf '%s' $1 | base64 --decode
  332. fi
  333. }
  334. decode-file64() {
  335. if [[ $# -eq 0 ]]; then
  336. echo "You must write path to file for encode"
  337. else
  338. base64 --decode $1 > $1.txt
  339. echo "${1}'s content decoded from base64 and saved as ${1}.txt"
  340. fi
  341. }
  342. ## end work with base64 }}}
  343. ## {{{ system things
  344. # {{{ fancy-ctrl-z realization
  345. fancy-ctrl-z () {
  346. if [[ $#BUFFER -eq 0 ]]; then
  347. BUFFER="fg"
  348. zle accept-line -w
  349. fi
  350. }
  351. # }}}
  352. # {{{ find--everywhere
  353. find--everywhere () {
  354. if [[ $# -eq 0 ]]; then
  355. echo "No word to find"
  356. else
  357. find / -name $1 2>/dev/null
  358. fi
  359. }
  360. # }}}
  361. # {{{ open-ranger (by Ctrl+g hotkey)
  362. open-ranger() {
  363. # if there is no command typed, open ranger in current directory
  364. if [[ $#BUFFER -eq 0 ]]; then
  365. BUFFER="ranger `pwd`"
  366. zle accept-line -w
  367. # if there is command typed, comment and push it, then open ranger in current directory
  368. else
  369. BUFFER="# $BUFFER"
  370. zle accept-line -w
  371. #BUFFER="#ranger `pwd`"
  372. #zle accept-line -w
  373. fi
  374. # if there is no command typed, use the last command
  375. #[[ -z "$BUFFER" ]] && zle up-history
  376. # if typed command begins with man, do nothing
  377. #[[ "$BUFFER" = man\ * ]] && return
  378. # get command and possible subcommand
  379. # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
  380. #local -a args
  381. #args=(${${(Az)BUFFER}[1]} ${${(Az)BUFFER}[2]})
  382. # check if man page exists for command and first argument
  383. #if man "${args[1]}-${args[2]}" >/dev/null 2>&1; then
  384. # BUFFER="man $args"
  385. #else
  386. # BUFFER="man ${args[1]}"
  387. #fi
  388. }
  389. zle -N open-ranger
  390. # Defined shortcut keys: [Ctrl]g
  391. bindkey "\C"g open-ranger
  392. # }}}
  393. ## end system things }}}
  394. ## {{{ jokes
  395. # {{{ gachi string
  396. #requires emoji plugin
  397. gachi() {
  398. if [[ $# -eq 0 ]]; then
  399. echo $emoji[male_sign]$emoji[male_sign]
  400. else
  401. echo $emoji[male_sign]$1$emoji[male_sign]
  402. fi
  403. }
  404. # }}}
  405. ## end jokes }}}
  406. ### end misc }}}
  407. #### end function aliases }}}
  408. #### {{{ normal aliases
  409. ### {{{ Rewrite shell-built aliases
  410. alias l='ls -lFh'
  411. alias la='ls -lFha'
  412. alias l--dot='ls -ld .*'
  413. alias l--col='ls -1F'
  414. alias la--col='ls -1aF'
  415. ### end rewrite shell-built aliases }}}
  416. ### {{{ pacman and paru
  417. alias inst='sudo pacman -Sy --needed'
  418. alias pacman--upg='sudo pacman -Syu'
  419. alias pacman--rem='sudo pacman -Rscun'
  420. alias pacman--reposearch='pacman -Ss'
  421. alias pacman--localsearch='pacman -Qs | grep'
  422. alias pacman--package-owner='pacman -Qo'
  423. # clean old and unused cache and packages
  424. alias paclean='sudo pacman -Sc'
  425. # erase all pacman cache
  426. alias pacman--erasecache='sudo pacman -Scc'
  427. alias pacman--orphans-show='pacman -Qdt'
  428. # erase all orphan packages
  429. alias pacman--oprhans-erase='sudo pacman -Rs $(pacman -Qtdq)'
  430. alias paru--upg='paru --aur -Syu'
  431. alias paru--aur='paru --aur'
  432. alias paru--rem='paru -Rscun'
  433. alias upgdg='sudo pacman -Syu && paru --aur -Syu && sudo mkinitcpio -p linux-zen && sudo pacman -Sc'
  434. ### end pacman and paru }}}
  435. ### {{{ system things
  436. alias cls='clear'
  437. alias lsblk_sys='lsblk -o name,parttypename,label,partlabel,pttype,model,mode,fstype,fsver,size,fsavail,fsused,fsuse%,mountpoints'
  438. alias lsblko='lsblk -o name,label,fstype,fsver,uuid,size,fsavail,fsused,fsuse%,mountpoints'
  439. alias zshrc='nvim ~/.zshrc'
  440. alias awesome--config='nvim ~/.config/awesome/rc.lua'
  441. alias awesome--test='Xephyr :5 & sleep 1 ; DISPLAY=:5 awesome'
  442. # show files with size
  443. alias pwd--files-size='du -d 1 -h'
  444. alias pwd--size='du -sh'
  445. alias hist--grep='fc -El 0 | grep'
  446. alias cur--processes='ps -f'
  447. alias ..='cd ..'
  448. alias ....='cd ../..'
  449. alias ......='cd ../../..'
  450. alias ........='cd ../../../..'
  451. alias _autostart_script='sudo ~/autostart_scripts/main.sh'
  452. alias cleanup='sudo pacman -Scc && sudo pacman -Qtdq && echo "\nOrphans shown. Type \"sudo pacman -Qtdq | sudo pacman -Rns -\" for delete them" && echo "Or for show optional depends type \"pacman -Qttdq\"" && echo "For see info about package type \"pacman -Qii [package-name]\" and watch at \"Required By\" line" && echo "Type \"pacman -Qe\" for see manually installed packages" && echo "Type \"pacman -Qm\" for see third-party packages (mainly from AUR)\n"'
  453. ### end system things }}}
  454. ### {{{ no category
  455. alias exa--long='exa -alFh --icons'
  456. alias exa--col='exa -a1Fh --icons'
  457. alias exa--recursive='exa -aFTh --icons'
  458. alias exa--longrecursive'exa -alFTh --icons'
  459. ### end no category }}}
  460. ### {{{ misc
  461. # Launch Minecraft
  462. #alias MINE="/usr/lib/jvm/java-8-openjdk/jre/bin/java -Xmx4096M -Xms4096M -jar ~/minecraft/TLauncher.jar"
  463. alias show='egrep -v "(^#|^$)"'
  464. ### end misc }}}
  465. ### {{{ Python
  466. alias pip3in='pip3 install --user --break-system-packages --upgrade'
  467. ### End python}}}
  468. ### {{{ idk how to use it
  469. # telling that this useful for searching within files
  470. #sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS}'
  471. ### end idk how to use it }}}
  472. #### end normal aliases }}}
  473. ##### end aliases }}}
  474. ###### end added by sekhali }}}
  475. # {{{ Last zsh init things
  476. # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
  477. [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
  478. # }}}