Add Zsh config to the dotfiles repo 😎

This commit is contained in:
the_4n0nym0u53 2021-12-23 00:55:07 +01:00
parent 3f0f59bdb2
commit a9320954f7
No known key found for this signature in database
GPG key ID: 35EE09F5481049BB
11 changed files with 140 additions and 11 deletions

View file

@ -34,8 +34,9 @@ This configuration depends on the following packages:
- `waybar` - `waybar`
- `wireplumber` - `wireplumber`
- `wl-clipboard` - `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.

View file

@ -1,23 +1,29 @@
#!/bin/sh #!/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..." echo -e "Creating the symlinks with stow..."
stow -t $HOME alacritty \ stow -d $DOTDIR -t $HOME alacritty \
mako \ mako \
nvim \ nvim \
scripts \ scripts \
sway \ sway \
swaylock \ swaylock \
waybar waybar \
zsh
sleep 1 sleep 0.5
echo -e "Making scripts executable..." echo -e "Making scripts executable..."
chmod +x scripts/.local/bin/clear-clipboard.sh chmod +x $DOTDIR/scripts/.local/bin/clear-clipboard.sh
chmod +x sway/.config/sway/autostart.sh chmod +x $DOTDIR/sway/.config/sway/autostart.sh
chmod +x waybar/.config/waybar/ivpn-status.sh chmod +x $DOTDIR/waybar/.config/waybar/ivpn-status.sh
chmod +x waybar/.config/waybar/ivpn-reconnect.sh chmod +x $DOTDIR/waybar/.config/waybar/ivpn-reconnect.sh
chmod +x waybar/.config/waybar/mediaplayer.py chmod +x $DOTDIR/waybar/.config/waybar/mediaplayer.py
sleep 1 sleep 0.5
echo -e "Done!" echo -e "Done!"

View file

@ -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"

View file

@ -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

5
zsh/.config/zsh/.gpg.zsh Normal file
View file

@ -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

View file

@ -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

7
zsh/.config/zsh/.zlogout Normal file
View file

@ -0,0 +1,7 @@
ivpn disconnect
doas pkill ivpn-service
pkill mako
pkill pipewire
pkill pipewire-pulse
pkill wireplumber

View file

@ -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

11
zsh/.config/zsh/.zshenv Normal file
View file

@ -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

39
zsh/.config/zsh/.zshrc Normal file
View file

@ -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

2
zsh/.zshenv Normal file
View file

@ -0,0 +1,2 @@
ZDOTDIR="$HOME/.config/zsh"
source $ZDOTDIR/.zshenv