diff options
Diffstat (limited to '.config/zsh')
-rw-r--r-- | .config/zsh/.zshrc | 64 | ||||
-rw-r--r-- | .config/zsh/command-tools.zsh | 2 | ||||
-rw-r--r-- | .config/zsh/zprofile | 9 |
3 files changed, 41 insertions, 34 deletions
diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 22bf62f..d3ba554 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -6,9 +6,13 @@ bindkey -e alias find="2> >(grep -v 'Permission denied' >&2) find" source ~/.profile + [ -n "$SDOTDIR" ] || SDOTDIR="${XDG_CONFIG_HOME:-$HOME/.config}/shell" [ -n "$ZDOTDIR" ] || ZDOTDIR="${XDG_CONFIG_HOME:-HOME/.config}/zsh" -source "/usr/share/fzf/completion.zsh" +[ -n "$CD_HISTFILE" ] || CD_HISTFILE="${XDG_STATE_HOME:-$HOME/.local/state}/cd_history" +[ -n "$OPEN_HISTFILE" ] || OPEN_HISTFILE="${XDG_STATE_HOME:-$HOME/.local/state}/open_history" + +source "${PREFIX:-/usr}/share/fzf/completion.zsh" source "$ZDOTDIR/command-tools.zsh" source "$ZDOTDIR/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" @@ -52,7 +56,7 @@ preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt. # Completion. autoload -Uz compinit compinit -d ~/.cache/zshcompdump-$ZSH_VERSION -zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # Case insensitive tab completion +zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' # Case insensitive tab completion zstyle ':completion:*' rehash true # automatically find new executables in path zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" # Colored completion (different colors for dirs/files/etc) zstyle ':completion:*' completer _expand _complete _ignored _approximate @@ -67,7 +71,9 @@ zstyle ':completion:*' cache-path ~/.cache/zsh # automatically load bash completion functions autoload -U +X bashcompinit && bashcompinit -source "$ZDOTDIR/completion/arduino-cli.zsh" + +unset WORDCHARS +stty -ixon ZSH_AUTOSUGGEST_STRATEGY=(history completion) ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=(end-of-line vi-end-of-line vi-add-eol) @@ -77,14 +83,7 @@ HISTFILE="${XDG_STATE_HOME:=$HOME/.local/state}/zsh/history" HISTSIZE=100000 SAVEHIST=50000 -unset WORDCHARS -stty -ixon - -[ -z "$CD_HISTFILE" ] && - export CD_HISTFILE="${XDG_STATE_HOME:-$HOME/.local/state}/cd_history" - -[ -z "$OPEN_HISTFILE" ] && - export OPEN_HISTFILE="${XDG_STATE_HOME:-$HOME/.local/state}/open_history" +# source "$ZDOTDIR/completion/arduino-cli.zsh" # Angular # _ng_yargs_completions() @@ -99,12 +98,20 @@ stty -ixon # compdef _ng_yargs_completions ng +[ -n "$DISPLAY" ] && command -V xdotool >/dev/null && { + TERMINAL_WINDOW_ID="$(xdotool getactivewindow)" + function set_win_title() { + echo -ne "\033]0; $USER@$HOST:${PWD/$HOME/~} \007" + } + precmd_functions+=(set_win_title) +} + _command_fail_hook() { [ $? = 1 ] || return if [ -n "$TMUX" ]; then tmux send-keys C-p - elif [ -n "$XDOTOOL_WINDOW_ID" ]; then - xdotool key --window "$XDOTOOL_WINDOW_ID" ctrl+p + elif [ -n "$TERMINAL_WINDOW_ID" ]; then + xdotool key --window "$TERMINAL_WINDOW_ID" ctrl+p fi } add-zsh-hook precmd _command_fail_hook @@ -150,21 +157,18 @@ if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then fi -[ -n "$DISPLAY" ] && command -V xdotool >/dev/null && - XDOTOOL_WINDOW_ID="$(xdotool getactivewindow)" - [ -f "$BUFFER_CACHE" ] && { { if [ -n "$TMUX" ]; then tmux send-keys -l "$(cat "$BUFFER_CACHE")" elif [ -z "$TERMUX_VERSION" ]; then - xdotool type --window "$XDOTOOL_WINDOW_ID" "$(cat "$BUFFER_CACHE")" + xdotool type --window "$TERMINAL_WINDOW_ID" "$(cat "$BUFFER_CACHE")" fi rm -f "$BUFFER_CACHE" } & disown } -BUFFER_CACHE="${ZCACHEDIR:=$HOME/.cache/zsh}/previous-command-buffer-$$.tmp" +export BUFFER_CACHE="${ZCACHEDIR:=$HOME/.cache/zsh}/previous-command-buffer-$$.tmp" _exec-zsh() { echo "$BUFFER" > "$BUFFER_CACHE" BUFFER=' exec zsh' @@ -248,6 +252,7 @@ bindkey '^[H' get-help [ -f "$SDOTDIR/aliasrc" ] && source "$SDOTDIR/aliasrc" [ -f "$SDOTDIR/shortcutrc" ] && source "$SDOTDIR/shortcutrc" +[ -f "$SDOTDIR/shortcutenvrc" ] && source "$SDOTDIR/shortcutenvrc" [ -f "$ZDOTDIR/zshnameddirrc" ] && source "$ZDOTDIR/zshnameddirrc" @@ -263,30 +268,25 @@ case "$TERM" in *256*) } command -v fd >/dev/null && { - FZF_DEFAULT_COMMAND="fd --hidden --no-ignore-vcs --color=always | sort" + FZF_DEFAULT_COMMAND="fd --hidden --color=always" FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --ansi" - ff() { FZF_DEFAULT_COMMAND+="$@" fzf -m; } alias f='fd --hidden --no-ignore-vcs' alias sr='fd --no-ignore-vcs --color=always . ~/.config ~/.local/bin ~/bin | fzf --ansi' } command -v starship >/dev/null && { eval "$(starship init zsh)" - function set_win_title() { - echo -ne "\033]0; $USER@$HOST:${PWD/$HOME/~} \007" - } - precmd_functions+=(set_win_title) } ;; esac +alias s='sudo ' alias p='pacman' alias sp='sudo pacman' alias sv='sudo sv' +alias pm='PASSWORD_STORE_DIR=$CUSTOM_PASSWORD_STORE pass' alias mmv='noglob zmv -W' -alias s='sudo ' -alias fh='fzf --tac < "$OPEN_HISTFILE"' -alias ide='nvim -u "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/dev.vim"' +alias ide='nvim -u "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/coc.vim"' alias mirror='sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist-arch' alias mirrord='sudo reflector --latest 50 --number 20 --sort delay --save /etc/pacman.d/mirrorlist-arch' alias cleanup='sudo pacman -Rns $(pacman -Qtdq)' @@ -294,14 +294,18 @@ alias fixpacman='sudo rm /var/lib/pacman/db.lck' alias gtypist="gtypist $GTYPIST_OPTS" alias typ='launch-gtypist -l "$(sed "/^gtypist lesson - \(.*\)$/!d; s//\1/" ~/Documents/Notes/QuickNote.md)"' alias typa='launch-gtypist -e 3 -l "$(sed "/^gtypist lesson - \(.*\)$/!d; s//\1/" ~/Documents/Notes/ak47.txt)"' +alias uc='cd ~ && gitpush' # update config +alias gpu='gitpush' +alias wtr='less -r /tmp/wttr.in' # Launch new (W)indow in background -W() { +new_window() { windowid="$(xdotool getactivewindow)" - setsid -f $TERMINAL >/dev/null 2>&1 + setsid -f $TERMINAL -e sh -c "${*:-$SHELL}" >/dev/null 2>&1 while [ "$(xdotool getactivewindow)" = "$windowid" ]; do sleep 0.1; done xdotool windowfocus "$windowid" } +alias W='new_window ' # Find command package F() { @@ -328,5 +332,5 @@ pyenvs() { } # Load syntax highlighter; should be last. -source "/home/master/.config/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh" +source "$ZDOTDIR/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" diff --git a/.config/zsh/command-tools.zsh b/.config/zsh/command-tools.zsh index 20126cb..fe17ed1 100644 --- a/.config/zsh/command-tools.zsh +++ b/.config/zsh/command-tools.zsh @@ -1,5 +1,5 @@ whereis_alias() { - location="$(zsh -xic exit 2>&1 | sed -E "/alias[ '$]*$1=/!d" | + location="$(zsh -xic exit 2>&1 | sed -E "/sh.*alias[ '$]*$1=/!d; /\/plugins\//d" | fzf --exit-0 --select-1 --ansi --header-first --header='Select alias location' | sed -n "s|^\+\(/.*:[0-9]*\)>.*$|\1|p")" diff --git a/.config/zsh/zprofile b/.config/zsh/zprofile index 16b64c6..3a9242f 100644 --- a/.config/zsh/zprofile +++ b/.config/zsh/zprofile @@ -1,17 +1,20 @@ #!/bin/zsh + . ~/.profile -[ -n "$TMUX" ] || [ -n "$TERMUX_VERSION" ] || [ "$SSH_CONNECTION" ] && +[ -n "$TMUX" ] || [ -n "$TERMUX_VERSION" ] || [ -n "$SSH_CONNECTION" ] && return on_ac_power="$(cat /sys/class/power_supply/ACAD/online)" -[ "$on_ac_power" = 0 ] && brightnessctl set 5% || brightnessctl set 20% +[ "$on_ac_power" = 0 ] && + brightnessctl set 5% || + brightnessctl set "$(<"${XDG_STATE_HOME:-$HOME/.local/state}/brightness")" case "$TTY" in /dev/tty1) command -V optimus-manager >/dev/null && [ "$on_ac_power" = 1 ] && { echo "Waiting for nvidia card to load up..." - until [ -e /dev/dri/card1 ]; do; sleep 0.1; done + until [ -e /dev/dri/card1 ]; do sleep 0.1; done } command -V startx >/dev/null && { pgrep startx || startx } ;; |