From 671dc697c8ebb4763e434d123372d10782b220f0 Mon Sep 17 00:00:00 2001 From: Jeremie Fraeys Date: Wed, 18 Dec 2024 20:51:10 -0500 Subject: [PATCH] making bash more similar to zsh configs --- bash/.bash_profile | 17 +++++++++++++++-- bash/.bashrc | 27 +++++++++++++++++++++++++++ bash/.fzf.bash | 15 +++++++++++++-- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/bash/.bash_profile b/bash/.bash_profile index 075fd45..2697d82 100755 --- a/bash/.bash_profile +++ b/bash/.bash_profile @@ -15,6 +15,8 @@ if [ -d "$HOME/.local/bin" ] && [[ ! "$PATH" =~ (^|:)${HOME}/.local/bin(:|$) ]]; export PATH="$HOME/.local/bin:$PATH" fi +[[ -n ${SSH_CONNECTION} ]] && export EDITOR='vim' + # Set permissions for ~/.local/bin chmod -R ug+rwx "$HOME/.local/bin/" @@ -31,12 +33,12 @@ fi [ -f ~/.fzf.bash ] && . ~/.fzf.bash -# Add RVM to PATH +# Add RVM to PATH if not already included if [[ ! "$PATH" =~ (^|:)${HOME}/.rvm/bin(:|$) ]]; then export PATH="$PATH:$HOME/.rvm/bin" fi -# Add Golang to PATH +# Add Golang to PATH if not already included if [ -n "$(go env GOPATH)" ] && [[ ! "$PATH" =~ (^|:)$(go env GOPATH)/bin(:|$) ]]; then export GOPATH="$HOME/Documents/projects:$HOME/go" export PATH="$PATH:$(go env GOPATH)/bin" @@ -62,3 +64,14 @@ fi unset __conda_setup # <<< conda initialize <<< +# Check for WSL and adjust configurations +if grep -q Microsoft /proc/version; then + # Ensure WSL compatibility for Conda if using Miniforge + if [ -f "/mnt/c/Users/$USER/AppData/Local/Miniconda3/etc/profile.d/conda.sh" ]; then + . "/mnt/c/Users/$USER/AppData/Local/Miniconda3/etc/profile.d/conda.sh" + fi +else + # Unix-specific configuration (Linux/macOS) + # Add any Unix-specific paths or configurations here + export PATH="/usr/local/bin:$PATH" +fi diff --git a/bash/.bashrc b/bash/.bashrc index 7142ce4..b4b5528 100755 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -3,6 +3,25 @@ if [[ -f /etc/bash_completion ]]; then . /etc/bash_completion fi +# Check for WSL and adjust accordingly +if grep -q Microsoft /proc/version; then + # WSL-specific configuration + + # Set path to Windows executables for easy access + export PATH="/mnt/c/Windows/System32:$PATH" + export PATH="/mnt/c/Program Files:$PATH" + export PATH="/mnt/c/Windows:$PATH" + + # Use Windows Notepad or other executables from WSL + alias notepad="notepad.exe" + alias explorer="explorer.exe" +else + # Unix-specific configuration (Linux or macOS) + # You can add Unix-specific tools and paths here if needed + # For example, add custom Linux paths if they are different from default + export PATH="/usr/local/bin:$PATH" +fi + # Custom aliases alias python="python3" alias grep="grep --color=auto" @@ -12,6 +31,7 @@ alias ...="cd ../.." alias ....="cd ../../.." alias .....="cd ../../../.." +# Load custom check_aliases if it exists if [[ -f "$HOME/.local/bin/scripts/check_aliases" ]]; then . "$HOME/.local/bin/scripts/check_aliases" fi @@ -33,3 +53,10 @@ fi if command -v starship &>/dev/null; then eval "$(starship init bash)" fi + +# Optionally, initialize other tools for Unix and WSL environments +if command -v wslpath &>/dev/null; then + # Adjust paths between WSL and Windows if necessary + export PATH="$(wslpath 'C:\Program Files'):$PATH" + export PATH="/mnt/c/Program Files/neovim/bin:$PATH" +fi diff --git a/bash/.fzf.bash b/bash/.fzf.bash index d133b02..a282583 100755 --- a/bash/.fzf.bash +++ b/bash/.fzf.bash @@ -1,9 +1,9 @@ # Setup fzf # --------- -# Get the path to fzf installed by Nix +# Get the path to fzf installed by Nix or from a general location FZF_PATH="$(command -v fzf | xargs dirname)" -# Ensure the fzf binary is in the PATH +# Ensure the fzf binary is in the PATH (if not already added) if [[ ! "$PATH" == *"$FZF_PATH/bin"* ]]; then PATH="${PATH:+${PATH}:}$FZF_PATH/bin" fi @@ -19,3 +19,14 @@ fi if [[ -f "$FZF_PATH/shell/key-bindings.bash" ]]; then source "$FZF_PATH/shell/key-bindings.bash" fi + +# Check for WSL and ensure compatibility +if grep -q Microsoft /proc/version; then + # WSL-specific path handling (if needed) + if [[ -f "/mnt/c/Program Files/fzf/shell/completion.bash" ]]; then + source "/mnt/c/Program Files/fzf/shell/completion.bash" + fi + if [[ -f "/mnt/c/Program Files/fzf/shell/key-bindings.bash" ]]; then + source "/mnt/c/Program Files/fzf/shell/key-bindings.bash" + fi +fi