Remove Oh My ZSH dependency of my ZSH configuration

This commit is contained in:
Fabio Scotto di Santolo
2025-08-18 12:00:40 +02:00
parent 39adacbd5e
commit a7601f0c55
13 changed files with 268 additions and 166 deletions

15
.gitmodules vendored
View File

@@ -19,18 +19,15 @@
[submodule "tmux/.tmux/plugins/tmux"] [submodule "tmux/.tmux/plugins/tmux"]
path = tmux/.tmux/plugins/tmux path = tmux/.tmux/plugins/tmux
url = https://github.com/catppuccin/tmux.git url = https://github.com/catppuccin/tmux.git
[submodule "zsh/.oh-my-zsh/custom/plugins/zsh-autosuggestions"]
path = zsh/.oh-my-zsh/custom/plugins/zsh-autosuggestions
url = https://github.com/zsh-users/zsh-autosuggestions.git
[submodule "zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting"]
path = zsh/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
url = https://github.com/zsh-users/zsh-syntax-highlighting.git
[submodule "zsh/.oh-my-zsh/custom/plugins/fzf"]
path = zsh/.oh-my-zsh/custom/plugins/fzf
url = https://github.com/junegunn/fzf.git
[submodule "tmux/.tmux/plugins/tmux-continuum"] [submodule "tmux/.tmux/plugins/tmux-continuum"]
path = tmux/.tmux/plugins/tmux-continuum path = tmux/.tmux/plugins/tmux-continuum
url = https://git::@github.com/tmux-plugins/tmux-continuum url = https://git::@github.com/tmux-plugins/tmux-continuum
[submodule "tmux/.tmux/plugins/tmux-resurrect"] [submodule "tmux/.tmux/plugins/tmux-resurrect"]
path = tmux/.tmux/plugins/tmux-resurrect path = tmux/.tmux/plugins/tmux-resurrect
url = https://git::@github.com/tmux-plugins/tmux-resurrect url = https://git::@github.com/tmux-plugins/tmux-resurrect
[submodule "zsh/.zsh/plugins/zsh-autosuggestions"]
path = zsh/.zsh/plugins/zsh-autosuggestions
url = https://github.com/zsh-users/zsh-autosuggestions.git
[submodule "zsh/.zsh/plugins/zsh-syntax-highlighting"]
path = zsh/.zsh/plugins/zsh-syntax-highlighting
url = https://github.com/zsh-users/zsh-syntax-highlighting.git

View File

@@ -1,30 +0,0 @@
pbcopy() {
if [ -f "$1" ]; then
mime_type=$(file --mime-type -b "$1")
wl-copy --type "$mime_type" < "$1"
else
printf "%s" "$*" | wl-copy
fi
}
alias pbpaste='wl-paste --no-newline'
alias ls="eza --color=always --group-directories-first --icons=always"
alias cat='bat --style header --style snip --style changes --pager never'
# Replace df command tool
alias df='duf'
# Replace Vim implementation
alias vi='nvim'
alias vim='nvim'
# Replace grep command tool
alias grep='ugrep --color=auto'
alias egrep='ugrep -E --color=auto'
alias fgrep='ugrep -F --color=auto'
# Other aliases
alias paths='echo -e ${PATH//:/\\n}' # path: Echo all executable Paths
alias userlist="cut -d: -f1 /etc/passwd | sort"
alias ip='ip -color'
alias stow='stow -d $DOTFILES '

View File

@@ -0,0 +1,54 @@
# Requires colors autoload.
# See termcap(5).
# Set up once, and then reuse. This way it supports user overrides after the
# plugin is loaded.
typeset -AHg less_termcap
# bold & blinking mode
less_termcap[mb]="${fg_bold[red]}"
less_termcap[md]="${fg_bold[red]}"
less_termcap[me]="${reset_color}"
# standout mode
less_termcap[so]="${fg_bold[yellow]}${bg[blue]}"
less_termcap[se]="${reset_color}"
# underlining
less_termcap[us]="${fg_bold[green]}"
less_termcap[ue]="${reset_color}"
# Handle $0 according to the standard:
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
# Absolute path to this file's directory.
typeset -g __colored_man_pages_dir="${0:A:h}"
function colored() {
local -a environment
# Convert associative array to plain array of NAME=VALUE items.
local k v
for k v in "${(@kv)less_termcap}"; do
environment+=( "LESS_TERMCAP_${k}=${v}" )
done
# Prefer `less` whenever available, since we specifically configured
# environment for it.
environment+=( PAGER="${commands[less]:-$PAGER}" )
environment+=( GROFF_NO_SGR=1 )
# See ./nroff script.
if [[ "$OSTYPE" = solaris* ]]; then
environment+=( PATH="${__colored_man_pages_dir}:$PATH" )
fi
command env $environment "$@"
}
# Colorize man and dman/debman (from debian-goodies)
function man \
dman \
debman {
colored $0 "$@"
}

