Undated, cleanup, rationalize and change theme engine to powerline-go.

This commit is contained in:
cyteen 2026-03-11 01:47:52 +00:00
parent 60e606d4b5
commit fe51ae96b8
1 changed files with 225 additions and 64 deletions

View File

@ -1,27 +1,10 @@
#!/usr/bin/env bash
set -x
#set -Eeu -o -pipefail
## Completions for Debian 9.0 - may be included in zgen
# files included from .zshrc
# ~/.zsh-completions
# directories included from .zshrc
# ~/.zshrc.pre-plugins.d
# ~/.zsh-completions.d
# ~/.zshrc.d
# ~/.macos_aliases.d
# ~/.osx_aliases.d
#
#sudo bash -c "cat > /etc/apt/sources.list.d/shells:zsh-users:zsh-completions.list" << 'EOF'
#deb http://download.opensuse.org/repositories/shells:/zsh-users:/zsh-completions/Debian_9.0/ /
#EOF
#
# KEY_DIR=/etc/apt/keyrings
#wget -qO - https://download.opensuse.org/repositories/shells:zsh-users:zsh-completions/Debian_9.0/Release.key | sudo tee ${KEY_DIR}/zsh-completions.gpg
#
#sudo apt update
#sudo apt install zsh-completions
set -Eeu -o -pipefail
sudo apt install -y zsh nodejs zsh-theme-powerlevel9k git fonts-powerline powerline fzf golang-chroma python3-argcomplete
# ND Do not put alias files in the script they are now in their own 020_script.
sudo apt install -y zsh nodejs fzf chroma powerline-go
# compaudit
# There are insecure directories: /usr/local/share/zsh/site-functions
@ -37,48 +20,42 @@ HOME="${DEST}"
# KEY_DIR=/etc/apt/keyrings
ALIAS_DIR=".zshrc.d"
cd "${DEST}" || exit
cp /var/tmp/automate/.p10k.zsh "${DEST}"
chsh -s "$(which zsh)" "${USER}"
# Install zgenom plugin manager and zsh quickstart to get a default setup for zsh
# .zgen-setup pulls zgenom automatically and puts it in .zqs-zgenom, plugins in .zgenom
git clone https://github.com/unixorn/zsh-quickstart-kit "${DEST}"/zsh-quickstart-kit
if [ ! -d "${DEST}/zsh-quickstart-kit" ]; then
git clone https://github.com/unixorn/zsh-quickstart-kit "${DEST}"/zsh-quickstart-kit
else
echo "Quickstart kit already exists, skipping clone..."
fi
ln -rsf "${DEST}"/zsh-quickstart-kit/zsh/.zshrc "${DEST}"/.zshrc
ln -rsf "${DEST}"/zsh-quickstart-kit/zsh/.zsh_functions "${DEST}"/.zsh_functions
#ln -rsf "${DEST}"/zsh-quickstart-kit/zsh/.zsh_aliases "${DEST}"/.zsh_aliases
ln -rsf "${DEST}"/zsh-quickstart-kit/zsh/.zgen-setup "${DEST}"/.zgen-setup
#ln -rsf ~/zsh-quickstart-kit/zsh/.zsh_completions ~/.zsh_completions
mkdir -p "${DEST}"/"${ALIAS_DIR}"
ln -rsf "${DEST}"/zsh-quickstart-kit/zsh/.zshrc "${DEST}/.zshrc"
ln -rsf "${DEST}"/zsh-quickstart-kit/zsh/.zsh_functions "${DEST}/.zsh_functions"
ln -rsf "${DEST}"/zsh-quickstart-kit/zsh/.zgen-setup "${DEST}/.zgen-setup"
mkdir -p "${DEST}/${ALIAS_DIR}"
touch "${DEST}"/.zshrc
echo "setopt PROMPT_SUBST" >>"${DEST}"/.zshrc
echo "NVIM_PYTHON_LOG_FILE=/var/tmp/nvim_python.log" >>"${DEST}"/"${ALIAS_DIR}"/008_nvim.zsh
echo "NVIM_PYTHON_LOG_LEVEL=DEBUG" >>"${DEST}"/"${ALIAS_DIR}"/008_nvim.zsh
echo "NVIM_PYTHON_LOG_FILE=/var/tmp/nvim_python.log" >>"${DEST}/${ALIAS_DIR}/008_nvim.zsh"
echo "NVIM_PYTHON_LOG_LEVEL=DEBUG" >>"${DEST}/${ALIAS_DIR}/008_nvim.zsh"
sudo touch /var/tmp/nvim_python.log
# fix path error in .zshrc
#sed -i 's|pushd $(dirname "${HOME}/$(readlink "${DEST}"/.zshrc)")|pushd $(dirname "$(readlink "${DEST}"/.zshrc)")|' "${DEST}"/zsh-quickstart-kit/zsh/.zshrc
# debians locate db locate
# sed -i 's,^\(export LOCATE_PATH=\).*,\1'/var/lib/mlocate/mlocate.db',' "${DEST}"/.zshrc
echo "export LOCATE_PATH=/var/lib/mlocate/mlocate.db" >"${DEST}"/"${ALIAS_DIR}"/005_locatedb.zsh
echo "export LOCATE_PATH=/var/lib/mlocate/mlocate.db" >"${DEST}/${ALIAS_DIR}/005_locatedb.zsh"
# add plugins to the load-starter-plugin-list() function in ~/.zgen-setup ~/zsh-quickstart-kit/zsh/.zgen-setup
# FIXED: create a file named .zgen-local-plugins and add your zgenom load commands there.
# Create a file named .zgen-local-plugins and add your zgenom load commands there.
# Don't forget to run `zgenom save` at the end of your .zgen-local-plugins file.
# Warning: .zgen-local-plugins REPLACES the starter list setup, it doesn't add to it.
# Comment out default docker plugin and replace with omz docker and compose plugins
sed -i -e "s|zgenom load srijanshetty/docker-zsh|# zgenom load srijanshetty/docker-zsh|" "${DEST}"/zsh-quickstart-kit/zsh/.zgen-setup
sed -i -e "s|zgenom load srijanshetty/docker-zsh|# zgenom load srijanshetty/docker-zsh|" "${DEST}/zsh-quickstart-kit/zsh/.zgen-setup"
#sed -i '/\# zgenom load srijanshetty\/docker-zsh/a\ \ zgenom load ohmyzsh plugins\/docker\n\ \ zgenom load ohmyzsh plugins\/docker-compose' "${DEST}"/zsh-quickstart-kit/zsh/.zgen-setup
conf_print_fzf() {
cat <<'EOF'
# zsh quickstart created this file if missing expecting fzf to be installed in ${HOME}
# we have it installed via apt so the executables are in the path and the key-bindings
# and completitions are in examples fom the package.
cat <<-EOF | tee "${DEST}/.fzf.zsh"
# Setup fzf
# ---------
#if [[ ! "\$PATH" == *\${HOME}/.vim/bundle/fzf/bin/* ]]; then
@ -93,9 +70,12 @@ cat <<-EOF | tee "${DEST}/.fzf.zsh"
# ------------
source "/usr/share/doc/fzf/examples/key-bindings.zsh"
EOF
}
conf_print_fzf | tee "${DEST}/.fzf.zsh"
# The contents of the starter plugin function with changes above, pulling from upstream git with now not squash local changes.
cat <<-EOF | tee "${DEST}"/.zgen-local-plugins
conf_print_local_plugins() {
cat <<EOF
echo "creating a zgen save"
ZGEN_LOADED=()
ZGEN_COMPLETIONS=()
@ -131,6 +111,9 @@ cat <<-EOF | tee "${DEST}"/.zgen-local-plugins
# Colorize the things if you have grc installed. Well, some of the
# things, anyway.
zgenom load unixorn/warhol.plugin.zsh
#
# Auto-pair brackets etc (very lightweight)
zgenom load hlissner/zsh-autopair
# OS X helpers
zgenom load unixorn/tumult.plugin.zsh
@ -216,9 +199,9 @@ cat <<-EOF | tee "${DEST}"/.zgen-local-plugins
# zgenom load bckim92/zsh-autoswitch-conda
# Add functional testing for zsh
zgenom load molovo/revolver
zgenom load olets/zsh-test-runner
zgenom load zunit-zsh/zunit
# zgenom load molovo/revolver
# zgenom load olets/zsh-test-runner
# zgenom load zunit-zsh/zunit
# IDE-like type-ahead completion for Zsh, asynchronous/non-blocking
#zgenom load marlonrichert/zsh-autocomplete
@ -229,7 +212,8 @@ cat <<-EOF | tee "${DEST}"/.zgen-local-plugins
# Bullet train prompt setup
#zgenom load caiogondim/bullet-train-ohmyzsh-theme bullet-train
zgenom load robbyrussell/oh-my-zsh themes/agnoster
#zgenom load robbyrussell/oh-my-zsh themes/agnoster
zgenom load oh-my-zsh themes/agnoster
## Load Prezto
# zgen prezto
@ -259,19 +243,29 @@ cat <<-EOF | tee "${DEST}"/.zgen-local-plugins
# Save it all to init script
zgenom save
EOF
}
conf_print_local_plugins | tee "${DEST}/.zgen-local-plugins"
# -- Additions to .zshrc.d --
# Dedup path
cat <<-EOF | tee "${DEST}/${ALIAS_DIR}/zzz_dedup_path.zsh"
conf_print_dedup() {
cat <<-EOF
# Dedup the path, auto installers help themselves to you config files.'
typeset -U path
typeset -U PATH path
EOF
}
conf_print_dedup | tee "${DEST}/${ALIAS_DIR}/zzz_dedup_path.zsh"
# Uopdates for omz, quickstart and zgenom all gets a bit much.
# prevent update
cat <<-EOF | tee "${DEST}/${ALIAS_DIR}/001_quickstart-refresh.zsh"
conf_print_qs_refresh() {
cat <<-EOF
# Use unset 'QUICKSTART_KIT_REFRESH_IN_DAYS' to disable.'
# QUICKSTART_KIT_REFRESH_IN_DAYS=0'
unset "QUICKSTART_KIT_REFRESH_IN_DAYS"
EOF
}
conf_print_qs_refresh | tee "${DEST}/${ALIAS_DIR}/001_quickstart-refresh.zsh"
#
echo '# zgenom autoupdate' >"${DEST}/${ALIAS_DIR}/001_zgenom-refresh.zsh"
@ -281,27 +275,162 @@ echo 'DISABLE_AUTO_UPDATE="true"' >"${DEST}/${ALIAS_DIR}/001_auto-update-off.zsh
# sed -i 's,^\(export LOCATE_PATH=\).*,\1'/var/lib/mlocate/mlocate.db',' ~/.zshrc
# Use powerline-daemon to speedup the prompt.
echo 'powerline-daemon -q' >"${DEST}/${ALIAS_DIR}/006_powerline-daemon.zsh"
# -- Theme --
#
#
# Replace with powerline-go Use powerline-daemon to speedup the prompt.
# echo 'powerline-daemon -q' >"${DEST}/${ALIAS_DIR}/006_powerline-daemon.zsh"
# conf_print_powerline_daemon() {
# cat <<EOF
# if ! pgrep -x "powerline-daemon" > /dev/null; then
# powerline-daemon -q
# fi
# EOF
# }
# conf_print_powerline_daemon | tee "${DEST}/${ALIAS_DIR}/006_powerline-daemon.zsh"
conf_print_powerline_go() {
cat <<'EOF'
# Powerline-go setup for Zsh
function powerline_precmd() {
# 1. Find the binary
local P_GO=$(command -v powerline-go || echo "$GOPATH/bin/powerline-go")
# 2. Check if it exists before running
if [[ ! -x "$P_GO" ]]; then
return
fi
# 3. Use -eval to let powerline-go handle PS1 and RPS1
# Note: We've merged your desired modules and path-aliases here
eval "$($P_GO \
-error $? \
-shell zsh \
-eval \
-modules "user,host,ssh,cwd,perms,git,venv,aws,duration,exit,newline" \
--cwd-max-depth 3 \
--cwd-max-dir-size 7 \
-theme ${HOME}/.config/powerline-go/catppuccin-mocha.json)"
}
function install_powerline_precmd() {
for s in "${precmd_functions[@]}"; do
if [ "$s" = "powerline_precmd" ]; then
return
fi
done
precmd_functions+=(powerline_precmd)
}
# Avoid loading in basic linux TTY to prevent broken glyphs
if [ "$TERM" != "linux" ]; then
install_powerline_precmd
fi
EOF
}
conf_print_powerline_go | tee "${DEST}/${ALIAS_DIR}/006_powerline-go.zsh"
mkdir -p "${DEST}/.config/powerline-go"
conf_print_powerline_go_theme() {
cat <<EOF
{
"BoldForeground": false,
"Reset": 0,
"UsernameFg": 189,
"UsernameBg": 60,
"UsernameRootBg": 161,
"HostnameFg": 189,
"HostnameBg": 60,
"HomeSpecialDisplay": true,
"HomeFg": 231,
"HomeBg": 111,
"PathFg": 189,
"PathBg": 237,
"CwdFg": 231,
"SeparatorFg": 240,
"ReadonlyFg": 161,
"ReadonlyBg": 235,
"SshFg": 231,
"SshBg": 173,
"RepoCleanFg": 16,
"RepoCleanBg": 114,
"RepoDirtyFg": 231,
"RepoDirtyBg": 161,
"GitAheadFg": 231,
"GitAheadBg": 60,
"GitBehindFg": 231,
"GitBehindBg": 60,
"GitStagedFg": 16,
"GitStagedBg": 114,
"GitNotStagedFg": 231,
"GitNotStagedBg": 173,
"GitUntrackedFg": 231,
"GitUntrackedBg": 180,
"GitConflictedFg": 231,
"GitConflictedBg": 161,
"VirtualEnvFg": 16,
"VirtualEnvBg": 180,
"TimeFg": 189,
"TimeBg": 236,
"DurationFg": 189,
"DurationBg": 237,
"CmdPassedFg": 114,
"CmdPassedBg": 236,
"CmdFailedFg": 161,
"CmdFailedBg": 236
}
EOF
}
conf_print_powerline_go_theme | tee "${DEST}/.config/powerline-go/catppuccin-mocha.json"
conf_print_ls_colors() {
cat <<'EOF'
# Catppuccin Mocha LS_COLORS
# This sets colors for both GNU ls and entries in zsh completion
# Base colors
export LS_COLORS="di=34:ln=36:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;44:"
# Archives (Lavender)
export LS_COLORS=$LS_COLORS"*.tar=35:*.tgz=35:*.arc=35:*.zip=35:*.z=35:*.Z=35:*.gz=35:*.bz2=35:*.bz=35:*.tz=35:*.rpm=35:*.deb=35:"
# Images (Teal)
export LS_COLORS=$LS_COLORS"*.jpg=36:*.jpeg=36:*.gif=36:*.bmp=36:*.tga=36:*.svg=36:*.png=36:*.webp=36:"
# Media (Maroon)
export LS_COLORS=$LS_COLORS"*.mp4=31:*.mkv=31:*.mp3=31:*.wav=31:*.flac=31:"
alias ls='ls --color=auto'
# Sync Zsh completions with LS_COLORS
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
EOF
}
conf_print_ls_colors | tee "${DEST}/${ALIAS_DIR}/002_ls_colors.zsh"
# -- End Theme --
sudo sed -i 's,^\(CHARMAP=\).*,\1'\"UTF-8\"',' /etc/default/console-setup
# set theme for zsh
cat <<-EOF | tee "${DEST}/${ALIAS_DIR}/002_theme.zsh"
# Removed infavor of powerline-go | set theme for oh-my-zsh
conf_print_theme() {
cat <<-EOF
# https://zshthem.es/browse-zsh-themes/
ZSH_THEME="agnoster" # powerline based theme
#ZSH_THEME="3den"
#ZSH_THEME="Pure"
EOF
}
# conf_print_theme | tee "${DEST}/${ALIAS_DIR}/002_theme.zsh"
# set colorize tool
cat <<-EOF | tee "${DEST}/${ALIAS_DIR}/003_colorize.zsh"
conf_print_coloize() {
cat <<-EOF
ZSH_COLORIZE_TOOL="chroma"
ZSH_COLORIZE_CHROMA_FORMATTER=terminal256
EOF
}
conf_print_coloize | tee "${DEST}/${ALIAS_DIR}/003_colorize.zsh"
# see also ZVM jeffreytse/zsh-vi-mode plugin
cat <<-'EOF' | tee "${DEST}/${ALIAS_DIR}/001_vi-mode.sh"
conf_print_vi_mode() {
cat <<-'EOF'
# Set vi mode
bindkey -v
bindkey '^R' history-incremental-search-backward
@ -339,12 +468,14 @@ cat <<-'EOF' | tee "${DEST}/${ALIAS_DIR}/001_vi-mode.sh"
ZVM_NORMAL_MODE_CURSOR=$ZVM_CURSOR_BLOCK
ZVM_OPPEND_MODE_CURSOR=$ZVM_CURSOR_UNDERLINE
EOF
}
conf_print_vi_mode | tee "${DEST}/${ALIAS_DIR}/001_vi-mode.sh"
#git clone http://github.com/bhilburn/powerlevel9k.git "${DEST}"/.zgen/robbyrussell/ohmyzsh-master/themes/powerlevel9k
## add a separate zsh aliases directory
cat <<'EOF' | tee "${DEST}/${ALIAS_DIR}/000_enable-aliases-directory.zsh"
conf_print_enable_alias_dir() {
cat <<EOF
# Enable ${ALIAS_DIR} to keep aliases separate from env variables
if [ -d ~/.zsh_aliases.d ]; then
for f in ~/.zsh_aliases.d/**/*.zsh(N); do
@ -352,20 +483,41 @@ if [ -d ~/.zsh_aliases.d ]; then
done
fi
EOF
}
conf_print_enable_alias_dir | tee "${DEST}/${ALIAS_DIR}/000_enable-aliases-directory.zsh"
ALIASES_HOME=".zsh_aliases.d"
mkdir -p "${DEST}/${ALIASES_HOME}"
# Override EDITOR and VISUAL set be quickstart in its:
# zsh-quickstart-kit/zsh/.zsh_aliases
conf_print_editor() {
cat <<'EOF'
if [ -x /usr/bin/nvim ]; then
alias vi="/usr/bin/nvim"
alias vim="/usr/bin/nvim"
export EDITOR="/usr/bin/nvim"
fi
if [ -x "$(command -v neovide)" ]; then
VISUAL=$(command -v neovide)
export VISUAL
fi
EOF
}
conf_print_editor | tee "${DEST}/${ALIASES_HOME}/001_editor.zsh"
# Set the path to the pipx bin directory
cat <<'EOF' | tee "${DEST}/${ALIAS_DIR}/001_pipx-path.zsh"
export PATH="$PATH:$HOME/.local/bin"
EOF
# tell bash to check the next word after the alias (i.e sudo) by adding a space to the end of the alias value.
echo "# tell bash to check the next word after the alias (i.e sudo) by adding a space to the end of the alias value." >"${DEST}"/"${ALIAS_DIR}"/002_sudo.zsh
echo 'alias sudo="sudo "' >>"${DEST}/${ALIAS_DIR}/002_sudo.zsh"
echo "# tell bash to check the next word after the alias (i.e sudo) by adding a space to the end of the alias value." >"${DEST}/${ALIAS_DIR}/002_sudo.zsh"
echo 'alias sudo="sudo "' >>"${DEST}/${ALIASES_HOME}/002_sudo.zsh"
cat <<-EOF | tee "${DEST}/${ALIAS_DIR}/003_py_aliases.zsh"
conf_print_py_aliases() {
cat <<EOF
_py_version() {
PY_VERSIONS=(2 3)
@ -401,9 +553,13 @@ cat <<-EOF | tee "${DEST}/${ALIAS_DIR}/003_py_aliases.zsh"
# alias ipython="_py_version"
# alias jupyter="_py_version"
EOF
}
conf_print_py_aliases | tee "${DEST}/${ALIASES_HOME}/003_py_aliases.zsh"
mkdir -p "${DEST}/${ALIAS_DIR}/"
cat <<-EOF | tee "${DEST}/${ALIAS_DIR}/003_transfer.zsh"
conf_print_transfer() {
cat <<EOF
#
# Defines transfer alias and provides easy command line file and folder sharing.
#
@ -471,11 +627,16 @@ cat <<-EOF | tee "${DEST}/${ALIAS_DIR}/003_transfer.zsh"
rm -f \$tmpfile
}
EOF
}
conf_print_transfer | tee "${DEST}/${ALIAS_DIR}/003_transfer.zsh"
cat <<EOF | tee "${DEST}/${ALIAS_DIR}/002_nvm.zsh"
conf_print_nvm() {
cat <<EOF
plugins+=(nvm)
zstyle ':omz:plugins:nvm' lazy yes
EOF
}
conf_print_nvm | tee "${DEST}/${ALIAS_DIR}/002_nvm.zsh"
# https://github.com/catppuccin/fzf/blob/main/themes/catppuccin-fzf-mocha.sh
conf_print_fzf_colors() {