Fix ZSH configuration for WSL

This commit is contained in:
Fabio Scotto di Santolo
2025-07-31 10:47:20 +02:00
parent ba96824387
commit 2326e2e92d
15 changed files with 42 additions and 157 deletions

View File

@@ -1,3 +0,0 @@
#/usr/bin/env bash
export DOTFILES="$HOME/.dotfiles"

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env bash
export EDITOR=vim

View File

@@ -1,38 +0,0 @@
#!/usr/bin/env bash
is_debian_based() {
# Checking /etc/os-release
if [[ -f /etc/os-release ]]; then
. /etc/os-release
if [[ "$ID_LIKE" == *"debian"* ]] || [[ "$ID" == "debian" ]]; then
return 0 # OK: Debian-based
fi
fi
# Alternative check: /etc/debian_version
if [[ -f /etc/debian_version ]]; then
return 0 # OK: Debian-based
fi
return 1 # NO Debian-based
}
# Add fzf keybindings and enhancements
if is_debian_based; then
export FZF_CTRL_T_COMMAND="fdfind --type f"
export FZF_ALT_C_COMMAND="fdfind --type d"
else
export FZF_CTRL_T_COMMAND="fd --type f"
export FZF_ALT_C_COMMAND="fd --type d"
fi
export FZF_CTRL_R_OPTS="--preview 'echo {}'"
# Export Catppuccin Mocha theme for FZF
export FZF_DEFAULT_OPTS=" \
--height 60% --layout=reverse --border \
--color=bg+:#313244,bg:#1E1E2E,spinner:#F5E0DC,hl:#F38BA8 \
--color=fg:#CDD6F4,header:#F38BA8,info:#CBA6F7,pointer:#F5E0DC \
--color=marker:#B4BEFE,fg+:#CDD6F4,prompt:#CBA6F7,hl+:#F38BA8 \
--color=selected-bg:#45475A \
--color=border:#313244,label:#CDD6F4"

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env bash
[ -f "$HOME/.ghcup/env" ] && . "$HOME/.ghcup/env"

View File

@@ -1,12 +0,0 @@
#!/usr/bin/env bash
case $(uname -s) in
"Linux")
export GOPATH="$HOME/.local/share/Go";;
"Darwin")
export GOPATH="$HOME/Library/Go";;
*)
echo "Operating System unknown";;
esac
export GOBIN=$GOPATH/bin

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env bash
export GRAALVM_HOME="${HOME}/.local/share/mise/installs/java/graalvm-community-23.0.1"

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
if [[ $SHELL == "zsh" ]]; then
export HELPDIR=/usr/share/zsh/"${ZSH_VERSION}"/help
fi

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env bash
export HOMEBREW_NO_ENV_HINTS=1

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env bash
export JAVA_HOME="${HOME}/.local/share/mise/installs/java/23.0.1"

View File

@@ -1,4 +0,0 @@
#!/usr/bin/env bash
JMETER_HOME="$(which jmeter)"
export JMETER_HOME

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
if [ -e "$HOME/.cargo" ]; then
source "$HOME/.cargo/env"
fi

View File

@@ -1,55 +0,0 @@
#!/usr/bin/env bash
if [ -z "$DISPLAY" ] && [ "$(tty)" = "/dev/tty1" ]; then
if [ -n "$DBUS_SESSION_BUS_ADDRESS" ]; then
# XDG Settings Basic
export XDG_CONFIG_HOME=${HOME}/.config
export XDG_DATA_HOME=${HOME}/.local/share
export XDG_CACHE_HOME=${HOME}/.local/cache
export XDG_STATE_HOME=${HOME}/.local/state
# XDG_CONFIG_HOME
export GTK2_RC_FILES=${XDG_CONFIG_HOME}/gtk-2.0/gtkrc-2.0
# Reduces crashs for some gdk apps, like evolution
# ! Do not set as global variable. Electron Apps will not start !
# export GDK_BACKEND=wayland
# Required for tray icons on waybar
export XDG_CURRENT_DESKTOP=sway
# Enable QT apps to have gtk theme
export QT_QPA_PLATFORMTHEME=qt5ct
# Force wayland on qt apps
export QT_QPA_PLATFORM=wayland
export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
# Explicitly set to '96' instead of 'physical' because some apps have problems
# Looking at you nextcloud client!
# https://github.com/nextcloud/desktop/issues/1079
# https://github.com/swaywm/sway/issues/2424
export QT_WAYLAND_FORCE_DPI=96
# Make Qt apps honour DPI settings.
export QT_AUTO_SCREEN_SCALE_FACTOR=1
# Mozilla Wayland support + hardware video decoding
export MOZ_ENABLE_WAYLAND=1
export MOZ_WAYLAND_USE_VAAPI=1
# SDL
export SDL_VIDEODRIVER=wayland
# Java under Xwayland
export _JAVA_AWT_WM_NONREPARENTING=1
# Session Type for later screensharing
export XDG_SESSION_TYPE=wayland
exec dbus-launch --exit-with-session sway
else
echo "Cannot found dbus session: Sway don't work"
fi
fi