View File

@@ -0,0 +1,70 @@
## Platforms with a built-in command-not-found handler init file
for file (
# Arch Linux. Must have pkgfile installed: https://wiki.archlinux.org/index.php/Pkgfile#Command_not_found
/usr/share/doc/pkgfile/command-not-found.zsh
# Homebrew: https://github.com/Homebrew/homebrew-command-not-found
/opt/homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh
/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh
); do
if [[ -r "$file" ]]; then
source "$file"
unset file
return 0
fi
done
unset file
## Platforms with manual command_not_found_handler() setup
# Debian and derivatives: https://launchpad.net/ubuntu/+source/command-not-found
if [[ -x /usr/lib/command-not-found || -x /usr/share/command-not-found/command-not-found ]]; then
command_not_found_handler() {
if [[ -x /usr/lib/command-not-found ]]; then
/usr/lib/command-not-found -- "$1"
return $?
elif [[ -x /usr/share/command-not-found/command-not-found ]]; then
/usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "zsh: command not found: %s\n" "$1" >&2
return 127
fi
}
fi
# Fedora: https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound
if [[ -x /usr/libexec/pk-command-not-found ]]; then
command_not_found_handler() {
if [[ -S /var/run/dbus/system_bus_socket && -x /usr/libexec/packagekitd ]]; then
/usr/libexec/pk-command-not-found "$@"
return $?
fi
printf "zsh: command not found: %s\n" "$1" >&2
return 127
}
fi
# NixOS: https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found
if [[ -x /run/current-system/sw/bin/command-not-found ]]; then
command_not_found_handler() {
/run/current-system/sw/bin/command-not-found "$@"
}
fi
# Termux: https://github.com/termux/command-not-found
if [[ -x /data/data/com.termux/files/usr/libexec/termux/command-not-found ]]; then
command_not_found_handler() {
/data/data/com.termux/files/usr/libexec/termux/command-not-found "$1"
}
fi
# SUSE and derivates: https://www.unix.com/man-page/suse/1/command-not-found/
if [[ -x /usr/bin/command-not-found ]]; then
command_not_found_handler() {
/usr/bin/command-not-found "$1"
}
fi

View File

@@ -0,0 +1,27 @@
# TODO: 2024-01-03 remove rtx support
local __mise=mise
if (( ! $+commands[mise] )); then
if (( $+commands[rtx] )); then
__mise=rtx
else
return
fi
fi
# Load mise hooks
eval "$($__mise activate zsh)"
# Hook mise into current environment
eval "$($__mise hook-env -s zsh)"
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `mise`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_$__mise" ]]; then
typeset -g -A _comps
autoload -Uz _$__mise
_comps[$__mise]=_$__mise
fi
# Generate and load mise completion
$__mise completion zsh >| "$ZSH_CACHE_DIR/completions/_$__mise" &|
unset __mise

View File

@@ -0,0 +1,5 @@
if (( $+commands[zoxide] )); then
eval "$(zoxide init --cmd ${ZOXIDE_CMD_OVERRIDE:-z} zsh)"
else
echo '[oh-my-zsh] zoxide not found, please install it from https://github.com/ajeetdsouza/zoxide'
fi

View File

