Worked on zsh + starship + confs
This commit is contained in:
+8
-32
@@ -1144,13 +1144,13 @@ This file sets up starship prompt
|
|||||||
** =generated/system/applications/terminal_shell/zsh.nix=
|
** =generated/system/applications/terminal_shell/zsh.nix=
|
||||||
This is top file of this level which contains just an import statement for all relevant files and/or the subfolder in this folder
|
This is top file of this level which contains just an import statement for all relevant files and/or the subfolder in this folder
|
||||||
#+BEGIN_SRC nix :tangle generated/system/applications/terminal_shell/zsh.nix :noweb tangle :mkdirp yes :eval never-html
|
#+BEGIN_SRC nix :tangle generated/system/applications/terminal_shell/zsh.nix :noweb tangle :mkdirp yes :eval never-html
|
||||||
{ config, pkgs, lib, user, ... }:
|
{ config, pkgs, lib, user, flakeRoot, ... }:
|
||||||
let
|
let
|
||||||
zshConfigDir = "${config.home-manager.users.${user.username}.xdg.configHome}/zsh";
|
zshConfigDir = "${config.home-manager.users.${user.username}.xdg.configHome}/zsh";
|
||||||
|
assetsDir = "${flakeRoot}/assets/common/conf/zsh";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
home-manager.users.${user.username} = {
|
home-manager.users.${user.username} = {
|
||||||
# Install zsh-syntax-highlighting
|
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
zsh-syntax-highlighting
|
zsh-syntax-highlighting
|
||||||
starship
|
starship
|
||||||
@@ -1179,37 +1179,13 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Consolidated .zshrc
|
# Use the .zshrc file from assets
|
||||||
xdg.configFile."zsh/.zshrc".text = lib.concatStringsSep "\n" [
|
xdg.configFile."zsh/.zshrc".source = "${assetsDir}/.zshrc";
|
||||||
"# Oh-My-Zsh"
|
|
||||||
"export ZSH=\"${zshConfigDir}\""
|
|
||||||
"source \"${pkgs.zsh}/share/zsh/functions/Newuser/zsh-newuser-install\""
|
|
||||||
"source \"${zshConfigDir}/oh-my-zsh.sh\""
|
|
||||||
""
|
|
||||||
"# Zsh options"
|
|
||||||
"setopt AUTO_CD"
|
|
||||||
"setopt CORRECT"
|
|
||||||
"setopt INTERACTIVE_COMMENTS"
|
|
||||||
""
|
|
||||||
"# zsh-syntax-highlighting (manually sourced)"
|
|
||||||
"source ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|
|
||||||
""
|
|
||||||
"# Starship"
|
|
||||||
"eval \"$(starship init zsh)\""
|
|
||||||
""
|
|
||||||
"# fzf"
|
|
||||||
"source \"${pkgs.fzf}/shell/key-bindings.zsh\""
|
|
||||||
"source \"${pkgs.fzf}/shell/completion.zsh\""
|
|
||||||
""
|
|
||||||
"# User customizations"
|
|
||||||
"source \"${zshConfigDir}/custom.zsh\" 2>/dev/null"
|
|
||||||
];
|
|
||||||
|
|
||||||
# User customizations
|
# Create symlinks or copy files from assets to XDG config
|
||||||
xdg.configFile."zsh/custom.zsh".text = ''
|
xdg.configFile."zsh/custom.zsh".source = "${assetsDir}/custom.zsh";
|
||||||
export EDITOR="nvim"
|
xdg.configFile."zsh/aliases.zsh".source = "${assetsDir}/aliases.zsh";
|
||||||
export PATH="$HOME/.local/bin:$PATH"
|
xdg.configFile."zsh/history.zsh".source = "${assetsDir}/history.zsh";
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
typeset -U path cdpath fpath manpath
|
||||||
|
for profile in ${(z)NIX_PROFILES}; do
|
||||||
|
fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
|
||||||
|
done
|
||||||
|
|
||||||
|
HELPDIR="${ZSH_HELPDIR:-${XDG_DATA_HOME:-$HOME/.local/share}/zsh/$ZSH_VERSION/help}"
|
||||||
|
|
||||||
|
# Source zsh-autosuggestions (use environment variable)
|
||||||
|
if [ -n "$ZSH_AUTOSUGGESTIONS_PATH" ]; then
|
||||||
|
source "$ZSH_AUTOSUGGESTIONS_PATH"
|
||||||
|
ZSH_AUTOSUGGEST_STRATEGY=(history)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# oh-my-zsh extra settings for plugins
|
||||||
|
plugins=(git sudo extract colored-man-pages command-not-found history docker kubectl)
|
||||||
|
|
||||||
|
source "$ZSH/oh-my-zsh.sh"
|
||||||
|
|
||||||
|
# Source zoxide (use environment variable)
|
||||||
|
if [ -n "$ZOXIDE_INIT" ]; then
|
||||||
|
eval "$($ZOXIDE_INIT zsh)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# History options should be set in .zshrc and after oh-my-zsh sourcing.
|
||||||
|
HISTSIZE="10000"
|
||||||
|
SAVEHIST="10000"
|
||||||
|
HISTFILE="${XDG_CONFIG_HOME:-$HOME/.config}/zsh/.zsh_history"
|
||||||
|
mkdir -p "$(dirname "$HISTFILE")"
|
||||||
|
|
||||||
|
# Source fzf (use environment variable)
|
||||||
|
if [[ $options[zle] = on ]] && [ -n "$FZF_ZSH" ]; then
|
||||||
|
source <($FZF_ZSH --zsh)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Source zsh-syntax-highlighting (use environment variable)
|
||||||
|
if [ -n "$ZSH_SYNTAX_HIGHLIGHTING_PATH" ]; then
|
||||||
|
source "$ZSH_SYNTAX_HIGHLIGHTING_PATH"
|
||||||
|
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Source catppuccin zsh-syntax-highlighting (use environment variable)
|
||||||
|
if [ -n "$CATPPUCCIN_ZSH_SYNTAX_PATH" ]; then
|
||||||
|
source "$CATPPUCCIN_ZSH_SYNTAX_PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set shell options
|
||||||
|
set_opts=(
|
||||||
|
HIST_FCNTL_LOCK HIST_IGNORE_DUPS HIST_IGNORE_SPACE SHARE_HISTORY autocd
|
||||||
|
NO_APPEND_HISTORY NO_EXTENDED_HISTORY NO_HIST_EXPIRE_DUPS_FIRST
|
||||||
|
NO_HIST_FIND_NO_DUPS NO_HIST_IGNORE_ALL_DUPS NO_HIST_SAVE_NO_DUPS
|
||||||
|
)
|
||||||
|
for opt in "${set_opts[@]}"; do
|
||||||
|
setopt "$opt"
|
||||||
|
done
|
||||||
|
unset opt set_opts
|
||||||
|
|
||||||
|
# Source starship (use environment variable)
|
||||||
|
if [[ $TERM != "dumb" ]] && [ -n "$STARSHIP_INIT" ]; then
|
||||||
|
eval "$($STARSHIP_INIT zsh)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Kitty shell integration
|
||||||
|
if test -n "$KITTY_INSTALLATION_DIR"; then
|
||||||
|
export KITTY_SHELL_INTEGRATION="no-rc"
|
||||||
|
autoload -Uz -- "$KITTY_INSTALLATION_DIR/shell-integration/zsh/kitty-integration"
|
||||||
|
kitty-integration
|
||||||
|
unfunction kitty-integration
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Source direnv (use environment variable)
|
||||||
|
if [ -n "$DIRENV_HOOK" ]; then
|
||||||
|
eval "$($DIRENV_HOOK zsh)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Aliases
|
||||||
|
alias -- la='eza -a'
|
||||||
|
alias -- ll='eza -l'
|
||||||
|
alias -- lla='eza -la'
|
||||||
|
alias -- ls='eza'
|
||||||
|
alias -- lt='eza --tree'
|
||||||
|
|
||||||
|
# Eat shell integration
|
||||||
|
[ -n "$EAT_SHELL_INTEGRATION_DIR" ] && source "$EAT_SHELL_INTEGRATION_DIR/zsh"
|
||||||
|
|
||||||
|
# Source user aliases
|
||||||
|
if [ -f "$XDG_CONFIG_HOME/zsh/aliases.zsh" ]; then
|
||||||
|
source "$XDG_CONFIG_HOME/zsh/aliases.zsh"
|
||||||
|
fi
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
# --- Environment Variables ---
|
||||||
|
export EDITOR="nvim"
|
||||||
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
|
export PATH="$HOME/.cargo/bin:$PATH" # Example: Add Rust's cargo binaries
|
||||||
|
|
||||||
|
# --- Aliases ---
|
||||||
|
# (You can move these from your Nix config to here if you prefer)
|
||||||
|
alias gs="git status"
|
||||||
|
alias ga="git add"
|
||||||
|
alias gc="git commit -m"
|
||||||
|
alias gp="git push"
|
||||||
|
alias gco="git checkout"
|
||||||
|
alias ll="exa --icons -la --group-directories-first"
|
||||||
|
alias ls="exa --icons -a --group-directories-first"
|
||||||
|
|
||||||
|
# --- Functions ---
|
||||||
|
# Example: Create a new directory and cd into it
|
||||||
|
mkcd() {
|
||||||
|
mkdir -p "$1" && cd "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- Shell Options ---
|
||||||
|
setopt HIST_IGNORE_ALL_DUPS # Ignore duplicate commands in history
|
||||||
|
setopt HIST_IGNORE_SPACE # Ignore commands starting with a space
|
||||||
|
setopt APPEND_HISTORY # Append to history file, don't overwrite
|
||||||
|
setopt INC_APPEND_HISTORY # Append to history file as soon as the command is entered
|
||||||
|
|
||||||
|
# --- Key Bindings ---
|
||||||
|
# Example: Edit command line in $EDITOR
|
||||||
|
autoload -U edit-command-line
|
||||||
|
zle -N edit-command-line
|
||||||
|
bindkey '^xe' edit-command-line # Ctrl+x, e
|
||||||
|
|
||||||
|
# --- Prompt Customization ---
|
||||||
|
# (Starship usually handles this, but you can add pre-starship prompts here)
|
||||||
|
|
||||||
|
# --- Load other files ---
|
||||||
|
# Source other files (e.g., secrets, local overrides)
|
||||||
|
[[ -f "$HOME/.zshrc.local" ]] && source "$HOME/.zshrc.local"
|
||||||
|
|
||||||
|
# --- Fuzzy Finder (fzf) ---
|
||||||
|
# If not already loaded in .zshrc
|
||||||
|
[[ $- == *i* ]] && source "$(brew --prefix)/opt/fzf/shell/key-bindings.zsh" 2>/dev/null
|
||||||
|
[[ $- == *i* ]] && source "$(brew --prefix)/opt/fzf/shell/completion.zsh" 2>/dev/null
|
||||||
|
|
||||||
|
# --- Conditional Loading ---
|
||||||
|
# Only load if not already loaded
|
||||||
|
if [[ -z "$TMUX" ]]; then
|
||||||
|
# Example: Start tmux if not already in a session
|
||||||
|
if command -v tmux &>/dev/null && [ -n "$PS1" ]; then
|
||||||
|
exec tmux
|
||||||
|
fi
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user