diff --git a/020_zsh_quickstart.sh b/020_zsh_quickstart.sh index 4a1be58..502779d 100755 --- a/020_zsh_quickstart.sh +++ b/020_zsh_quickstart.sh @@ -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 <"${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 < /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 <"${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 <