✨ (.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.
|
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
|
||||||
# Initialization code that may require console input (password prompts, [y/n]
|
# Initialization code that may require console input (password prompts, [y/n]
|
||||||
# confirmations, etc.) must go above this block; everything else may go below.
|
# confirmations, etc.) must go above this block; everything else may go below.
|
||||||
@@ -137,6 +142,12 @@ plugins=(
|
|||||||
|
|
||||||
|
|
||||||
fpath+=$ZSH/custom/plugins/zsh-completions/src
|
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 -U compinit && compinit -C -d ~/.cache/zsh/.zcompdump # zsh-completions
|
||||||
# autoload bashcompinit # bash completions
|
# autoload bashcompinit # bash completions
|
||||||
# bashcompinit
|
# 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 l="ls --hyperlink=auto -lAhrtF" # show all except . .. , sort by recent, / at the end of folders, clickable
|
||||||
alias e="exit"
|
alias e="exit"
|
||||||
alias ip="ip --color=auto"
|
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 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
|
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
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Save the original working directory
|
||||||
|
ORIGINAL_DIR="$(pwd)"
|
||||||
|
|
||||||
# Flags to determine if the arguments were passed
|
# Flags to determine if the arguments were passed
|
||||||
cp_hist_flag=false
|
cp_hist_flag=false
|
||||||
noninteractive_flag=false
|
noninteractive_flag=false
|
||||||
@@ -48,35 +51,91 @@ install_packages() {
|
|||||||
echo "Homebrew is not installed. Installing Homebrew..."
|
echo "Homebrew is not installed. Installing Homebrew..."
|
||||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||||
fi
|
fi
|
||||||
brew install zsh git wget fontconfig
|
brew install zsh git wget fontconfig eza
|
||||||
;;
|
;;
|
||||||
ubuntu|debian)
|
ubuntu|debian)
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y zsh git wget fontconfig
|
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)
|
fedora)
|
||||||
sudo dnf install -y zsh git wget fontconfig
|
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)
|
centos|rhel)
|
||||||
sudo yum install -y zsh git wget fontconfig
|
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)
|
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."
|
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
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Check if required packages are installed, if not, install them
|
# 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
|
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, and fontconfig are already installed\n"
|
echo -e "ZSH, Git, wget, fontconfig, and eza are already installed\n"
|
||||||
else
|
else
|
||||||
echo "Installing required packages..."
|
echo "Installing required packages..."
|
||||||
install_packages
|
install_packages
|
||||||
echo -e "zsh, wget, git, and fontconfig Installed\n"
|
echo -e "zsh, wget, git, fontconfig, and eza Installed\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f ~/.gitconfig.backup ]; then
|
if [ -f ~/.gitconfig.backup ]; then
|
||||||
@@ -128,25 +187,25 @@ if [ -f ~/.zcompdump ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d $ZSH/plugins/zsh-autosuggestions ]; then
|
if [ -d $ZSH/plugins/zsh-autosuggestions ]; then
|
||||||
cd $ZSH/plugins/zsh-autosuggestions && git pull
|
git -C $ZSH/plugins/zsh-autosuggestions pull
|
||||||
else
|
else
|
||||||
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions $ZSH/plugins/zsh-autosuggestions
|
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions $ZSH/plugins/zsh-autosuggestions
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d $ZSH/custom/plugins/zsh-syntax-highlighting ]; then
|
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
|
else
|
||||||
git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH/custom/plugins/zsh-syntax-highlighting
|
git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH/custom/plugins/zsh-syntax-highlighting
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d $ZSH/custom/plugins/zsh-completions ]; then
|
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
|
else
|
||||||
git clone --depth=1 https://github.com/zsh-users/zsh-completions $ZSH/custom/plugins/zsh-completions
|
git clone --depth=1 https://github.com/zsh-users/zsh-completions $ZSH/custom/plugins/zsh-completions
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d $ZSH/custom/plugins/zsh-history-substring-search ]; then
|
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
|
else
|
||||||
git clone --depth=1 https://github.com/zsh-users/zsh-history-substring-search $ZSH/custom/plugins/zsh-history-substring-search
|
git clone --depth=1 https://github.com/zsh-users/zsh-history-substring-search $ZSH/custom/plugins/zsh-history-substring-search
|
||||||
fi
|
fi
|
||||||
@@ -163,14 +222,14 @@ wget -q --show-progress -N https://github.com/ryanoasis/nerd-fonts/raw/master/pa
|
|||||||
fc-cache -fv ~/.fonts
|
fc-cache -fv ~/.fonts
|
||||||
|
|
||||||
if [ -d $ZSH/custom/themes/powerlevel10k ]; then
|
if [ -d $ZSH/custom/themes/powerlevel10k ]; then
|
||||||
cd $ZSH/custom/themes/powerlevel10k && git pull
|
git -C $ZSH/custom/themes/powerlevel10k pull
|
||||||
else
|
else
|
||||||
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH/custom/themes/powerlevel10k
|
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH/custom/themes/powerlevel10k
|
||||||
fi
|
fi
|
||||||
curl -s https://git.miomio.moe/mio/easyzsh/raw/branch/master/patch.sh | bash -s p10k
|
curl -s https://git.miomio.moe/mio/easyzsh/raw/branch/master/patch.sh | bash -s p10k
|
||||||
|
|
||||||
if [ -d ~/.fzf ]; then
|
if [ -d ~/.fzf ]; then
|
||||||
cd ~/.fzf && git pull
|
git -C ~/.fzf pull
|
||||||
~/.fzf/install --all --key-bindings --completion --no-update-rc
|
~/.fzf/install --all --key-bindings --completion --no-update-rc
|
||||||
else
|
else
|
||||||
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
|
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
|
||||||
@@ -178,13 +237,13 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d $ZSH/custom/plugins/k ]; then
|
if [ -d $ZSH/custom/plugins/k ]; then
|
||||||
cd $ZSH/custom/plugins/k && git pull
|
git -C $ZSH/custom/plugins/k pull
|
||||||
else
|
else
|
||||||
git clone --depth 1 https://github.com/supercrabtree/k $ZSH/custom/plugins/k
|
git clone --depth 1 https://github.com/supercrabtree/k $ZSH/custom/plugins/k
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d $ZSH/custom/plugins/fzf-tab ]; then
|
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
|
else
|
||||||
git clone --depth 1 https://github.com/Aloxaf/fzf-tab $ZSH/custom/plugins/fzf-tab
|
git clone --depth 1 https://github.com/Aloxaf/fzf-tab $ZSH/custom/plugins/fzf-tab
|
||||||
fi
|
fi
|
||||||
@@ -242,4 +301,7 @@ else
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Restore original working directory
|
||||||
|
cd "$ORIGINAL_DIR"
|
||||||
exit
|
exit
|
||||||
Reference in New Issue
Block a user