# My .zshrc the core for everything # # Set the path(s) to the config file(s) CONFIG_PATH="$HOME/.config/dotfiles/config" DEFAULT_CONFIG_PATH="$HOME/.config/dotfiles/config.default" # # Give an Error if the default configuration could not be found if [ ! -f "${DEFAULT_CONFIG_PATH}" ] then echo "Error: The default configuration file (${DEFAULT_CONFIG_PATH}) could not be found" exit 1 fi # # Source the default configuration to prevent errors source "${DEFAULT_CONFIG_PATH}" # # Copy the default configuration file if it does not exist if [ ! -f "${CONFIG_PATH}" ] then cp "${DEFAULT_CONFIG_PATH}" "${CONFIG_PATH}" fi # # Source the normal configuration source "${CONFIG_PATH}" # Add ~/.local/bin and ~/bin to the PATH if [ -d "$HOME/bin" ]; then export PATH="$HOME/bin:$PATH" fi if [ -d "$HOME/.local/bin" ]; then export PATH="$HOME/.local/bin:$PATH" fi # # Detect Device Arch arch="$(uname -m | tr '[:upper:]' '[:lower:]')" case "${arch}" in x86_64) arch="amd64" ;; armv*) arch="arm" ;; arm64) arch="arm64" ;; aarch64) arch="arm64" ;; i686) arch="386" ;; esac if [ "${arch}" = "arm64" ] && [ "$(getconf LONG_BIT)" -eq 32 ]; then arch=arm fi # # Detect Device Platform platform="$(uname -s | awk '{print tolower($0)}')" case "${platform}" in linux) platform="linux" ;; darwin) platform="darwin" ;; esac # # Set the OMP Path and create the directory OMP_PATH="$HOME/.config/dotfiles/oh-my-posh" [ ! -d $OMP_PATH ] && mkdir -p "$(dirname $OMP_PATH)" # # Set the path to the OMP Theme OMP_THEME_PATH="$OMP_PATH/$OMP_THEME.toml" # # Set the OMP target Platform OMP_TARGET="$platform-$arch" # # Set the path to the OMP Executeable OMP_EXE="$OMP_PATH/posh-$OMP_TARGET" # # Download OMP if it does not exist if [ ! -f $OMP_EXE ]; then echo "Downloading Oh My Posh for $OMP_TARGET" curl -s -L -o $OMP_EXE "https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-$OMP_TARGET" chmod +x $OMP_EXE fi # # Alias OMP alias oh-my-posh=$OMP_EXE # # Initialize OMP eval "$(oh-my-posh init zsh --config $OMP_THEME_PATH)" # # Get and download zinit ZINIT_HOME="$HOME/.config/dotfiles/zinit/zinit.git" [ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)" [ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" # # Initialize zinit source "${ZINIT_HOME}/zinit.zsh" # # Command Syntax Highlighting zinit light zsh-users/zsh-syntax-highlighting # # Command Completions zinit light zsh-users/zsh-completions # # Inline Command Suggestions based on history zinit light zsh-users/zsh-autosuggestions # # Initialize fzf if it exists if [ "${USE_FZF}" = "1" ] && command -v fzf &> /dev/null then eval "$(fzf --zsh)" zinit light Aloxaf/fzf-tab fi # # Initialize Zoxide if it exists if command -v zoxide &> /dev/null then eval "$(zoxide init --cmd cd zsh)" fi # # Load the zsh completion system autoload -U compinit && compinit # # Initialize TheF*ck if it exists if command -v thefuck &> /dev/null then eval "$(thefuck --alias)" fi # # Add boundaries to the path if it exists if [ -f "$HOME/.bndpath" ] then PATH="$(cat $HOME/.bndpath)/exec/bin:$PATH" elif [ -d "$HOME/boundaries" ] then PATH="$HOME/boundaries/exec/bin:$PATH" fi # # Colored ls alias ls="ls --color=auto" # # ls like colored completions zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" # # Ignore completion capitalisation zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' # # Disable the default autocompletion if fzf exists and show a better cd completion if [ "${USE_FZF}" = "1" ] && command -v fzf &> /dev/null then zstyle ':completion:*' menu no zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls --color $realpath' fi # # Alias please to run0, doas, sudo or su if command -v doas &> /dev/null then alias please='doas env WAYLAND_DISPLAY="$WAYLAND_DISPLAY" XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" DISPLAY="$DISPLAY"' elif command -v sudo &> /dev/null then alias please='sudo env WAYLAND_DISPLAY="$WAYLAND_DISPLAY" XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" DISPLAY="$DISPLAY"' elif command -v run0 &> /dev/null then alias please='run0 env WAYLAND_DISPLAY="$WAYLAND_DISPLAY" XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" DISPLAY="$DISPLAY"' elif command -v su &> /dev/null then alias please='su -c env WAYLAND_DISPLAY="$WAYLAND_DISPLAY" XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" DISPLAY="$DISPLAY"' fi # # set the correct editor if command -v nvim &> /dev/null then export EDITOR="nvim" elif command -v vim &> /dev/null then export EDITOR="vim" elif command -v nano &> /dev/null then export EDITOR="nano" fi # # Alias la to ls -la alias la="ls -la" # # Enable emacs keybindings bindkey -e # # Support for the delete key bindkey "^[[3~" delete-char # # The file the History is written to HISTFILE=~/.zsh_history # # The maximum History Size SAVEHIST=$HISTSIZE # # Erease duplicates HISTDUP=erase # # Share History between Sessions setopt appendhistory setopt sharehistory # # Ignore when Space is in front setopt hist_ignore_space # # Ingore Duplicates setopt hist_ignore_all_dups setopt hist_save_no_dups setopt hist_ignore_dups setopt hist_find_no_dups # # Command to update Dotfiles update-dotfiles () { pushd "$HOME/.config/dotfiles" git pull oh-my-posh upgrade popd echo "Dotfiles updated. You might need to restart your shell with exec zsh." } # # Show pfetch if it is enabled and installed if [ "${SHOW_PFETCH}" = "1" ] && command -v pfetch &> /dev/null then alias clear="clear && pfetch" pfetch fi