diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index c1fd1a6..ee2a931 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -12,7 +12,7 @@ setopt auto_cd # auto cd if directory __CONFIG_DIR=${XDG_CONFIG_HOME:-$HOME/.config} # highlight on tab (completion) -[ -f $__CONFIG_DIR/zsh/completion ] && source $__CONFIG_DIR/zsh/completion +[ -f $__CONFIG_DIR/zsh/include/completion ] && source $__CONFIG_DIR/zsh/include/completion # zstyle ':completion:*:*:git:*' script /usr/local/etc/bash_completion.d/git-completion.bash # fpath=(/usr/local/share/zsh-completions $fpath) # autoload -U compinit && compinit -u @@ -20,10 +20,10 @@ __CONFIG_DIR=${XDG_CONFIG_HOME:-$HOME/.config} # zstyle ':completion:*' menu select # Alias -[ -f $__CONFIG_DIR/zsh/aliases ] && source $__CONFIG_DIR/zsh/aliases +[ -f $__CONFIG_DIR/zsh/include/aliases ] && source $__CONFIG_DIR/zsh/include/aliases # Theme -[ -f $__CONFIG_DIR/zsh/theme ] && source $__CONFIG_DIR/zsh/theme +[ -f $__CONFIG_DIR/zsh/include/theme ] && source $__CONFIG_DIR/zsh/include/theme # opam test -r /home/ziro/.opam/opam-init/init.zsh && . /home/ziro/.opam/opam-init/init.zsh > /dev/null 2> /dev/null || true @@ -39,7 +39,7 @@ bindkey -v export KEYTIMEOUT=1 # Keybindings -[ -f $__CONFIG_DIR/zsh/keybinds ] && source $__CONFIG_DIR/zsh/keybinds +[ -f $__CONFIG_DIR/zsh/include/keybinds ] && source $__CONFIG_DIR/zsh/include/keybinds # [[ Plugins ZSH_PLUGINS="$XDG_DATA_HOME/zsh/plugins" diff --git a/.config/zsh/aliases b/.config/zsh/aliases deleted file mode 100644 index a21b4d1..0000000 --- a/.config/zsh/aliases +++ /dev/null @@ -1,136 +0,0 @@ -#!/usr/bin/env bash - -if [[ "$OSTYPE" == "darwin"* ]]; then - # i need sudo to launch emulator - alias pixelemu="sudo $HOME/Library/Android/sdk/emulator/emulator @Pixel_2_API_28" - alias mbrew="sudo -H -u maintenance -g staff brew" -fi - -alias punten='doas' -#sudo + vim without sacrificing config -alias sudovim='sudoedit' -alias doasvim='doasedit' - -#switch to pgsql user -alias pg='doas -u postgres' - -#mysql with color -# alias mysql=$(echo -e 'mysql --prompt="\x1B[34m\\d\x1B[32m \n>\x1B[0m "') - -#vim -alias nano=nvim -alias vim=nvim -alias vimsudo='sudoedit /etc/sudoers' -alias vimdoas='doasedit /etc/sudoers' -alias vi=nvim -alias v=nvim - -#emacs -alias emacs="emacs -nw" - -#mutt -alias mutt="neomutt" - -#curl -alias weather='curl wttr.in' - -#install -alias p='doas pacman' -alias a='paru' - -#ripper -alias yt='yt-dlp --add-metadata' -alias yta='yt-dlp --add-metadata -x --audio-format' -alias xreload='xrdb $HOME/.config/Xresources' - -#clean up -alias wget='wget --hsts-file="$XDG_CACHE_HOME/wget-hsts"' - -#shortcuts -alias ytv='youtube-viewer' -alias gravit="$HOME/my\ Files/Gravit/GravitDesigner.AppImage" -alias redoom="$HOME/doom refresh" -alias rvim='doas vim' -alias py='python' -alias cls='clear' -alias classprop='xprop WM_CLASS' -alias storagelist='lsblk -f' -alias ..='cd ..' -alias ...='cd ../..' -alias ....='cd ../../..' -alias .....='cd ../../../..' -alias q='exit' - -#ls stuff -alias l='exa --color=always --group-directories-first' # my preferred listing -alias ls='exa --color=always --group-directories-first' # my preferred listing -alias la='exa -a --color=always --group-directories-first' # all files and dirs -alias ll='exa -l --color=always --group-directories-first' # long format -alias lla='exa -al --color=always --group-directories-first' # long format -alias lt='exa -aT --color=always --group-directories-first' # tree listing - -alias md='mkdir -p' -alias rd='rmdir' - -alias reUSD='rm -rf /tmp/rate.html /tmp/rateUSD.txt' -#alias mpv='mpv --geometry=1280x720' - -#config shortcuts -alias config='cd ${DOTFILES:-$HOME/Build/GIT/dotfiles}' -alias cfg='config' -alias cfvim='vim $XDG_CONFIG_HOME/nvim/init.lua' -alias cfvimplug='vim $XDG_CONFIG_HOME/nvim/lua/null/plugins/' -alias cfvimnix='vim $XDG_CONFIG_HOME/nvim/lua/null/nix.lua' -alias cfvimuni='vim $XDG_CONFIG_HOME/nvim/lua/null/config.lua' -alias cfbash='vim $HOME/.bashrc' -alias cfzsh='vim $XDG_CONFIG_HOME/zsh/.zshrc' -alias cfxres='vim $XDG_CONFIG_HOME/Xresources' -alias cfbsp='vim $XDG_CONFIG_HOME/bspwm/bspwmrc' -alias cfqtile='vim $XDG_CONFIG_HOME/qtile/config.py' -alias cfpoly='vim $XDG_CONFIG_HOME/polybar/config' -alias cfkeys='vim $XDG_CONFIG_HOME/sxhkd/sxhkdrc' -alias cfalias='vim $XDG_CONFIG_HOME/zsh/aliases' -alias cfbind='vim $XDG_CONFIG_HOME/zsh/keybinds' -alias cfprofile='vim $XDG_CONFIG_HOME/zsh/.zprofile' -alias cfxprofile='vim $XDG_CONFIG_HOME/xprofile' -alias cfcompt='vim $XDG_CONFIG_HOME/picom/picom.conf' -alias cfenv='vim $XDG_CONFIG_HOME/zsh/.zshenv' -alias cfmutt='vim $XDG_CONFIG_HOME/mutt/muttrc' -alias cfnews='vim $XDG_CONFIG_HOME/newsboat/urls' - -#more shortcuts -alias htop='htop -t' -alias rm='rm -i' -alias mv='mv -i' -alias cp='cp -i' -alias mntfd='doas mount -o gid=users,fmask=113,dmask=002' -alias umntfd='doas umount' -alias cmatrix='unimatrix -n -s 96 -l "o"' -alias s='cd $HOME/.local/bin/scripts;ls' - -#folder shortcut -alias cdclg='cd "$HOME/my Files/Kuliah/"' -alias cdwine='cd "$HOME/.local/share/wineprefixes/"' - -#Git Aliases -alias cdgit='cd $HOME/Build/GIT' -alias gaa='git add -A' -alias gci='git commit' -alias gca='git commit --all' -alias gr='git rm' -alias gR='git restore' -alias gs='git status' -alias gp='git push' -alias gP='git pull' -alias gcl='git clone' -#alias config='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME' - -alias qn='vim $HOME/Documents/QuickNote' - -alias docx2pdf='lowriter --convert-to pdf' - -alias mirror-update='curl -s "https://archlinux.org/mirrorlist/?country=ID&country=SG&country=US&protocol=https&use_mirror_status=on" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 5 -' -alias center-pfetch="printf '\n'; pfetch | sed '\$d' | center -l" -[ "$TERM" = "xterm-kitty" ] && alias ssh="kitty +kitten ssh" - -alias neofetch='fastfetch' diff --git a/.config/zsh/aliases b/.config/zsh/aliases new file mode 120000 index 0000000..699dd25 --- /dev/null +++ b/.config/zsh/aliases @@ -0,0 +1 @@ +include/aliases \ No newline at end of file diff --git a/.config/zsh/completion b/.config/zsh/completion deleted file mode 100644 index 9f42d1e..0000000 --- a/.config/zsh/completion +++ /dev/null @@ -1,76 +0,0 @@ -# vim: filetype=zsh -zstyle ':completion:*:*:git:*' script /usr/local/etc/bash_completion.d/git-completion.bash -fpath=(/usr/local/share/zsh-completions $fpath) - -autoload -Uz compinit - -if [[ "$OSTYPE" == "darwin"* ]]; then - FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}" - compinit -u # homebrew moment, not recommended but whatever -else - compinit -fi - -zmodload -i zsh/complist -zstyle ':completion:*' menu select - -# case insensitive (all), partial-word and substring completion -if [[ "$CASE_SENSITIVE" = true ]]; then - zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*' -else - if [[ "$HYPHEN_INSENSITIVE" = true ]]; then - zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*' - else - zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' - fi -fi -unset CASE_SENSITIVE HYPHEN_INSENSITIVE - -# Complete . and .. special directories -zstyle ':completion:*' special-dirs true - -zstyle ':completion:*' list-colors '' -zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' - -if [[ "$OSTYPE" = solaris* ]]; then - zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm" -else - zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w" -fi - -# disable named-directories autocompletion -zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories - -# Use caching so that commands like apt and dpkg complete are useable -zstyle ':completion:*' use-cache yes -zstyle ':completion:*' cache-path $ZSH_CACHE_DIR - -# Don't complete uninteresting users -zstyle ':completion:*:*:*:users' ignored-patterns \ - adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \ - clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \ - gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \ - ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \ - named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \ - operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \ - rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \ - usbmux uucp vcsa wwwrun xfs '_*' - -# ... unless we really want to. -zstyle '*' single-ignored show - -if [[ $COMPLETION_WAITING_DOTS = true ]]; then - expand-or-complete-with-dots() { - # toggle line-wrapping off and back on again - [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam - print -Pn "%{%F{red}......%f%}" - [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam - - zle expand-or-complete - zle redisplay - } - zle -N expand-or-complete-with-dots - bindkey "^I" expand-or-complete-with-dots -fi - -[ -s "/usr/share/zsh/site-functions/_pass" ] && zstyle ':completion:*' "/usr/share/zsh/site-functions/_pass" diff --git a/.config/zsh/completion b/.config/zsh/completion new file mode 120000 index 0000000..78e63d4 --- /dev/null +++ b/.config/zsh/completion @@ -0,0 +1 @@ +include/completion \ No newline at end of file diff --git a/.config/zsh/dotfiles b/.config/zsh/dotfiles deleted file mode 100644 index 494bd2f..0000000 --- a/.config/zsh/dotfiles +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/zsh - -export DOTFILES="" - -[ ! $DOTFILES ] && unset DOTFILES diff --git a/.config/zsh/dotfiles b/.config/zsh/dotfiles new file mode 120000 index 0000000..7091572 --- /dev/null +++ b/.config/zsh/dotfiles @@ -0,0 +1 @@ +include/dotfiles \ No newline at end of file diff --git a/.config/zsh/include/aliases b/.config/zsh/include/aliases new file mode 100644 index 0000000..a21b4d1 --- /dev/null +++ b/.config/zsh/include/aliases @@ -0,0 +1,136 @@ +#!/usr/bin/env bash + +if [[ "$OSTYPE" == "darwin"* ]]; then + # i need sudo to launch emulator + alias pixelemu="sudo $HOME/Library/Android/sdk/emulator/emulator @Pixel_2_API_28" + alias mbrew="sudo -H -u maintenance -g staff brew" +fi + +alias punten='doas' +#sudo + vim without sacrificing config +alias sudovim='sudoedit' +alias doasvim='doasedit' + +#switch to pgsql user +alias pg='doas -u postgres' + +#mysql with color +# alias mysql=$(echo -e 'mysql --prompt="\x1B[34m\\d\x1B[32m \n>\x1B[0m "') + +#vim +alias nano=nvim +alias vim=nvim +alias vimsudo='sudoedit /etc/sudoers' +alias vimdoas='doasedit /etc/sudoers' +alias vi=nvim +alias v=nvim + +#emacs +alias emacs="emacs -nw" + +#mutt +alias mutt="neomutt" + +#curl +alias weather='curl wttr.in' + +#install +alias p='doas pacman' +alias a='paru' + +#ripper +alias yt='yt-dlp --add-metadata' +alias yta='yt-dlp --add-metadata -x --audio-format' +alias xreload='xrdb $HOME/.config/Xresources' + +#clean up +alias wget='wget --hsts-file="$XDG_CACHE_HOME/wget-hsts"' + +#shortcuts +alias ytv='youtube-viewer' +alias gravit="$HOME/my\ Files/Gravit/GravitDesigner.AppImage" +alias redoom="$HOME/doom refresh" +alias rvim='doas vim' +alias py='python' +alias cls='clear' +alias classprop='xprop WM_CLASS' +alias storagelist='lsblk -f' +alias ..='cd ..' +alias ...='cd ../..' +alias ....='cd ../../..' +alias .....='cd ../../../..' +alias q='exit' + +#ls stuff +alias l='exa --color=always --group-directories-first' # my preferred listing +alias ls='exa --color=always --group-directories-first' # my preferred listing +alias la='exa -a --color=always --group-directories-first' # all files and dirs +alias ll='exa -l --color=always --group-directories-first' # long format +alias lla='exa -al --color=always --group-directories-first' # long format +alias lt='exa -aT --color=always --group-directories-first' # tree listing + +alias md='mkdir -p' +alias rd='rmdir' + +alias reUSD='rm -rf /tmp/rate.html /tmp/rateUSD.txt' +#alias mpv='mpv --geometry=1280x720' + +#config shortcuts +alias config='cd ${DOTFILES:-$HOME/Build/GIT/dotfiles}' +alias cfg='config' +alias cfvim='vim $XDG_CONFIG_HOME/nvim/init.lua' +alias cfvimplug='vim $XDG_CONFIG_HOME/nvim/lua/null/plugins/' +alias cfvimnix='vim $XDG_CONFIG_HOME/nvim/lua/null/nix.lua' +alias cfvimuni='vim $XDG_CONFIG_HOME/nvim/lua/null/config.lua' +alias cfbash='vim $HOME/.bashrc' +alias cfzsh='vim $XDG_CONFIG_HOME/zsh/.zshrc' +alias cfxres='vim $XDG_CONFIG_HOME/Xresources' +alias cfbsp='vim $XDG_CONFIG_HOME/bspwm/bspwmrc' +alias cfqtile='vim $XDG_CONFIG_HOME/qtile/config.py' +alias cfpoly='vim $XDG_CONFIG_HOME/polybar/config' +alias cfkeys='vim $XDG_CONFIG_HOME/sxhkd/sxhkdrc' +alias cfalias='vim $XDG_CONFIG_HOME/zsh/aliases' +alias cfbind='vim $XDG_CONFIG_HOME/zsh/keybinds' +alias cfprofile='vim $XDG_CONFIG_HOME/zsh/.zprofile' +alias cfxprofile='vim $XDG_CONFIG_HOME/xprofile' +alias cfcompt='vim $XDG_CONFIG_HOME/picom/picom.conf' +alias cfenv='vim $XDG_CONFIG_HOME/zsh/.zshenv' +alias cfmutt='vim $XDG_CONFIG_HOME/mutt/muttrc' +alias cfnews='vim $XDG_CONFIG_HOME/newsboat/urls' + +#more shortcuts +alias htop='htop -t' +alias rm='rm -i' +alias mv='mv -i' +alias cp='cp -i' +alias mntfd='doas mount -o gid=users,fmask=113,dmask=002' +alias umntfd='doas umount' +alias cmatrix='unimatrix -n -s 96 -l "o"' +alias s='cd $HOME/.local/bin/scripts;ls' + +#folder shortcut +alias cdclg='cd "$HOME/my Files/Kuliah/"' +alias cdwine='cd "$HOME/.local/share/wineprefixes/"' + +#Git Aliases +alias cdgit='cd $HOME/Build/GIT' +alias gaa='git add -A' +alias gci='git commit' +alias gca='git commit --all' +alias gr='git rm' +alias gR='git restore' +alias gs='git status' +alias gp='git push' +alias gP='git pull' +alias gcl='git clone' +#alias config='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME' + +alias qn='vim $HOME/Documents/QuickNote' + +alias docx2pdf='lowriter --convert-to pdf' + +alias mirror-update='curl -s "https://archlinux.org/mirrorlist/?country=ID&country=SG&country=US&protocol=https&use_mirror_status=on" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 5 -' +alias center-pfetch="printf '\n'; pfetch | sed '\$d' | center -l" +[ "$TERM" = "xterm-kitty" ] && alias ssh="kitty +kitten ssh" + +alias neofetch='fastfetch' diff --git a/.config/zsh/include/completion b/.config/zsh/include/completion new file mode 100644 index 0000000..9f42d1e --- /dev/null +++ b/.config/zsh/include/completion @@ -0,0 +1,76 @@ +# vim: filetype=zsh +zstyle ':completion:*:*:git:*' script /usr/local/etc/bash_completion.d/git-completion.bash +fpath=(/usr/local/share/zsh-completions $fpath) + +autoload -Uz compinit + +if [[ "$OSTYPE" == "darwin"* ]]; then + FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}" + compinit -u # homebrew moment, not recommended but whatever +else + compinit +fi + +zmodload -i zsh/complist +zstyle ':completion:*' menu select + +# case insensitive (all), partial-word and substring completion +if [[ "$CASE_SENSITIVE" = true ]]; then + zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*' +else + if [[ "$HYPHEN_INSENSITIVE" = true ]]; then + zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*' + else + zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' + fi +fi +unset CASE_SENSITIVE HYPHEN_INSENSITIVE + +# Complete . and .. special directories +zstyle ':completion:*' special-dirs true + +zstyle ':completion:*' list-colors '' +zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' + +if [[ "$OSTYPE" = solaris* ]]; then + zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm" +else + zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w" +fi + +# disable named-directories autocompletion +zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories + +# Use caching so that commands like apt and dpkg complete are useable +zstyle ':completion:*' use-cache yes +zstyle ':completion:*' cache-path $ZSH_CACHE_DIR + +# Don't complete uninteresting users +zstyle ':completion:*:*:*:users' ignored-patterns \ + adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \ + clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \ + gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \ + ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \ + named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \ + operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \ + rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \ + usbmux uucp vcsa wwwrun xfs '_*' + +# ... unless we really want to. +zstyle '*' single-ignored show + +if [[ $COMPLETION_WAITING_DOTS = true ]]; then + expand-or-complete-with-dots() { + # toggle line-wrapping off and back on again + [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam + print -Pn "%{%F{red}......%f%}" + [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam + + zle expand-or-complete + zle redisplay + } + zle -N expand-or-complete-with-dots + bindkey "^I" expand-or-complete-with-dots +fi + +[ -s "/usr/share/zsh/site-functions/_pass" ] && zstyle ':completion:*' "/usr/share/zsh/site-functions/_pass" diff --git a/.config/zsh/include/dotfiles b/.config/zsh/include/dotfiles new file mode 100644 index 0000000..494bd2f --- /dev/null +++ b/.config/zsh/include/dotfiles @@ -0,0 +1,5 @@ +#!/bin/zsh + +export DOTFILES="" + +[ ! $DOTFILES ] && unset DOTFILES diff --git a/.config/zsh/include/keybinds b/.config/zsh/include/keybinds new file mode 100644 index 0000000..77c2157 --- /dev/null +++ b/.config/zsh/include/keybinds @@ -0,0 +1,45 @@ +#!/bin/env zsh +# create a zkbd compatible hash; +# to add other keys to this hash, see: man 5 terminfo +typeset -g -A key + +key[Home]="${terminfo[khome]}" +key[End]="${terminfo[kend]}" +key[Insert]="${terminfo[kich1]}" +key[Backspace]="${terminfo[kbs]}" +key[Delete]="${terminfo[kdch1]}" +key[Up]="${terminfo[kcuu1]}" +key[Down]="${terminfo[kcud1]}" +key[Left]="${terminfo[kcub1]}" +key[Right]="${terminfo[kcuf1]}" +key[PageUp]="${terminfo[kpp]}" +key[PageDown]="${terminfo[knp]}" +key[Shift-Tab]="${terminfo[kcbt]}" + +# setup key accordingly +[[ -n "${key[Home]}" ]] && bindkey -- "${key[Home]}" beginning-of-line +[[ -n "${key[End]}" ]] && bindkey -- "${key[End]}" end-of-line +[[ -n "${key[Insert]}" ]] && bindkey -- "${key[Insert]}" overwrite-mode +[[ -n "${key[Backspace]}" ]] && bindkey -- "${key[Backspace]}" backward-delete-char +[[ -n "${key[Delete]}" ]] && bindkey -- "${key[Delete]}" delete-char +[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-history +[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-history +[[ -n "${key[Left]}" ]] && bindkey -- "${key[Left]}" backward-char +[[ -n "${key[Right]}" ]] && bindkey -- "${key[Right]}" forward-char +[[ -n "${key[PageUp]}" ]] && bindkey -- "${key[PageUp]}" beginning-of-buffer-or-history +[[ -n "${key[PageDown]}" ]] && bindkey -- "${key[PageDown]}" end-of-buffer-or-history +[[ -n "${key[Shift-Tab]}" ]] && bindkey -- "${key[Shift-Tab]}" reverse-menu-complete + +# Finally, make sure the terminal is in application mode, when zle is +# active. Only then are the values from $terminfo valid. +if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then + autoload -Uz add-zle-hook-widget + function zle_application_mode_start { echoti smkx } + function zle_application_mode_stop { echoti rmkx } + add-zle-hook-widget -Uz zle-line-init zle_application_mode_start + add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop +fi + +bindkey -v '^[[3~' delete-char +bindkey '^ ' autosuggest-accept + diff --git a/.config/zsh/include/theme b/.config/zsh/include/theme new file mode 100644 index 0000000..26e4a63 --- /dev/null +++ b/.config/zsh/include/theme @@ -0,0 +1,61 @@ +#!/bin/env zsh +autoload -Uz vcs_info +precmd_vcs_info() { vcs_info } +precmd_functions+=( precmd_vcs_info ) +setopt prompt_subst +zstyle ':vcs_info:*' stagedstr 'M' +zstyle ':vcs_info:*' unstagedstr '!' +zstyle ':vcs_info:*' check-for-changes true +zstyle ':vcs_info:git:*' formats '%F{5} %b %F{1}%c%u %f' +zstyle ':vcs_info:git*+set-message:*' hooks git-untracked +zstyle ':vcs_info:*' enable git ++vi-git-untracked() { + + # git status ahead + if [[ $(git status --porcelain -b | grep '^## [^ ]\+ .*ahead') ]]; then + hook_com[unstaged]+='%F{1}⇡%f' + fi + + # git untracked + if [ $(git rev-parse --is-inside-work-tree 2> /dev/null) = 'true' ] && \ + [ $(git ls-files --other --directory --exclude-standard | sed q | wc -l | tr -d ' ') = 1 ] ; then + hook_com[unstaged]+='%F{1}?%f' + fi +} + +function zle-line-init zle-keymap-select { + PS1=" +%B%F{blue}%~ \$vcs_info_msg_0_ +%F{green}${${KEYMAP/vicmd/N }/(main|viins)/}$>%f%b " + PS2="%B%F{blue}?>%f%b " + # RPS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}" + # RPS2=$RPS1 + + if [[ ${KEYMAP} == vicmd ]] || + [[ $1 = 'block' ]]; then + echo -ne '\e[1 q' + + elif [[ ${KEYMAP} == main ]] || + [[ ${KEYMAP} == viins ]] || + [[ ${KEYMAP} = '' ]] || + [[ $1 = 'beam' ]]; then + echo -ne '\e[5 q' + fi + + zle reset-prompt +} +zle -N zle-line-init +zle -N zle-keymap-select + +_fix_cursor() { + echo -ne '\e[5 q' +} + +precmd () { + RPROMPT="" # for some reason path added to RPROMPT in macOS, I have no idea where it's coming from + vcs_info + _fix_cursor +} +#RPROMPT=\$vcs_info_msg_0_ +ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#60C0FF,bold,underline" +ZSH_AUTOSUGGEST_HISTORY_IGNORE="ls *,cd *" diff --git a/.config/zsh/keybinds b/.config/zsh/keybinds deleted file mode 100644 index 77c2157..0000000 --- a/.config/zsh/keybinds +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/env zsh -# create a zkbd compatible hash; -# to add other keys to this hash, see: man 5 terminfo -typeset -g -A key - -key[Home]="${terminfo[khome]}" -key[End]="${terminfo[kend]}" -key[Insert]="${terminfo[kich1]}" -key[Backspace]="${terminfo[kbs]}" -key[Delete]="${terminfo[kdch1]}" -key[Up]="${terminfo[kcuu1]}" -key[Down]="${terminfo[kcud1]}" -key[Left]="${terminfo[kcub1]}" -key[Right]="${terminfo[kcuf1]}" -key[PageUp]="${terminfo[kpp]}" -key[PageDown]="${terminfo[knp]}" -key[Shift-Tab]="${terminfo[kcbt]}" - -# setup key accordingly -[[ -n "${key[Home]}" ]] && bindkey -- "${key[Home]}" beginning-of-line -[[ -n "${key[End]}" ]] && bindkey -- "${key[End]}" end-of-line -[[ -n "${key[Insert]}" ]] && bindkey -- "${key[Insert]}" overwrite-mode -[[ -n "${key[Backspace]}" ]] && bindkey -- "${key[Backspace]}" backward-delete-char -[[ -n "${key[Delete]}" ]] && bindkey -- "${key[Delete]}" delete-char -[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-history -[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-history -[[ -n "${key[Left]}" ]] && bindkey -- "${key[Left]}" backward-char -[[ -n "${key[Right]}" ]] && bindkey -- "${key[Right]}" forward-char -[[ -n "${key[PageUp]}" ]] && bindkey -- "${key[PageUp]}" beginning-of-buffer-or-history -[[ -n "${key[PageDown]}" ]] && bindkey -- "${key[PageDown]}" end-of-buffer-or-history -[[ -n "${key[Shift-Tab]}" ]] && bindkey -- "${key[Shift-Tab]}" reverse-menu-complete - -# Finally, make sure the terminal is in application mode, when zle is -# active. Only then are the values from $terminfo valid. -if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then - autoload -Uz add-zle-hook-widget - function zle_application_mode_start { echoti smkx } - function zle_application_mode_stop { echoti rmkx } - add-zle-hook-widget -Uz zle-line-init zle_application_mode_start - add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop -fi - -bindkey -v '^[[3~' delete-char -bindkey '^ ' autosuggest-accept - diff --git a/.config/zsh/keybinds b/.config/zsh/keybinds new file mode 120000 index 0000000..4b76640 --- /dev/null +++ b/.config/zsh/keybinds @@ -0,0 +1 @@ +include/keybinds \ No newline at end of file diff --git a/.config/zsh/theme b/.config/zsh/theme deleted file mode 100644 index 26e4a63..0000000 --- a/.config/zsh/theme +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/env zsh -autoload -Uz vcs_info -precmd_vcs_info() { vcs_info } -precmd_functions+=( precmd_vcs_info ) -setopt prompt_subst -zstyle ':vcs_info:*' stagedstr 'M' -zstyle ':vcs_info:*' unstagedstr '!' -zstyle ':vcs_info:*' check-for-changes true -zstyle ':vcs_info:git:*' formats '%F{5} %b %F{1}%c%u %f' -zstyle ':vcs_info:git*+set-message:*' hooks git-untracked -zstyle ':vcs_info:*' enable git -+vi-git-untracked() { - - # git status ahead - if [[ $(git status --porcelain -b | grep '^## [^ ]\+ .*ahead') ]]; then - hook_com[unstaged]+='%F{1}⇡%f' - fi - - # git untracked - if [ $(git rev-parse --is-inside-work-tree 2> /dev/null) = 'true' ] && \ - [ $(git ls-files --other --directory --exclude-standard | sed q | wc -l | tr -d ' ') = 1 ] ; then - hook_com[unstaged]+='%F{1}?%f' - fi -} - -function zle-line-init zle-keymap-select { - PS1=" -%B%F{blue}%~ \$vcs_info_msg_0_ -%F{green}${${KEYMAP/vicmd/N }/(main|viins)/}$>%f%b " - PS2="%B%F{blue}?>%f%b " - # RPS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}" - # RPS2=$RPS1 - - if [[ ${KEYMAP} == vicmd ]] || - [[ $1 = 'block' ]]; then - echo -ne '\e[1 q' - - elif [[ ${KEYMAP} == main ]] || - [[ ${KEYMAP} == viins ]] || - [[ ${KEYMAP} = '' ]] || - [[ $1 = 'beam' ]]; then - echo -ne '\e[5 q' - fi - - zle reset-prompt -} -zle -N zle-line-init -zle -N zle-keymap-select - -_fix_cursor() { - echo -ne '\e[5 q' -} - -precmd () { - RPROMPT="" # for some reason path added to RPROMPT in macOS, I have no idea where it's coming from - vcs_info - _fix_cursor -} -#RPROMPT=\$vcs_info_msg_0_ -ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#60C0FF,bold,underline" -ZSH_AUTOSUGGEST_HISTORY_IGNORE="ls *,cd *" diff --git a/.config/zsh/theme b/.config/zsh/theme new file mode 120000 index 0000000..6696fdf --- /dev/null +++ b/.config/zsh/theme @@ -0,0 +1 @@ +include/theme \ No newline at end of file diff --git a/.gitignore b/.gitignore index e14dfc5..7ed3bcf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ -.config/discordcanary +.config/discordcanary/** !.config/discordcanary/settings.json -.config/zsh/ + +.config/zsh/** !.config/zsh/.zprofile !.config/zsh/.zshenv !.config/zsh/.zshrc @@ -9,3 +10,5 @@ !.config/zsh/dotfiles !.config/zsh/keybinds !.config/zsh/theme +!.config/zsh/include/ +!.config/zsh/include/**