From e58497ec557d6228cb6c7eb5ed90e4b4415adedc Mon Sep 17 00:00:00 2001 From: Bartek Stalewski Date: Wed, 3 May 2023 01:34:27 +0200 Subject: [PATCH] Switch to proper if statements. --- zsh/.zshrc | 28 ++++++++++++++++++++++------ zsh/aliases.zsh | 24 +++++++++++++++++++----- zsh/fzf.zsh | 2 +- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/zsh/.zshrc b/zsh/.zshrc index f1d5339..00e7c91 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -1,5 +1,9 @@ # prepare directories -[ ! -L ~/.cache ] && { rm -rf ~/.cache; mkdir -p $XDG_CACHE_HOME; ln -sf $XDG_CACHE_HOME ~/.cache ; } +if [[ ! -L ~/.cache ]]; then + rm -rf ~/.cache + mkdir -p $XDG_CACHE_HOME + ln -sf $XDG_CACHE_HOME ~/.cache +fi mkdir -p $XDG_DATA_HOME/zsh mkdir -p $XDG_CACHE_HOME/zsh @@ -13,7 +17,9 @@ setopt HIST_REDUCE_BLANKS setopt SHARE_HISTORY setopt INC_APPEND_HISTORY -[ -z $DISPLAY ] && export PATH=~/.local/bin:$PATH +if [[ -z $DISPLAY ]]; then + export PATH=~/.local/bin:$PATH +fi # source configuration source $ZDOTDIR/aliases.zsh @@ -34,7 +40,11 @@ source $XDG_DATA_HOME/repos/zsh_modules/powerlevel10k/powerlevel10k.zsh-theme if [[ -r "$XDG_CACHE_HOME/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then source "$XDG_CACHE_HOME/p10k-instant-prompt-${(%):-%n}.zsh" fi -[ $(command -v vivid) ] && export LS_COLORS=$(vivid generate molokai) || unset LS_COLORS +if [[ $(command -v vivid) ]]; then + export LS_COLORS=$(vivid generate molokai) +else + unset LS_COLORS +fi tabs 2 # completion @@ -42,7 +52,10 @@ zstyle ':completion:*' menu select zstyle ':completion:*' list-colors '' autoload -Uz compinit -[ ! -e $XDG_DATA_HOME/zsh/zcompdump.zwc ] && autoload -Uz zrecompile && zrecompile -p -R $XDG_DATA_HOME/zsh/zcompdump +if [ ! -e $XDG_DATA_HOME/zsh/zcompdump.zwc ]; then + autoload -Uz zrecompile + zrecompile -p -R $XDG_DATA_HOME/zsh/zcompdump +fi if [[ -n $XDG_DATA_HOME/zsh/zcompdump(#qN.mh+24) ]]; then compinit -d $XDG_DATA_HOME/zsh/zcompdump else @@ -50,11 +63,14 @@ else fi # quick note functionality -if [ -f ~/.note ]; then +if [[ -f ~/.note ]]; then echo cat ~/.note echo fi # local settings -[ -f ~/.local/config/zsh ] && source ~/.local/config/zsh +if [[ -f ~/.local/config/zsh ]]; then + source ~/.local/config/zsh +fi + diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh index be018e3..4370976 100644 --- a/zsh/aliases.zsh +++ b/zsh/aliases.zsh @@ -3,8 +3,11 @@ alias gae='git add .; git commit --amend; git push --force-with-lease' alias less='less -R' alias startx='xinit ~/.config/xinitrc -- /etc/X11/xinit/xserverrc :0 -ardelay 280 -arinterval 30' -[ $(command -v bat) ] && alias cat='bat -pp --color=always --tabs=2 --theme=Monokai\ Extended\ Bright' -if [ $(command -v exa) ]; then +if [[ $(command -v bat) ]]; then + alias cat='bat -pp --color=always --tabs=2 --theme=Monokai\ Extended\ Bright' +fi + +if [[ $(command -v exa) ]]; then alias ls='exa --group-directories-first' alias ll='ls -l --git --octal-permissions --no-permissions' else @@ -14,9 +17,15 @@ else esac alias ll='ls -l' fi -if [ $(command -v fd) ]; then - [ -f ~/.local/config/fd ] && alias fd='fd -H -L --ignore-file ~/.local/config/fd' || alias fd='fd -H -L' + +if [[ $(command -v fd) ]]; then + if [[ -f ~/.local/config/fd ]]; then + alias fd='fd -H -L --ignore-file ~/.local/config/fd' + else + alias fd='fd -H -L' + fi fi + if [ $(command -v nvim) ]; then export EDITOR=nvim export MANPAGER="nvim +Man!" @@ -27,7 +36,12 @@ elif [ $(command -v vim) ] ; then else export EDITOR=vi fi -[ $(command -v rg) ] && alias grep='rg -i' || alias grep='grep --color' + +if [[ $(command -v rg) ]]; then + alias grep='rg -i' +else + alias grep='grep --color' +fi function ud() { wd dots && git pull diff --git a/zsh/fzf.zsh b/zsh/fzf.zsh index b872c43..26a1814 100644 --- a/zsh/fzf.zsh +++ b/zsh/fzf.zsh @@ -1,4 +1,4 @@ -if [ $(command -v fzf) ]; then +if [[ $(command -v fzf) ]]; then case $(lsb_release -i | awk '{print $3}') in Gentoo) source /usr/share/zsh/site-functions/_fzf ;; VoidLinux) source /usr/share/fzf/completion.zsh ;;