@@ -1,13 +1,28 @@
# 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
export DOTFILES="$HOME/.dotfiles" export DOTFILES="$HOME/.dotfiles"
export MANPAGER="nvim +Man!"
export EDITOR=nvim export EDITOR=nvim
export HELPDIR=/usr/share/zsh/"${ZSH_VERSION}"/help export HELPDIR=/usr/share/zsh/"${ZSH_VERSION}"/help
export MISE_HOME=$HOME/.local/share/mise/installs export MISE_HOME=$HOME/.local/share/mise/installs
export MANPAGER="less -R --use-color -Dd+r -Du+b" # colored man pages
# colored less + termcap vars
export LESS="R --use-color -Dd+r -Du+b"
export LESS_TERMCAP_mb="$(printf '%b' '[1;31m')"
export LESS_TERMCAP_md="$(printf '%b' '[1;36m')"
export LESS_TERMCAP_me="$(printf '%b' '[0m')"
export LESS_TERMCAP_so="$(printf '%b' '[01;44;33m')"
export LESS_TERMCAP_se="$(printf '%b' '[0m')"
export LESS_TERMCAP_us="$(printf '%b' '[1;32m')"
export LESS_TERMCAP_ue="$(printf '%b' '[0m')"
# fzf # fzf
export FZF_DEFAULT_COMMAND="fd --hidden --type file --strip-cwd-prefix --exclude .git" export FZF_DEFAULT_COMMAND="fdfind --hidden --type file --strip-cwd-prefix --exclude .git"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="fd --hidden --type directory --strip-cwd-prefix --exclude .git" export FZF_ALT_C_COMMAND="fdfind --hidden --type directory --strip-cwd-prefix --exclude .git"
# Export Catppuccin Mocha theme for FZF # Export Catppuccin Mocha theme for FZF
export FZF_DEFAULT_OPTS=" \ export FZF_DEFAULT_OPTS=" \
--height 60% --layout=reverse --border \ --height 60% --layout=reverse --border \
@@ -17,8 +32,6 @@ export FZF_DEFAULT_OPTS=" \
--color=selected-bg:#45475A \ --color=selected-bg:#45475A \
--color=border:#313244,label:#CDD6F4" --color=border:#313244,label:#CDD6F4"
export FZF_TMUX_OPTS=" -p90%,70%" export FZF_TMUX_OPTS=" -p90%,70%"
export FZF_CTRL_T_OPTS="--preview 'bat --color=always -n --line-range :500 {}'"
export FZF_ALT_C_OPTS="--preview 'eza --tree --color=always {} | head -200'"
# Golang # Golang
if command -v go >/dev/null 2>&1; then if command -v go >/dev/null 2>&1; then
@@ -31,10 +44,6 @@ if command -v java >/dev/null 2>&1; then
export JAVA_HOME="$(dirname $(mise bin-paths | grep -i java))" export JAVA_HOME="$(dirname $(mise bin-paths | grep -i java))"
fi fi
if command -v jmeter >/dev/null 2>&1; then
export JMETER_HOME="$(which jmeter)"
fi
# Python # Python
export VIRTUAL_ENV_DISABLE_PROMPT=1 export VIRTUAL_ENV_DISABLE_PROMPT=1

View File