View File

@@ -1,3 +0,0 @@
#/usr/bin/env bash
export VIRTUAL_ENV_DISABLE_PROMPT=1

View File

@@ -1,7 +1,12 @@
[ -f "$HOME/.ghcup/env" ] && . "$HOME/.ghcup/env"
# Add ~/.local/bin if not exists
case ":$PATH:" in
*":$HOME/.local/bin:"*) ;;
*) export PATH="$HOME/.local/bin:$PATH" ;;
esac
if [ -f "/home/linuxbrew/.linuxbrew/bin/brew" ]; then
# Initialize Homebrew
export HOMEBREW_NO_ENV_HINTS=1
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
@@ -10,9 +15,38 @@ if command -v starship > /dev/null 2>&1; then
eval "$(starship init zsh)"
fi
# Aggiungi ~/.local/bin a PATH se non c'è già
case ":$PATH:" in
*":$HOME/.local/bin:"*) ;;
*) export PATH="$HOME/.local/bin:$PATH" ;;
esac
if [ -e "$HOME/.cargo" ]; then
source "$HOME/.cargo/env"
fi
export EDITOR="nvim"
export MANPAGER="nvim +Man!"
export DOTFILES="$HOME/.dotfiles"
export GOPATH="$HOME/.local/share/Go"
export GOBIN=$GOPATH/bin
export GRAALVM_HOME="${HOME}/.local/share/mise/installs/java/graalvm-community-23.0.1"
export HELPDIR=/usr/share/zsh/"${ZSH_VERSION}"/help
export JAVA_HOME="${HOME}/.local/share/mise/installs/java/23.0.1"
export VIRTUAL_ENV_DISABLE_PROMPT=1
export JMETER_HOME="$(which jmeter)"
export FZF_HOME=$HOME/.oh-my-zsh/custom/plugins/fzf
export FZF_CTRL_T_COMMAND="fdfind --type f"
export FZF_ALT_C_COMMAND="fdfind --type d"
export FZF_CTRL_R_OPTS="--preview 'echo {}'"
# Export Catppuccin Mocha theme for FZF
export FZF_DEFAULT_OPTS=" \
--height 60% --layout=reverse --border \
--color=bg+:#313244,bg:#1E1E2E,spinner:#F5E0DC,hl:#F38BA8 \
--color=fg:#CDD6F4,header:#F38BA8,info:#CBA6F7,pointer:#F5E0DC \
--color=marker:#B4BEFE,fg+:#CDD6F4,prompt:#CBA6F7,hl+:#F38BA8 \
--color=selected-bg:#45475A \
--color=border:#313244,label:#CDD6F4"
source <(fzf --zsh)
source "$FZF_HOME/shell/key-bindings.zsh"
source "$FZF_HOME/shell/completion.zsh"
# Launch tmux in the default session
if command -v tmux &> /dev/null && [ -z "$TMUX" ]; then
tmux attach-session -t default || tmux new-session -s default
fi

View File

@@ -74,7 +74,6 @@ ZSH_CUSTOM=$ZSH/custom
# Add wisely, as too many plugins slow down shell startup.
plugins=(
aws
colored-man-pages
command-not-found
gitignore
mise
@@ -113,19 +112,11 @@ source $ZSH/oh-my-zsh.sh
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# Setup emacs keymap
bindkey -e
# Setup vim keymap
bindkey -v
fpath=(~/.zsh $fpath)
autoload run-help
autoload -Uz compinit && compinit -u
export FZF_HOME=$HOME/.oh-my-zsh/custom/plugins/fzf
source <(fzf --zsh)
source "$FZF_HOME/shell/key-bindings.zsh"
source "$FZF_HOME/shell/completion.zsh"
if command -v tmux &> /dev/null && [ -z "$TMUX" ]; then
tmux attach-session -t default || tmux new-session -s default
fi