From a9320954f772b6e485dbdaa5e487fa63c97be451 Mon Sep 17 00:00:00 2001 From: the_4n0nym0u53 Date: Thu, 23 Dec 2021 00:55:07 +0100 Subject: [PATCH] Add Zsh config to the dotfiles repo :sunglasses: --- README.md | 5 +++-- install.sh | 24 ++++++++++++-------- zsh/.config/zsh/.aliases.zsh | 25 +++++++++++++++++++++ zsh/.config/zsh/.completion.zsh | 8 +++++++ zsh/.config/zsh/.gpg.zsh | 5 +++++ zsh/.config/zsh/.history.zsh | 16 ++++++++++++++ zsh/.config/zsh/.zlogout | 7 ++++++ zsh/.config/zsh/.zprofile | 9 ++++++++ zsh/.config/zsh/.zshenv | 11 ++++++++++ zsh/.config/zsh/.zshrc | 39 +++++++++++++++++++++++++++++++++ zsh/.zshenv | 2 ++ 11 files changed, 140 insertions(+), 11 deletions(-) create mode 100644 zsh/.config/zsh/.aliases.zsh create mode 100644 zsh/.config/zsh/.completion.zsh create mode 100644 zsh/.config/zsh/.gpg.zsh create mode 100644 zsh/.config/zsh/.history.zsh create mode 100644 zsh/.config/zsh/.zlogout create mode 100644 zsh/.config/zsh/.zprofile create mode 100644 zsh/.config/zsh/.zshenv create mode 100644 zsh/.config/zsh/.zshrc create mode 100644 zsh/.zshenv diff --git a/README.md b/README.md index 73f2f27..033fd83 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,9 @@ This configuration depends on the following packages: - `waybar` - `wireplumber` - `wl-clipboard` +- `zsh` -\* If you prefer `sudo`, then change all instances of `doas` to `sudo`. They're mainly in the sway config file and in my `autostart.sh` script. +\* If you prefer `sudo`, then change all instances of `doas` to `sudo`. -Also, you need to make a `doas`/`sudo` rule that allows you to execute `ivpn-service`, `poweroff` and `reboot` without a password, otherwise the keybindings for those won't work. +Also, you need to make `doas`/`sudo` rules that allow you to execute `ivpn-service`, `poweroff`, `reboot` and `pkill ivpn-service` without a password, otherwise the keybindings and scripts for those won't work. diff --git a/install.sh b/install.sh index 3c640d7..2a053c1 100755 --- a/install.sh +++ b/install.sh @@ -1,23 +1,29 @@ #!/bin/sh +echo -e "Configuring directories..." +mkdir -p $HOME/.config/zsh # Symlink only the individual files instead of the entire directory +DOTDIR=$(cd -- "$(dirname -- $0)" &> /dev/null && pwd) + +sleep 0.5 echo -e "Creating the symlinks with stow..." -stow -t $HOME alacritty \ +stow -d $DOTDIR -t $HOME alacritty \ mako \ nvim \ scripts \ sway \ swaylock \ - waybar + waybar \ + zsh -sleep 1 +sleep 0.5 echo -e "Making scripts executable..." -chmod +x scripts/.local/bin/clear-clipboard.sh -chmod +x sway/.config/sway/autostart.sh -chmod +x waybar/.config/waybar/ivpn-status.sh -chmod +x waybar/.config/waybar/ivpn-reconnect.sh -chmod +x waybar/.config/waybar/mediaplayer.py +chmod +x $DOTDIR/scripts/.local/bin/clear-clipboard.sh +chmod +x $DOTDIR/sway/.config/sway/autostart.sh +chmod +x $DOTDIR/waybar/.config/waybar/ivpn-status.sh +chmod +x $DOTDIR/waybar/.config/waybar/ivpn-reconnect.sh +chmod +x $DOTDIR/waybar/.config/waybar/mediaplayer.py -sleep 1 +sleep 0.5 echo -e "Done!" diff --git a/zsh/.config/zsh/.aliases.zsh b/zsh/.config/zsh/.aliases.zsh new file mode 100644 index 0000000..25798e0 --- /dev/null +++ b/zsh/.config/zsh/.aliases.zsh @@ -0,0 +1,25 @@ +# Shortcuts +alias btctl="bluetoothctl" +alias code="codium --enable-features=UseOzonePlatform --ozone-platform=wayland" +alias cl="clear" +alias exa="exa -aFghl --git --icons" +alias l="lsd -hlA" +alias la="lsd -hl" +alias ll="lsd -hlaF" +alias q="exit" +alias tree="exa --tree -I '.git'" +alias u="paru; echo; doas npm update -g" + +# File management +alias cp="cp -iv" +alias mkdir="mkdir -pv" +alias mv="mv -iv" +alias rm="rm -iv" +alias srm="srm -iv" + +# Passwordless doas +alias poweroff="doas poweroff" +alias reboot="doas reboot" + +# sudoedit for doas (hacky solution) +alias doasedit="doas -L; doas sh -c '$EDITOR /etc/doas.conf; doas -C /etc/doas.conf && echo ok || echo error'; doas -L" diff --git a/zsh/.config/zsh/.completion.zsh b/zsh/.config/zsh/.completion.zsh new file mode 100644 index 0000000..e868054 --- /dev/null +++ b/zsh/.config/zsh/.completion.zsh @@ -0,0 +1,8 @@ +# Load the completion system +autoload -Uz compinit && compinit + +# Case insensitive completion for lowercase +zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' + +# Highlighted tab selection +zstyle ':completion:*' menu yes select diff --git a/zsh/.config/zsh/.gpg.zsh b/zsh/.config/zsh/.gpg.zsh new file mode 100644 index 0000000..bcf13e9 --- /dev/null +++ b/zsh/.config/zsh/.gpg.zsh @@ -0,0 +1,5 @@ +# Configuration for gpg-agent, used with YubiKey and ssh +export GPG_TTY=$TTY +export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) +gpgconf --launch gpg-agent +gpg-connect-agent updatestartuptty /bye > /dev/null 2>&1 diff --git a/zsh/.config/zsh/.history.zsh b/zsh/.config/zsh/.history.zsh new file mode 100644 index 0000000..031e108 --- /dev/null +++ b/zsh/.config/zsh/.history.zsh @@ -0,0 +1,16 @@ +# History file configuration +HISTFILE="$ZDOTDIR/.zsh_history" +HISTSIZE=50000 +SAVEHIST=10000 + +# History command configuration +setopt EXTENDED_HISTORY +setopt HIST_EXPIRE_DUPS_FIRST +setopt HIST_IGNORE_ALL_DUPS +setopt HIST_IGNORE_DUPS +setopt HIST_IGNORE_SPACE +setopt HIST_NO_STORE +setopt HIST_REDUCE_BLANKS +setopt HIST_REDUCE_BLANKS +setopt HIST_VERIFY +setopt SHARE_HISTORY diff --git a/zsh/.config/zsh/.zlogout b/zsh/.config/zsh/.zlogout new file mode 100644 index 0000000..054fcc6 --- /dev/null +++ b/zsh/.config/zsh/.zlogout @@ -0,0 +1,7 @@ +ivpn disconnect +doas pkill ivpn-service + +pkill mako +pkill pipewire +pkill pipewire-pulse +pkill wireplumber diff --git a/zsh/.config/zsh/.zprofile b/zsh/.config/zsh/.zprofile new file mode 100644 index 0000000..7d4bcec --- /dev/null +++ b/zsh/.config/zsh/.zprofile @@ -0,0 +1,9 @@ +if [ "$(tty)" = "/dev/tty1" ]; then + export $(gnome-keyring-daemon --start) + export XDG_CURRENT_DESKTOP=Unity + export GTK_USE_PORTAL=1 + export QT_QPA_PLATFORM=wayland + exec dbus-launch --sh-syntax --exit-with-session sway &> /dev/null +else + neofetch +fi diff --git a/zsh/.config/zsh/.zshenv b/zsh/.config/zsh/.zshenv new file mode 100644 index 0000000..159bc41 --- /dev/null +++ b/zsh/.config/zsh/.zshenv @@ -0,0 +1,11 @@ +# PATH +export PATH="$PATH:$HOME/bin:$HOME/.local/bin" +command -v go > /dev/null 2>&1 && export PATH="$PATH:$(go env GOPATH)" + +# Essentials +export LANG="en_DK.UTF-8" +export EDITOR="nvim" +export PAGER="more" + +# Secret variables +[[ -f $HOME/.config/zsh/.env ]] && source $HOME/.config/zsh/.env diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc new file mode 100644 index 0000000..ecaba2a --- /dev/null +++ b/zsh/.config/zsh/.zshrc @@ -0,0 +1,39 @@ +# Enable p10k instant prompt +[[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]] && + source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" + +# Some variables +PZ_PLUGIN_HOME="$ZDOTDIR/plugins" +ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern regexp root line) + +# Load the .zsh files +for file in $ZDOTDIR/.*.zsh; do + [[ -L $file ]] && source $file +done + +# Initialize PZ +[[ -d $PZ_PLUGIN_HOME/pz ]] || + git clone https://github.com/mattmc3/pz.git $PZ_PLUGIN_HOME/pz +source $PZ_PLUGIN_HOME/pz/pz.zsh + +# Set p10k prompt +pz prompt romkatv/powerlevel10k + +# Source regular plugins +pz source zsh-users/zsh-autosuggestions +pz source zsh-users/zsh-completions + +# Source OMZ libs +pz source ohmyzsh/ohmyzsh lib/git +pz source ohmyzsh/ohmyzsh lib/key-bindings + +# Source OMZ plugins +pz source ohmyzsh/ohmyzsh plugins/extract +pz source ohmyzsh/ohmyzsh plugins/fzf +pz source ohmyzsh/ohmyzsh plugins/git + +# Always source syntax highlighting plugin last +pz source zsh-users/zsh-syntax-highlighting + +# Load p10k configuration +[[ -f $ZDOTDIR/.p10k.zsh ]] && source $ZDOTDIR/.p10k.zsh diff --git a/zsh/.zshenv b/zsh/.zshenv new file mode 100644 index 0000000..e831684 --- /dev/null +++ b/zsh/.zshenv @@ -0,0 +1,2 @@ +ZDOTDIR="$HOME/.config/zsh" +source $ZDOTDIR/.zshenv