@@ -1,130 +1,103 @@
# If you come from bash you might have to change your $PATH. # main zsh settings. env in ~/.zprofile
# export PATH=$HOME/bin:/usr/local/bin:$PATH # read second
# Path to your oh-my-zsh installation. export ZSH_HOME="$HOME/.zsh"
export ZSH="$HOME/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
# ZSH_THEME="robbyrussell"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment one of the following lines to change the auto-update behavior
# zstyle ':omz:update' mode disabled # disable automatic updates
# zstyle ':omz:update' mode auto # update automatically without asking
# zstyle ':omz:update' mode reminder # just remind me to update when it's time
# Uncomment the following line to change how often to auto-update (in days).
# zstyle ':omz:update' frequency 13
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
ZSH_CUSTOM=$ZSH/custom
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
aws
colored-man-pages
command-not-found
gitignore
mise
zoxide
zsh-autosuggestions
zsh-interactive-cd
zsh-navigation-tools
zsh-syntax-highlighting
)
source $ZSH/oh-my-zsh.sh
# User configuration
# source global shell alias & variables files
[[ ! -f ~/.zshenv ]] || source ~/.zshenv [[ ! -f ~/.zshenv ]] || source ~/.zshenv
# export MANPATH="/usr/local/man:$MANPATH" # load modules
zmodload zsh/complist
autoload -U compinit && compinit
autoload -U colors && colors
# autoload -U tetris # main attraction of zsh, obviously
# You may need to manually set your language environment # cmp opts
# export LANG=en_US.UTF-8 zstyle ':completion:*' menu select # tab opens cmp menu
zstyle ':completion:*' special-dirs true # force . and .. to show in cmp menu
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} ma=0\;33 # colorize cmp menu
# zstyle ':completion:*' file-list true # more detailed list
zstyle ':completion:*' squeeze-slashes false # explicit disable to allow /*/ expansion
# Preferred editor for local and remote sessions # main opts
# if [[ -n $SSH_CONNECTION ]]; then setopt append_history inc_append_history share_history # better history
# export EDITOR='vim' # on exit, history appends rather than overwrites; history is appended as soon as cmds executed; history shared across sessions
# else setopt auto_menu menu_complete # autocmp first menu match
# export EDITOR='mvim' setopt autocd # type a dir to cd
# fi setopt auto_param_slash # when a dir is completed, add a / instead of a trailing space
setopt no_case_glob no_case_match # make cmp case insensitive
setopt globdots # include dotfiles
setopt extended_glob # match ~ # ^
setopt interactive_comments # allow comments in shell
unsetopt prompt_sp # don't autoclean blanklines
stty stop undef # disable accidental ctrl s
# Compilation flags # history opts
# export ARCHFLAGS="-arch x86_64" HISTSIZE=1000000
SAVEHIST=1000000
# Set personal aliases, overriding those provided by oh-my-zsh libs, # HISTFILE="$XDG_CACHE_HOME/zsh_history" # move histfile to cache
# plugins, and themes. Aliases can be placed here, though oh-my-zsh HISTCONTROL=ignoreboth # consecutive duplicates & commands starting with space are not saved
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# Setup emacs keymap
bindkey -e
fpath=(~/.zsh $fpath) fpath=(~/.zsh $fpath)
autoload run-help autoload run-help
autoload -Uz compinit && compinit -u
if command -v starship > /dev/null 2>&1; then # fzf setup
# Initialize Starship source <(fzf --zsh) # allow for fzf history widget
eval "$(starship init zsh)"
fi # binds
bindkey "^a" beginning-of-line
bindkey "^e" end-of-line
bindkey "^k" kill-line
bindkey "^j" backward-word
bindkey "^k" forward-word
bindkey "^H" backward-kill-word
# ctrl J & K for going up and down in prev commands
bindkey "^J" history-search-forward
bindkey "^K" history-search-backward
bindkey '^R' fzf-history-widget
# set up prompt
NEWLINE=$'\n'
PROMPT='%F{blue}%B%~%b%f %F{green}%f '
# load plugins
ZSH_PLUGINS_DIR="$ZSH_HOME/plugins"
[ -e "$ZSH_PLUGINS_DIR/colored-man-pages.plugin.zsh" ] && source "$ZSH_PLUGINS_DIR/colored-man-pages.plugin.zsh"
[ -e "$ZSH_PLUGINS_DIR/command-not-found-plugin.zsh" ] && source "$ZSH_PLUGINS_DIR/command-not-found-plugin.zsh"
[ -e "$ZSH_PLUGINS_DIR/mise.plugin.zsh" ] && source "$ZSH_PLUGINS_DIR/mise.plugin.zsh"
[ -e "$ZSH_PLUGINS_DIR/zoxide.plugin.zsh" ] && source "$ZSH_PLUGINS_DIR/zoxide.plugin.zsh"
[ -e "$ZSH_PLUGINS_DIR/fzf-git.sh" ] && source "$ZSH_PLUGINS_DIR/fzf-git.sh"
[ -e "$ZSH_PLUGINS_DIR/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ] && source "$ZSH_PLUGINS_DIR/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
[ -e "$ZSH_PLUGINS_DIR/zsh-autosuggestions/zsh-autosuggestions.zsh" ] && source "$ZSH_PLUGINS_DIR/zsh-autosuggestions/zsh-autosuggestions.zsh"
# define user aliases
pbcopy() {
if [ -f "$1" ]; then
mime_type=$(file --mime-type -b "$1")
wl-copy --type "$mime_type" < "$1"
else
printf "%s" "$*" | wl-copy
fi
}
alias pbpaste='wl-paste --no-newline'
alias ls='ls --color=auto --group-directories-first'
# Replace Vim implementation
alias vi='nvim'
alias vim='nvim'
# Replace grep command tool
alias grep='grep --color=auto'
alias egrep='grep -E'
alias fgrep='grep -F'
# Other aliases
alias paths='echo -e ${PATH//:/\\n}' # path: Echo all executable Paths
alias userlist="cut -d: -f1 /etc/passwd | sort"
alias ip='ip -color'
alias stow='stow -d $DOTFILES '
case ":$PATH:" in case ":$PATH:" in
*":$HOME/.local/bin:"*) ;; *":$HOME/.local/bin:"*) ;;
@@ -135,8 +108,6 @@ if [ -e "$HOME/.cargo" ]; then
source "$HOME/.cargo/env" source "$HOME/.cargo/env"
fi fi
source <(fzf --zsh)
if command -v tmux &> /dev/null && [ -z "$TMUX" ]; then if command -v tmux &> /dev/null && [ -z "$TMUX" ]; then
tmux attach-session -t default || tmux new-session -s default tmux attach-session -t default || tmux new-session -s default
fi fi