✨ (.zshrc, install.sh): add Homebrew initialization and eza installation logic for multiple OSes
This commit is contained in:
13
.zshrc
13
.zshrc
@@ -1,3 +1,8 @@
|
||||
# Homebrew initialization
|
||||
if [ -d '/opt/homebrew' ]; then
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
fi
|
||||
|
||||
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
|
||||
# Initialization code that may require console input (password prompts, [y/n]
|
||||
# confirmations, etc.) must go above this block; everything else may go below.
|
||||
@@ -137,6 +142,12 @@ plugins=(
|
||||
|
||||
|
||||
fpath+=$ZSH/custom/plugins/zsh-completions/src
|
||||
|
||||
# Setup Homebrew completions for macOS
|
||||
if [[ "$OSTYPE" == "darwin"* ]] && command -v brew &> /dev/null; then
|
||||
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
|
||||
fi
|
||||
|
||||
autoload -U compinit && compinit -C -d ~/.cache/zsh/.zcompdump # zsh-completions
|
||||
# autoload bashcompinit # bash completions
|
||||
# bashcompinit
|
||||
@@ -150,7 +161,7 @@ alias myip="wget -qO- https://wtfismyip.com/text" # quickly show external ip add
|
||||
alias l="ls --hyperlink=auto -lAhrtF" # show all except . .. , sort by recent, / at the end of folders, clickable
|
||||
alias e="exit"
|
||||
alias ip="ip --color=auto"
|
||||
## Install EZA to use this. The better ls command
|
||||
## EZA - the better ls command
|
||||
alias a='eza -la --git --colour-scale all -g --smart-group --icons always --hyperlink' # the new ls; add --hyperlink if you like
|
||||
alias aa='eza -la --git --colour-scale all -g --smart-group --icons always -s modified -r --hyperlink' # sort by new
|
||||
|
||||
|
||||
88
install.sh
88
install.sh
@@ -1,5 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Save the original working directory
|
||||
ORIGINAL_DIR="$(pwd)"
|
||||
|
||||
# Flags to determine if the arguments were passed
|
||||
cp_hist_flag=false
|
||||
noninteractive_flag=false
|
||||
@@ -48,35 +51,91 @@ install_packages() {
|
||||
echo "Homebrew is not installed. Installing Homebrew..."
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
fi
|
||||
brew install zsh git wget fontconfig
|
||||
brew install zsh git wget fontconfig eza
|
||||
;;
|
||||
ubuntu|debian)
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y zsh git wget fontconfig
|
||||
|
||||
# Install eza if not already installed
|
||||
if ! command -v eza &> /dev/null; then
|
||||
echo "Installing eza..."
|
||||
# Install GPG if not present
|
||||
if ! command -v gpg &> /dev/null; then
|
||||
sudo apt install -y gpg
|
||||
fi
|
||||
|
||||
# Add eza repository and install
|
||||
sudo mkdir -p /etc/apt/keyrings
|
||||
wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo gpg --dearmor -o /etc/apt/keyrings/gierens.gpg
|
||||
echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list
|
||||
sudo chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list
|
||||
sudo apt update
|
||||
sudo apt install -y eza
|
||||
fi
|
||||
;;
|
||||
fedora)
|
||||
sudo dnf install -y zsh git wget fontconfig
|
||||
|
||||
# Install eza if not already installed
|
||||
if ! command -v eza &> /dev/null; then
|
||||
echo "Installing eza..."
|
||||
# For Fedora versions prior to 42
|
||||
if ! sudo dnf install -y eza; then
|
||||
echo "eza not available in official repository, installing from cargo..."
|
||||
if command -v cargo &> /dev/null; then
|
||||
cargo install eza
|
||||
else
|
||||
echo "cargo not found. Please install Rust/cargo first or install eza manually."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
centos|rhel)
|
||||
sudo yum install -y zsh git wget fontconfig
|
||||
|
||||
# Install eza if not already installed
|
||||
if ! command -v eza &> /dev/null; then
|
||||
echo "Installing eza..."
|
||||
# Install from cargo as primary method
|
||||
if command -v cargo &> /dev/null; then
|
||||
cargo install eza
|
||||
else
|
||||
echo "cargo not found. Installing from binary..."
|
||||
wget -c https://github.com/eza-community/eza/releases/latest/download/eza_x86_64-unknown-linux-gnu.tar.gz -O - | tar xz
|
||||
sudo chmod +x eza
|
||||
sudo chown root:root eza
|
||||
sudo mv eza /usr/local/bin/eza
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
arch|manjaro)
|
||||
sudo pacman -Syu --noconfirm zsh git wget fontconfig
|
||||
sudo pacman -Syu --noconfirm zsh git wget fontconfig eza
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported operating system. Please install zsh, git, wget, and fontconfig manually."
|
||||
# Try to install eza from binary for unsupported systems
|
||||
if ! command -v eza &> /dev/null; then
|
||||
echo "Installing eza from binary..."
|
||||
wget -c https://github.com/eza-community/eza/releases/latest/download/eza_x86_64-unknown-linux-gnu.tar.gz -O - | tar xz
|
||||
sudo chmod +x eza
|
||||
sudo chown root:root eza
|
||||
sudo mv eza /usr/local/bin/eza
|
||||
fi
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Check if required packages are installed, if not, install them
|
||||
if command -v zsh &> /dev/null && command -v git &> /dev/null && command -v wget &> /dev/null && command -v fc-cache &> /dev/null; then
|
||||
echo -e "ZSH, Git, wget, and fontconfig are already installed\n"
|
||||
if command -v zsh &> /dev/null && command -v git &> /dev/null && command -v wget &> /dev/null && command -v fc-cache &> /dev/null && command -v eza &> /dev/null; then
|
||||
echo -e "ZSH, Git, wget, fontconfig, and eza are already installed\n"
|
||||
else
|
||||
echo "Installing required packages..."
|
||||
install_packages
|
||||
echo -e "zsh, wget, git, and fontconfig Installed\n"
|
||||
echo -e "zsh, wget, git, fontconfig, and eza Installed\n"
|
||||
fi
|
||||
|
||||
if [ -f ~/.gitconfig.backup ]; then
|
||||
@@ -128,25 +187,25 @@ if [ -f ~/.zcompdump ]; then
|
||||
fi
|
||||
|
||||
if [ -d $ZSH/plugins/zsh-autosuggestions ]; then
|
||||
cd $ZSH/plugins/zsh-autosuggestions && git pull
|
||||
git -C $ZSH/plugins/zsh-autosuggestions pull
|
||||
else
|
||||
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions $ZSH/plugins/zsh-autosuggestions
|
||||
fi
|
||||
|
||||
if [ -d $ZSH/custom/plugins/zsh-syntax-highlighting ]; then
|
||||
cd $ZSH/custom/plugins/zsh-syntax-highlighting && git pull
|
||||
git -C $ZSH/custom/plugins/zsh-syntax-highlighting pull
|
||||
else
|
||||
git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH/custom/plugins/zsh-syntax-highlighting
|
||||
fi
|
||||
|
||||
if [ -d $ZSH/custom/plugins/zsh-completions ]; then
|
||||
cd $ZSH/custom/plugins/zsh-completions && git pull
|
||||
git -C $ZSH/custom/plugins/zsh-completions pull
|
||||
else
|
||||
git clone --depth=1 https://github.com/zsh-users/zsh-completions $ZSH/custom/plugins/zsh-completions
|
||||
fi
|
||||
|
||||
if [ -d $ZSH/custom/plugins/zsh-history-substring-search ]; then
|
||||
cd $ZSH/custom/plugins/zsh-history-substring-search && git pull
|
||||
git -C $ZSH/custom/plugins/zsh-history-substring-search pull
|
||||
else
|
||||
git clone --depth=1 https://github.com/zsh-users/zsh-history-substring-search $ZSH/custom/plugins/zsh-history-substring-search
|
||||
fi
|
||||
@@ -163,14 +222,14 @@ wget -q --show-progress -N https://github.com/ryanoasis/nerd-fonts/raw/master/pa
|
||||
fc-cache -fv ~/.fonts
|
||||
|
||||
if [ -d $ZSH/custom/themes/powerlevel10k ]; then
|
||||
cd $ZSH/custom/themes/powerlevel10k && git pull
|
||||
git -C $ZSH/custom/themes/powerlevel10k pull
|
||||
else
|
||||
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH/custom/themes/powerlevel10k
|
||||
fi
|
||||
curl -s https://git.miomio.moe/mio/easyzsh/raw/branch/master/patch.sh | bash -s p10k
|
||||
|
||||
if [ -d ~/.fzf ]; then
|
||||
cd ~/.fzf && git pull
|
||||
git -C ~/.fzf pull
|
||||
~/.fzf/install --all --key-bindings --completion --no-update-rc
|
||||
else
|
||||
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
|
||||
@@ -178,13 +237,13 @@ else
|
||||
fi
|
||||
|
||||
if [ -d $ZSH/custom/plugins/k ]; then
|
||||
cd $ZSH/custom/plugins/k && git pull
|
||||
git -C $ZSH/custom/plugins/k pull
|
||||
else
|
||||
git clone --depth 1 https://github.com/supercrabtree/k $ZSH/custom/plugins/k
|
||||
fi
|
||||
|
||||
if [ -d $ZSH/custom/plugins/fzf-tab ]; then
|
||||
cd $ZSH/custom/plugins/fzf-tab && git pull
|
||||
git -C $ZSH/custom/plugins/fzf-tab pull
|
||||
else
|
||||
git clone --depth 1 https://github.com/Aloxaf/fzf-tab $ZSH/custom/plugins/fzf-tab
|
||||
fi
|
||||
@@ -242,4 +301,7 @@ else
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
# Restore original working directory
|
||||
cd "$ORIGINAL_DIR"
|
||||
exit
|
||||
Reference in New Issue
Block a user