From 2326e2e92de27fca968c4d058f55046610761447 Mon Sep 17 00:00:00 2001 From: Fabio Scotto di Santolo Date: Thu, 31 Jul 2025 10:47:20 +0200 Subject: [PATCH] Fix ZSH configuration for WSL --- zsh/.profile.d/dotfiles.sh | 3 -- zsh/.profile.d/editor.sh | 3 -- zsh/.profile.d/fzf.sh | 38 ----------------------- zsh/.profile.d/ghcup.sh | 3 -- zsh/.profile.d/go.sh | 12 -------- zsh/.profile.d/graalvm.sh | 3 -- zsh/.profile.d/help.sh | 5 ---- zsh/.profile.d/homebrew.sh | 3 -- zsh/.profile.d/java.sh | 3 -- zsh/.profile.d/jmeter.sh | 4 --- zsh/.profile.d/rust.sh | 5 ---- zsh/.profile.d/sway-startup.sh | 55 ---------------------------------- zsh/.profile.d/venv.sh | 3 -- zsh/.zshenv | 46 ++++++++++++++++++++++++---- zsh/.zshrc | 13 ++------ 15 files changed, 42 insertions(+), 157 deletions(-) delete mode 100755 zsh/.profile.d/dotfiles.sh delete mode 100755 zsh/.profile.d/editor.sh delete mode 100755 zsh/.profile.d/fzf.sh delete mode 100755 zsh/.profile.d/ghcup.sh delete mode 100755 zsh/.profile.d/go.sh delete mode 100755 zsh/.profile.d/graalvm.sh delete mode 100755 zsh/.profile.d/help.sh delete mode 100755 zsh/.profile.d/homebrew.sh delete mode 100755 zsh/.profile.d/java.sh delete mode 100755 zsh/.profile.d/jmeter.sh delete mode 100755 zsh/.profile.d/rust.sh delete mode 100755 zsh/.profile.d/sway-startup.sh delete mode 100755 zsh/.profile.d/venv.sh diff --git a/zsh/.profile.d/dotfiles.sh b/zsh/.profile.d/dotfiles.sh deleted file mode 100755 index ce610c5..0000000 --- a/zsh/.profile.d/dotfiles.sh +++ /dev/null @@ -1,3 +0,0 @@ -#/usr/bin/env bash - -export DOTFILES="$HOME/.dotfiles" diff --git a/zsh/.profile.d/editor.sh b/zsh/.profile.d/editor.sh deleted file mode 100755 index a55e9e0..0000000 --- a/zsh/.profile.d/editor.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -export EDITOR=vim diff --git a/zsh/.profile.d/fzf.sh b/zsh/.profile.d/fzf.sh deleted file mode 100755 index bdccac0..0000000 --- a/zsh/.profile.d/fzf.sh +++ /dev/null @@ -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" diff --git a/zsh/.profile.d/ghcup.sh b/zsh/.profile.d/ghcup.sh deleted file mode 100755 index 8a285c2..0000000 --- a/zsh/.profile.d/ghcup.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -[ -f "$HOME/.ghcup/env" ] && . "$HOME/.ghcup/env" diff --git a/zsh/.profile.d/go.sh b/zsh/.profile.d/go.sh deleted file mode 100755 index fc20431..0000000 --- a/zsh/.profile.d/go.sh +++ /dev/null @@ -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 diff --git a/zsh/.profile.d/graalvm.sh b/zsh/.profile.d/graalvm.sh deleted file mode 100755 index 4471bc4..0000000 --- a/zsh/.profile.d/graalvm.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -export GRAALVM_HOME="${HOME}/.local/share/mise/installs/java/graalvm-community-23.0.1" diff --git a/zsh/.profile.d/help.sh b/zsh/.profile.d/help.sh deleted file mode 100755 index 7ebd5a2..0000000 --- a/zsh/.profile.d/help.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -if [[ $SHELL == "zsh" ]]; then - export HELPDIR=/usr/share/zsh/"${ZSH_VERSION}"/help -fi diff --git a/zsh/.profile.d/homebrew.sh b/zsh/.profile.d/homebrew.sh deleted file mode 100755 index 9a0db64..0000000 --- a/zsh/.profile.d/homebrew.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -export HOMEBREW_NO_ENV_HINTS=1 diff --git a/zsh/.profile.d/java.sh b/zsh/.profile.d/java.sh deleted file mode 100755 index 41e1f74..0000000 --- a/zsh/.profile.d/java.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -export JAVA_HOME="${HOME}/.local/share/mise/installs/java/23.0.1" diff --git a/zsh/.profile.d/jmeter.sh b/zsh/.profile.d/jmeter.sh deleted file mode 100755 index d4c1838..0000000 --- a/zsh/.profile.d/jmeter.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -JMETER_HOME="$(which jmeter)" -export JMETER_HOME diff --git a/zsh/.profile.d/rust.sh b/zsh/.profile.d/rust.sh deleted file mode 100755 index 4b9ab3b..0000000 --- a/zsh/.profile.d/rust.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -if [ -e "$HOME/.cargo" ]; then - source "$HOME/.cargo/env" -fi \ No newline at end of file diff --git a/zsh/.profile.d/sway-startup.sh b/zsh/.profile.d/sway-startup.sh deleted file mode 100755 index f271ca6..0000000 --- a/zsh/.profile.d/sway-startup.sh +++ /dev/null @@ -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 diff --git a/zsh/.profile.d/venv.sh b/zsh/.profile.d/venv.sh deleted file mode 100755 index c66cedb..0000000 --- a/zsh/.profile.d/venv.sh +++ /dev/null @@ -1,3 +0,0 @@ -#/usr/bin/env bash - -export VIRTUAL_ENV_DISABLE_PROMPT=1 diff --git a/zsh/.zshenv b/zsh/.zshenv index f5cf481..2abf2eb 100644 --- a/zsh/.zshenv +++ b/zsh/.zshenv @@ -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 diff --git a/zsh/.zshrc b/zsh/.zshrc index 3b21c25..a628ea0 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -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