Upgrade easyzsh

This commit is contained in:
Frank Qing
2025-05-28 01:26:30 +08:00
parent 038cf2b2c7
commit bf1f1c0cbb
4 changed files with 240 additions and 1776 deletions

99
.zshrc
View File

@@ -1,4 +1,9 @@
# Your original .zshrc is backed up at ~/.zshrc-backup-%y-%m-%d
# 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.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
export TERM="xterm-256color"
# If you come from bash you might have to change your $PATH.
@@ -11,31 +16,7 @@ export ZSH=$HOME/.oh-my-zsh
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
# 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.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
ZSH_THEME="powerlevel10k/powerlevel10k"
# POWERLEVEL9K_MODE='nerdfont-complete'
# POWERLEVEL9K_OS_ICON_BACKGROUND="white"
# POWERLEVEL9K_OS_ICON_FOREGROUND="blue"
# POWERLEVEL9K_DIR_HOME_FOREGROUND="white"
# POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND="white"
# POWERLEVEL9K_DIR_DEFAULT_FOREGROUND="white"
# POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status command_execution_time background_jobs ram load rvm time)
# # more prompt elements that are suggested
# # (public_ip docker_machine pyenv nvm) https://github.com/bhilburn/powerlevel9k#prompt-customization
# # Note: using public_ip is cool but when connection is down prompt waits for 10-20 seconds
# POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh os_icon context dir vcs)
# POWERLEVEL9K_PROMPT_ON_NEWLINE=true
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
@@ -80,17 +61,17 @@ ZSH_THEME="powerlevel10k/powerlevel10k"
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
zsh-completions
zsh-autosuggestions # disable when using marker, otherwise enable
# zsh-completions INSTALL METHOD CHANGED https://github.com/zsh-users/zsh-completions/issues/603
zsh-autosuggestions # Disable if you are using Marker, otherwise enable
zsh-syntax-highlighting
history-substring-search
screen
systemd
web-search
k
extract
z
sudo
fzf-tab
# web-search
# httpie
# git
# python
@@ -99,11 +80,19 @@ plugins=(
# pip
# pyenv
# redis-cli
# screen
# zsh-wakatime # enable if you use wakatime with 'https://github.com/wbingli/zsh-wakatime'
)
# Plugins can be added like into your own config file under ~/.config/zshrc/ like this:
#plugins+=(zsh-nvm)
# source $ZSH/oh-my-zsh.sh # This is now run after importing user configs
# Remove plugins from the default list above in your own config file using:
# plugins=(${plugins:#pluginname})
# plugins=(${plugins:#zsh-autosuggestions})
# fpath+="${ZSH_CUSTOM:-"$ZSH/custom"}/plugins/zsh-completions/src" # install zsh-completions, if you need it
# source $ZSH/oh-my-zsh.sh # This is now run in .zshrc after importing user configs from ~/.config/zshrc/* files
# User configuration
@@ -134,16 +123,20 @@ plugins=(
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# Add to PATH to Install and run programs with "pip install --user"
# Add to PATH to run programs installed with pipx or "pip install --user"
# export PATH=$PATH:~/.local/bin
# To give this path preference instead of system paths to run the latest version of tools, add the following to your personal config. Due to security concerns this is not done by default.
# export PATH=~/.local/bin:$PATH
# export PATH=$PATH:~/.config/ezsh/bin
# NPM_PACKAGES="${HOME}/.npm"
# PATH="$NPM_PACKAGES/bin:$PATH"
# [[ -s "$HOME/.marker/marker.sh" ]] && source "$HOME/.marker/marker.sh"
[[ -s "$HOME/.marker/marker.sh" ]] && source "$HOME/.marker/marker.sh"
fpath+=$ZSH/custom/plugins/zsh-completions/src
autoload -U compinit && compinit -C -d ~/.cache/zsh/.zcompdump # zsh-completions
# autoload bashcompinit # bash completions
# bashcompinit
@@ -154,9 +147,12 @@ SAVEHIST=50000 #save upto 50,000 lines in history. oh-my-zsh default is 10,
#setopt hist_ignore_all_dups # dont record duplicated entries in history during a single session
alias myip="wget -qO- https://wtfismyip.com/text" # quickly show external ip address
alias l="ls -lAhrtF" # show all except . .. , sort by recent, / at the end of folders
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
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
# CUSTOM FUNCTIONS
@@ -173,7 +169,6 @@ cheat() {
fi
}
# Matrix screen saver! will run if you have installed "cmatrix"
# TMOUT=900
# TRAPALRM() { if command -v cmatrix &> /dev/null; then cmatrix -sb; fi }
@@ -186,17 +181,6 @@ dadjoke() {
curl https://icanhazdadjoke.com
}
# Find dictionary definition
dict() {
if [ "$3" ]; then
curl "dict://dict.org/d:$1 $2 $3"
elif [ "$2" ]; then
curl "dict://dict.org/d:$1 $2"
else
curl "dict://dict.org/d:$1"
fi
}
# Find geo info from IP
ipgeo() {
# Specify ip or your ip will be used
@@ -207,29 +191,28 @@ ipgeo() {
fi
}
# Any zshrc configurations under the folder ~/.config/ezsh/zshrc/ will override the default ezsh configs.
# To customize prompt look, edit ~/.config/ezsh/p10k.zsh or run `p10k configure`
# [[ ! -f ~/.config/ezsh/p10k.zsh ]] || source ~/.config/ezsh/p10k.zsh # already in ZSH_CONFIGS_DIR
# Any zshrc configurations under the folder ~/.config/zshrc/ will override the default ezsh configs.
# Place all of your personal configurations over there
ZSH_CONFIGS_DIR="$HOME/.config/zshrc"
mkdir -p $ZSH_CONFIGS_DIR
if [ "$(ls -A $ZSH_CONFIGS_DIR)" ]; then
for file in "$ZSH_CONFIGS_DIR"/*; do
for file in "$ZSH_CONFIGS_DIR"/*(DN); do
# Exclude '.' and '..' from being sourced
if [ -f "$file" ]; then
source "$file"
done
fi
fi
done
# Now source oh-my-zsh.sh so that any plugins added in ~/.config/ezsh/zshrc/* files also get loaded
# Now source oh-my-zsh.sh so that any plugins added in ~/.config/zshrc/* files also get loaded
source $ZSH/oh-my-zsh.sh
# Configs that can only work after "source $ZSH/oh-my-zsh.sh", such as Aliases that depend oh-my-zsh plugins
# Autojump configuration
[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
[ -f /usr/share/autojump/autojump.sh ] && . /usr/share/autojump/autojump.sh
# Now source fzf.zsh , otherwise Ctr+r is overwritten by ohmyzsh
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export FZF_DEFAULT_OPS="--extended"
alias k="k -h" # show human readable file sizes, in kb, mb etc
alias k="k -h" # show human readable file sizes, in kb, mb etc

View File

@@ -1,70 +1 @@
# ezsh
A simple script to setup an awesome shell environment.
Quickly install and setup zsh and oh-my-zsh (https://github.com/robbyrussell/oh-my-zsh) with
* powerlevel10k theme (https://github.com/romkatv/powerlevel10k)
* Nerd-Fonts (https://github.com/ryanoasis/nerd-fonts)
* zsh-completions (https://github.com/zsh-users/zsh-completions)
* zsh-autosuggestions (https://github.com/zsh-users/zsh-autosuggestions)
* zsh-syntax-highlighting (https://github.com/zsh-users/zsh-syntax-highlighting)
* history-substring-search (https://github.com/zsh-users/zsh-history-substring-search)
* fzf (https://github.com/junegunn/fzf)
* k (https://github.com/supercrabtree/k)
* marker (https://github.com/pindexis/marker)
* todotxt (https://github.com/todotxt/todo.txt-cli)
Sets following useful aliases and ohmyzsh plugins. **You can add more or overwrite these in your personal zsh config files under `~/.config/ezsh/zshrc/`**
* l="ls -lah" - just type "l" instead of "ls -lah"
* alias k="k -h" - show human readable filesizes, in kb, mb etc
* e="exit"
* [x="extract"](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/extract) - extract any compressed files
* [z](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/z) - quickly jump to most visited directories
* [web-search](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/web-search) - search on the web from cli
* [sudo](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/sudo) - easily prefix your commands with sudo by pressing `esc` twice
* [systemd](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/systemd) - many useful aliases for systemd
* https - make httpie use https
* myip - (wget -qO- https://wtfismyip.com/text) - what's my ip: quickly find out external IP
* cheat - (https://github.com/chubin/cheat.sh) - cheatsheets in the terminal!
* speedtest - (curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python3 -) run speedtest on the fly
* dadjoke - (curl https://icanhazdadjoke.com) - terminally sick jokes
* dict - (curl "dict://dict.org/d:$1 $2 $3") - dictionary definitions
* ipgeo - (curl "http://api.db-ip.com/v2/free/$1") - finds geo location from IP
* corona - (curl "https://corona-stats.online/") - shows corona virus spread live stats
## Demo
Command prompt looks like this (easily customize it by placing your configs in ~/.config/ezsh/zshrc/)
![prompt](https://user-images.githubusercontent.com/8462091/43674765-8bb13a76-9817-11e8-8b7b-16b8b1998408.png)
user : directory : git stats : last command exit code free memory: load : time
Watch this to get an idea of what your Shell (well, life!) could be like!!
[![asciicast](https://asciinema.org/a/225226.svg)](https://asciinema.org/a/225226)
## Installation
Requirements:
* `git` to clone it.
* `python3` or `python` is required to run option '-c' which copies history from .bash_history
``` bash
git clone https://github.com/jotyGill/ezsh
cd ezsh
./install.sh -c # only run with '-c' the first time, running multiple times will duplicate history entries
```
This will install the setup under `~/.config/ezsh/`
Change your terminal's fonts to either "RobotoMono Nerd Font" or "Hack Nerd Font" or "DejaVu Sans Mono Nerd Fonts".
You can also manually install Nerd Fonts of your choice.
## Notes
* If you are already using zsh, your zsh config will be backed up to .zshrc-backup-date
* If the text/icons look broken, make sure your terminal is using one of the Nerd fonts. [discussion](https://github.com/powerline/fonts/issues/185). I recommend "RobotoMono Nerd Font"
* marker's shortcut "Ctr+t" clashed with fzf so I rebound it to "Ctr +b"
* All oh-my-zsh plugins are installed under ~/.config/ezsh/oh-my-zsh/plugin, Other tools (fzf,marker,todo) are installed in ~/.config/ezsh/
* The look of the shell can be very easily customised[https://github.com/bhilburn/powerlevel9k#prompt-customization] by overwriting POWERLEVEL10K settings
in your personal config file under ~/.config/ezsh/zshrc/ . See my setup under example/personal_rc.zsh
Suggestions about more cool tools are always welcome :)
# Easy Zsh Setup

View File

@@ -48,35 +48,35 @@ 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 autojump
brew install zsh git wget fontconfig
;;
ubuntu|debian)
sudo apt-get update
sudo apt-get install -y zsh git wget fontconfig autojump
sudo apt-get install -y zsh git wget fontconfig
;;
fedora)
sudo dnf install -y zsh git wget fontconfig autojump
sudo dnf install -y zsh git wget fontconfig
;;
centos|rhel)
sudo yum install -y zsh git wget fontconfig autojump
sudo yum install -y zsh git wget fontconfig
;;
arch|manjaro)
sudo pacman -Syu --noconfirm zsh git wget fontconfig autojump
sudo pacman -Syu --noconfirm zsh git wget fontconfig
;;
*)
echo "Unsupported operating system. Please install zsh, git, wget, fontconfig, and autojump manually."
echo "Unsupported operating system. Please install zsh, git, wget, and fontconfig manually."
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 && command -v autojump &> /dev/null; then
echo -e "ZSH, Git, wget, fontconfig, and autojump 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; then
echo -e "ZSH, Git, wget, and fontconfig are already installed\n"
else
echo "Installing required packages..."
install_packages
echo -e "zsh, wget, git, fontconfig, and autojump Installed\n"
echo -e "zsh, wget, git, and fontconfig Installed\n"
fi
if [ -f ~/.gitconfig.backup ]; then
@@ -95,7 +95,7 @@ fi
# echo -e "The setup will be installed in '~/.config/ezsh'\n"
# echo -e "Place your personal zshrc config files under '~/.config/ezsh/zshrc/'\n"
# mkdir -p ~/.config/ezsh/zshrc
# mkdir -p ~/.config/ezsh/zshrc # PLACE YOUR ZSHRC CONFIGURATIONS OVER THERE
# if [ -d ~/.quickzsh ]; then
# echo -e "\n PREVIOUS SETUP FOUND AT '~/.quickzsh'. PLEASE MANUALLY MOVE ANY FILES YOU'D LIKE TO '~/.config/ezsh' \n"
@@ -115,11 +115,11 @@ else
fi
# cp -f .zshrc ~/
# cp -f ezshrc.zsh ~/.config/ezsh/
echo -e "Downloaded the remote .zshrc configuration\n"
wget -q "https://git.miomio.moe/mio/easyzsh/raw/branch/master/.zshrc" -O ~/.zshrc
# cp -f ezshrc.zsh ~/.config/ezsh/
# cp -f p10k.zsh ~/.config/ezsh/
# mkdir -p ~/.config/ezsh/zshrc # PLACE YOUR ZSHRC CONFIGURATIONS OVER THERE
mkdir -p ~/.cache/zsh/ # this will be used to store .zcompdump zsh completion cache files which normally clutter $HOME
mkdir -p ~/.fonts # Create .fonts if doesn't exist
@@ -201,13 +201,13 @@ else
echo -e "Marker Installation Had Issues\n"
fi
# # if git clone --depth 1 https://github.com/todotxt/todo.txt-cli.git ~/.config/ezsh/todo; then :
# # else
# # cd ~/.config/ezsh/todo && git fetch --all && git reset --hard origin/master
# # fi
# # mkdir ~/.config/ezsh/todo/bin ; cp -f ~/.config/ezsh/todo/todo.sh ~/.config/ezsh/todo/bin/todo.sh # cp todo.sh to ./bin so only it is included in $PATH
# # #touch ~/.todo/config # needs it, otherwise spits error , yeah a bug in todo
# # ln -s ~/.config/ezsh/todo ~/.todo
# if git clone --depth 1 https://github.com/todotxt/todo.txt-cli.git ~/.config/ezsh/todo; then :
# else
# cd ~/.config/ezsh/todo && git fetch --all && git reset --hard origin/master
# fi
# mkdir ~/.config/ezsh/todo/bin ; cp -f ~/.config/ezsh/todo/todo.sh ~/.config/ezsh/todo/bin/todo.sh # cp todo.sh to ./bin so only it is included in $PATH
# #touch ~/.todo/config # needs it, otherwise spits error , yeah a bug in todo
# ln -s ~/.config/ezsh/todo ~/.todo
# if [ ! -L ~/.config/ezsh/todo/bin/todo.sh ]; then
# echo -e "Installing todo.sh in ~/.config/ezsh/todo\n"
# mkdir -p ~/.config/ezsh/bin
@@ -219,7 +219,6 @@ fi
# else
# echo -e "todo.sh is already instlled in ~/.config/ezsh/todo/bin/\n"
# fi
if [ "$cp_hist_flag" = true ]; then
echo -e "\nCopying bash_history to zsh_history\n"
if command -v python &>/dev/null; then
@@ -249,7 +248,8 @@ else
echo -e "Installation complete, exit terminal and enter a new zsh session"
echo -e "In a new zsh session manually run: build-fzf-tab-module"
else
echo -e "Something went wrong"
echo -e "Something is wrong"
fi
fi
exit

File diff suppressed because it is too large Load Diff