Auto dark/light mode switching, fix Mason

This commit is contained in:
Bartek Stalewski 2024-09-26 02:21:11 +02:00
parent 0d1e6f2967
commit 4d516d6b9d
No known key found for this signature in database
7 changed files with 58 additions and 23 deletions

View file

@ -6,3 +6,4 @@ export XDG_STATE_HOME=$HOME/.local/state
export HISTFILE=$XDG_DATA_HOME/zsh/history
export HISTSIZE=10000
export SAVEHIST=$HISTSIZE
source $ZDOTDIR/settheme.zsh

View file

@ -1,4 +1,4 @@
# mac specific configuration
# macOS specific
if [[ $(uname -s) = "Darwin" ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
@ -36,7 +36,11 @@ fpath=(~/.local/git/zsh_modules/wd $fpath)
# theme and colors
if [[ $(command -v vivid) ]]; then
export LS_COLORS=$(vivid generate molokai)
if [[ "${macos_interface_style}" = "Dark" ]]; then
export LS_COLORS=$(vivid generate molokai)
else
export LS_COLORS=$(vivid generate ayu)
fi
else
unset LS_COLORS
fi

View file

@ -12,7 +12,11 @@ gd() {
alias less='less -R'
if [[ $(command -v bat) ]]; then
alias cat='bat -pp --color=always --tabs=2 --theme=Monokai\ Extended\ Bright'
if [[ "${macos_interface_style}" = "Dark" ]]; then
alias cat='bat -pp --color=always --tabs=2 --theme=Monokai\ Extended\ Bright'
else
alias cat='bat -pp --color=always --tabs=2 --theme=Monokai\ Extended\ Light'
fi
fi
if [[ $(command -v eza) ]]; then
@ -44,9 +48,6 @@ elif [ $(command -v vim) ] ; then
else
export EDITOR=vi
fi
if [ $(command -v zed) ] && [ $(id -u) -ne 0 ]; then
alias vim=zed
fi
if [[ $(command -v rg) ]]; then
alias grep='rg -i'

View file

@ -2,8 +2,19 @@ if [[ $(command -v fzf) ]]; then
source <(fzf --zsh)
export FZF_DEFAULT_COMMAND='fd -H -L --ignore-file ~/.local/config/fd'
export FZF_CTRL_T_COMMAND='fd -H -L --ignore-file ~/.local/config/fd'
export FZF_DEFAULT_OPTS="--multi -e --ansi --layout=reverse --preview='bat --color=always --tabs=2 --style=plain --theme=Monokai\ Extended\ Bright {}'"
export FZF_CTRL_R_OPTS="-e --ansi --layout=reverse --preview=''"
if [[ $macos_interface_style = "Light" ]]; then
FZF_COLORS='
--color=fg:#5C6166,fg+:#FCFCFC,bg:#FCFCFC,bg+:#5C6166
--color=hl:#4196df,hl+:#6daee6,info:#eba54d,marker:#80ab24
--color=prompt:#e7666a,spinner:#9870c3,pointer:#b294d2,header:#51b891
--color=border:#5C6166,label:#e7666a,query:#5C6166
--border="rounded" --border-label="" --preview-window="border-rounded" --prompt="> "
--marker=">" --pointer="◆" --separator="─" --scrollbar="│"'
else
FZF_COLORS=""
fi
export FZF_DEFAULT_OPTS=$FZF_COLORS" --multi -e --ansi --layout=reverse --preview='bat --color=always --tabs=2 --style=plain --theme=Monokai\ Extended\ Light {}'"
export FZF_CTRL_R_OPTS=$FZF_COLORS" -e --ansi --layout=reverse --preview=''"
_fzf_compgen_path() {
fd -H -L --ignore-file ~/.local/config/fd . "$1"
}

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

@ -0,0 +1,7 @@
if [[ $(uname -s) = "Darwin" ]]; then
if defaults read -g AppleInterfaceStyle > /dev/null 2>&1; then
export macos_interface_style=Dark
else
export macos_interface_style=Light
fi
fi