From a9668b14ef8cad6be8d44729dd8b144285398520 Mon Sep 17 00:00:00 2001 From: Musselman Date: Thu, 25 Jul 2024 17:19:22 -0500 Subject: [PATCH 1/4] Add ZSH install option --- src/commands/install-zsh.sh | 59 +++++++++++++++++++++++++++++++++++++ src/list.rs | 4 +++ 2 files changed, 63 insertions(+) create mode 100644 src/commands/install-zsh.sh diff --git a/src/commands/install-zsh.sh b/src/commands/install-zsh.sh new file mode 100644 index 00000000..fc73fa9d --- /dev/null +++ b/src/commands/install-zsh.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +# Function to install zsh +install_zsh() { + if command -v apt-get >/dev/null 2>&1; then + sudo apt-get update + sudo apt-get install -y zsh + elif command -v yum >/dev/null 2>&1; then + sudo yum install -y zsh + elif command -v dnf >/dev/null 2>&1; then + sudo dnf install -y zsh + elif command -v pacman >/dev/null 2>&1; then + sudo pacman -Sy zsh + elif command -v zypper >/dev/null 2>&1; then + sudo zypper install -y zsh + else + echo "No compatible package manager found. Please install zsh manually." >&2 + exit 1 + fi +} + +# Function to setup zsh configuration +setup_zsh_config() { + CONFIG_DIR="$HOME/.config/zsh" + ZSHRC_FILE="$CONFIG_DIR/.zshrc" + + # Create config directory if it doesn't exist + mkdir -p "$CONFIG_DIR" + + # Write the configuration to .zshrc + cat <"$ZSHRC_FILE" +# Lines configured by zsh-newuser-install +HISTFILE=~/.config/zsh/.histfile +HISTSIZE=5000 +SAVEHIST=100000 +setopt autocd extendedglob +unsetopt beep +bindkey -v +# End of lines configured by zsh-newuser-install + +# Configure the prompt with embedded Solarized color codes +PROMPT='%F{32}%n%f%F{166}@%f%F{64}%m:%F{166}%~%f%F{15}$%f ' +RPROMPT='%F{15}(%F{166}%D{%H:%M}%F{15})%f' +EOL + + # Ensure /etc/zsh/zshenv sets ZDOTDIR to the user's config directory + echo 'export ZDOTDIR="$HOME/.config/zsh"' | sudo tee -a /etc/zsh/zshenv +} + +# Execute the installation and setup +install_zsh + +if [ $? -eq 0 ]; then + echo "zsh installed successfully." + setup_zsh_config +else + echo "zsh installation failed." + exit 1 +fi diff --git a/src/list.rs b/src/list.rs index b564bdea..3536133e 100644 --- a/src/list.rs +++ b/src/list.rs @@ -74,6 +74,10 @@ impl CustomList { name: "Setup Neovim", command: "bash -c \"$(curl -s https://raw.githubusercontent.com/ChrisTitusTech/neovim/main/setup.sh)\"" }, + ListNode { + name: "Setup Zsh and Prompt", + command: with_common_script!("commands/install-zsh.sh"), + }, // ListNode { // name: "Just ls, nothing special, trust me", // command: include_str!("commands/special_ls.sh"), From 5319634a57930b6595ceeec19e4aec5cc687df0d Mon Sep 17 00:00:00 2001 From: Musselman Date: Tue, 30 Jul 2024 15:56:34 -0500 Subject: [PATCH 2/4] Update install command to use -Syu --- src/commands/install-zsh.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/install-zsh.sh b/src/commands/install-zsh.sh index fc73fa9d..f1aee319 100644 --- a/src/commands/install-zsh.sh +++ b/src/commands/install-zsh.sh @@ -10,7 +10,7 @@ install_zsh() { elif command -v dnf >/dev/null 2>&1; then sudo dnf install -y zsh elif command -v pacman >/dev/null 2>&1; then - sudo pacman -Sy zsh + sudo pacman -Syu zsh elif command -v zypper >/dev/null 2>&1; then sudo zypper install -y zsh else From 3b9f759f08d716f2d86ba9c2c32a7f6e41205cf0 Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Thu, 8 Aug 2024 15:58:07 -0500 Subject: [PATCH 3/4] update pacman install --- src/commands/applications-setup/zsh-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/applications-setup/zsh-setup.sh b/src/commands/applications-setup/zsh-setup.sh index 8ee68351..c7a7ea9e 100644 --- a/src/commands/applications-setup/zsh-setup.sh +++ b/src/commands/applications-setup/zsh-setup.sh @@ -8,7 +8,7 @@ install_zsh() { if ! command_exists zsh; then case "$PACKAGER" in pacman) - sudo "$PACKAGER" -S --noconfirm zsh + sudo "$PACKAGER" -Sy --noconfirm zsh ;; *) sudo "$PACKAGER" install -y zsh From 62ee1d8661f6f835b59289c4835e537ca0a4e5f7 Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Thu, 8 Aug 2024 16:01:04 -0500 Subject: [PATCH 4/4] fix whitespace in fmt --- src/list.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/list.rs b/src/list.rs index 8574bd32..0a0b1216 100644 --- a/src/list.rs +++ b/src/list.rs @@ -116,7 +116,7 @@ impl CustomList { name: "ZSH Prompt", command: Command::LocalFile("applications-setup/zsh-setup.sh"), } - + }, ListNode { name: "Full System Update",