From ff76824283c38a0288a8c9d5313e33cd90ee590e Mon Sep 17 00:00:00 2001 From: Frank Qing Date: Wed, 1 May 2024 12:31:40 +0800 Subject: [PATCH] Customize zsh installation --- .zshrc | 211 +++++++++++++++++++++++++++++++-- example-config/personal_rc.zsh | 10 -- ezshrc.zsh | 203 ------------------------------- install.sh | 131 ++++++++++---------- patch.sh | 18 +++ 5 files changed, 288 insertions(+), 285 deletions(-) delete mode 100644 example-config/personal_rc.zsh delete mode 100644 ezshrc.zsh create mode 100644 patch.sh diff --git a/.zshrc b/.zshrc index 518d104..87e6543 100644 --- a/.zshrc +++ b/.zshrc @@ -1,18 +1,211 @@ -################# DO NOT MODIFY THIS FILE ####################### -####### PLACE YOUR CONFIGS IN ~/.config/ezsh/zshrc FOLDER ####### -################################################################# - -# This file is created by ezsh setup. -# Place all your .zshrc configurations / overrides in a single or multiple files under ~/.config/ezsh/zshrc/ folder # Your original .zshrc is backed up at ~/.zshrc-backup-%y-%m-%d +export TERM="xterm-256color" +# If you come from bash you might have to change your $PATH. +# export PATH=$HOME/bin:/usr/local/bin:$PATH -# Load ezsh configurations -source "$HOME/.config/ezsh/ezshrc.zsh" +# Path to your oh-my-zsh installation. +export ZSH=$HOME/.oh-my-zsh + +# Set name of the theme to load. Optionally, if you set this to "random" +# it'll load a random theme each time that oh-my-zsh is loaded. +# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes + + +POWERLEVEL9K_MODE='nerdfont-complete' + +ZSH_THEME="powerlevel10k/powerlevel10k" + +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" + +# Uncomment the following line to use hyphen-insensitive completion. Case +# sensitive completion must be off. _ and - will be interchangeable. +# HYPHEN_INSENSITIVE="true" + +# Uncomment the following line to disable bi-weekly auto-update checks. +# DISABLE_AUTO_UPDATE="true" + +# Uncomment the following line to change how often to auto-update (in days). +# export UPDATE_ZSH_DAYS=13 + +# Uncomment the following line to disable colors in ls. +# DISABLE_LS_COLORS="true" + +# Uncomment the following line to disable auto-setting terminal title. +# DISABLE_AUTO_TITLE="true" + +# Uncomment the following line to enable command auto-correction. +# ENABLE_CORRECTION="true" + +# Uncomment the following line to display red dots whilst waiting for completion. +# COMPLETION_WAITING_DOTS="true" + +# Uncomment the following line if you want to disable marking untracked files +# under VCS as dirty. This makes repository status check for large repositories +# much, much faster. +# DISABLE_UNTRACKED_FILES_DIRTY="true" + +# Uncomment the following line if you want to change the command execution time +# stamp shown in the history command output. +# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" +# HIST_STAMPS="mm/dd/yyyy" + +# Would you like to use another custom folder than $ZSH/custom? +# ZSH_CUSTOM=/path/to/new-custom-folder + +# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) +# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ +# 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-syntax-highlighting + history-substring-search + screen + systemd + web-search + k + extract + z + sudo + # httpie + # git + # python + # docker + # lol + # pip + # pyenv + # redis-cli + # zsh-wakatime # enable if you use wakatime with 'https://github.com/wbingli/zsh-wakatime' + ) +#plugins+=(zsh-nvm) + +# source $ZSH/oh-my-zsh.sh # This is now run after importing user configs + +# User configuration + +# export MANPATH="/usr/local/man:$MANPATH" + +# You may need to manually set your language environment +# export LANG=en_US.UTF-8 + +# Preferred editor for local and remote sessions +# if [[ -n $SSH_CONNECTION ]]; then +# export EDITOR='vim' +# else +# export EDITOR='mvim' +# fi + +# Compilation flags +# export ARCHFLAGS="-arch x86_64" + +# ssh +# export SSH_KEY_PATH="~/.ssh/rsa_id" + +# Set personal aliases, overriding those provided by oh-my-zsh libs, +# plugins, and themes. Aliases can be placed here, though oh-my-zsh +# users are encouraged to define aliases within the ZSH_CUSTOM folder. +# For a full list of active aliases, run `alias`. +# +# Example aliases +# alias zshconfig="mate ~/.zshrc" +# alias ohmyzsh="mate ~/.oh-my-zsh" + +# Add to PATH to Install and run programs with "pip install --user" +# export PATH=$PATH:~/.local/bin + +# export PATH=$PATH:~/.config/ezsh/bin + +# NPM_PACKAGES="${HOME}/.npm" +# PATH="$NPM_PACKAGES/bin:$PATH" + +[[ -s "$HOME/.config/ezsh/marker/marker.sh" ]] && source "$HOME/.config/ezsh/marker/marker.sh" + +autoload -U compinit && compinit -C -d ~/.cache/zsh/.zcompdump # zsh-completions +# autoload bashcompinit # bash completions +# bashcompinit + + +# QuickZsh +SAVEHIST=50000 #save upto 50,000 lines in history. oh-my-zsh default is 10,000 +#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 e="exit" +alias ip="ip --color=auto" + + +# CUSTOM FUNCTIONS + +# cheat sheets (github.com/chubin/cheat.sh), find out how to use commands +# example 'cheat tar' +# for language specific question supply 2 args first for language, second as the question +# eample: cheat python3 execute external program +cheat() { + if [ "$2" ]; then + curl "https://cheat.sh/$1/$2+$3+$4+$5+$6+$7+$8+$9+$10" + else + curl "https://cheat.sh/$1" + fi +} + + +# Matrix screen saver! will run if you have installed "cmatrix" +# TMOUT=900 +# TRAPALRM() { if command -v cmatrix &> /dev/null; then cmatrix -sb; fi } + +speedtest() { + curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python3 - +} + +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 + if [ "$1" ]; then + curl "http://api.db-ip.com/v2/free/$1" + else + curl "http://api.db-ip.com/v2/free/$(myip)" + fi +} # Any zshrc configurations under the folder ~/.config/ezsh/zshrc/ will override the default ezsh configs. # Place all of your personal configurations over there -ZSH_CONFIGS_DIR="$HOME/.config/ezsh/zshrc" +ZSH_CONFIGS_DIR="$HOME/.config/zshrc" if [ "$(ls -A $ZSH_CONFIGS_DIR)" ]; then for file in "$ZSH_CONFIGS_DIR"/*; do diff --git a/example-config/personal_rc.zsh b/example-config/personal_rc.zsh deleted file mode 100644 index 0a6360f..0000000 --- a/example-config/personal_rc.zsh +++ /dev/null @@ -1,10 +0,0 @@ -# This my personal zshrc configs. Feel free to use it and modify according to your needs -# Place all your .zshrc configurations (including this one) in a single or multiple files under ~/.config/ezsh/zshrc/ folder - -# Additional OH-MY-ZSH plugins to enable -plugins+=(lol httpie docker docker-compose pyenv pip) - -POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(virtualenv status command_execution_time background_jobs todo ram load rvm time) - - -# Custom Aliases, add your personal aliases here diff --git a/ezshrc.zsh b/ezshrc.zsh deleted file mode 100644 index 898e642..0000000 --- a/ezshrc.zsh +++ /dev/null @@ -1,203 +0,0 @@ -export TERM="xterm-256color" -# If you come from bash you might have to change your $PATH. -# export PATH=$HOME/bin:/usr/local/bin:$PATH - -# Path to your oh-my-zsh installation. -export ZSH=$HOME/.config/ezsh/oh-my-zsh - -# Set name of the theme to load. Optionally, if you set this to "random" -# it'll load a random theme each time that oh-my-zsh is loaded. -# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes - - -POWERLEVEL9K_MODE='nerdfont-complete' - -ZSH_THEME="powerlevel10k/powerlevel10k" - -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" - -# Uncomment the following line to use hyphen-insensitive completion. Case -# sensitive completion must be off. _ and - will be interchangeable. -# HYPHEN_INSENSITIVE="true" - -# Uncomment the following line to disable bi-weekly auto-update checks. -# DISABLE_AUTO_UPDATE="true" - -# Uncomment the following line to change how often to auto-update (in days). -# export UPDATE_ZSH_DAYS=13 - -# Uncomment the following line to disable colors in ls. -# DISABLE_LS_COLORS="true" - -# Uncomment the following line to disable auto-setting terminal title. -# DISABLE_AUTO_TITLE="true" - -# Uncomment the following line to enable command auto-correction. -# ENABLE_CORRECTION="true" - -# Uncomment the following line to display red dots whilst waiting for completion. -# COMPLETION_WAITING_DOTS="true" - -# Uncomment the following line if you want to disable marking untracked files -# under VCS as dirty. This makes repository status check for large repositories -# much, much faster. -# DISABLE_UNTRACKED_FILES_DIRTY="true" - -# Uncomment the following line if you want to change the command execution time -# stamp shown in the history command output. -# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" -# HIST_STAMPS="mm/dd/yyyy" - -# Would you like to use another custom folder than $ZSH/custom? -# ZSH_CUSTOM=/path/to/new-custom-folder - -# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) -# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ -# 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-syntax-highlighting - history-substring-search - screen - systemd - web-search - k - extract - z - sudo - # httpie - # git - # python - # docker - # lol - # pip - # pyenv - # redis-cli - # zsh-wakatime # enable if you use wakatime with 'https://github.com/wbingli/zsh-wakatime' - ) -#plugins+=(zsh-nvm) - -# source $ZSH/oh-my-zsh.sh # This is now run in .zshrc after importing user configs from ~/.config/ezsh/zshrc/* files - -# User configuration - -# export MANPATH="/usr/local/man:$MANPATH" - -# You may need to manually set your language environment -# export LANG=en_US.UTF-8 - -# Preferred editor for local and remote sessions -# if [[ -n $SSH_CONNECTION ]]; then -# export EDITOR='vim' -# else -# export EDITOR='mvim' -# fi - -# Compilation flags -# export ARCHFLAGS="-arch x86_64" - -# ssh -# export SSH_KEY_PATH="~/.ssh/rsa_id" - -# Set personal aliases, overriding those provided by oh-my-zsh libs, -# plugins, and themes. Aliases can be placed here, though oh-my-zsh -# users are encouraged to define aliases within the ZSH_CUSTOM folder. -# For a full list of active aliases, run `alias`. -# -# Example aliases -# alias zshconfig="mate ~/.zshrc" -# alias ohmyzsh="mate ~/.oh-my-zsh" - -# Add to PATH to Install and run programs with "pip install --user" -export PATH=$PATH:~/.local/bin - -export PATH=$PATH:~/.config/ezsh/bin - -NPM_PACKAGES="${HOME}/.npm" -PATH="$NPM_PACKAGES/bin:$PATH" - -[[ -s "$HOME/.config/ezsh/marker/marker.sh" ]] && source "$HOME/.config/ezsh/marker/marker.sh" - -autoload -U compinit && compinit -C -d ~/.cache/zsh/.zcompdump # zsh-completions -# autoload bashcompinit # bash completions -# bashcompinit - - -# QuickZsh -SAVEHIST=50000 #save upto 50,000 lines in history. oh-my-zsh default is 10,000 -#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 e="exit" -alias ip="ip --color=auto" - - -# CUSTOM FUNCTIONS - -# cheat sheets (github.com/chubin/cheat.sh), find out how to use commands -# example 'cheat tar' -# for language specific question supply 2 args first for language, second as the question -# eample: cheat python3 execute external program -cheat() { - if [ "$2" ]; then - curl "https://cheat.sh/$1/$2+$3+$4+$5+$6+$7+$8+$9+$10" - else - curl "https://cheat.sh/$1" - fi -} - - -# Matrix screen saver! will run if you have installed "cmatrix" -# TMOUT=900 -# TRAPALRM() { if command -v cmatrix &> /dev/null; then cmatrix -sb; fi } - -speedtest() { - curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python3 - -} - -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 - if [ "$1" ]; then - curl "http://api.db-ip.com/v2/free/$1" - else - curl "http://api.db-ip.com/v2/free/$(myip)" - fi -} - diff --git a/install.sh b/install.sh index dfb4cb1..00d7daa 100755 --- a/install.sh +++ b/install.sh @@ -30,35 +30,39 @@ else fi fi +ZSH="~/.oh-my-zsh" + if mv -n ~/.zshrc ~/.zshrc-backup-$(date +"%Y-%m-%d"); then # backup .zshrc echo -e "Backed up the current .zshrc to .zshrc-backup-date\n" 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 +# 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 -if [ -d ~/.quickzsh ]; then - echo -e "\n PREVIOUS SETUP FOUND AT '~/.quickzsh'. PLEASE MANUALLY MOVE ANY FILES YOU'D LIKE TO '~/.config/ezsh' \n" -fi +# if [ -d ~/.quickzsh ]; then +# echo -e "\n PREVIOUS SETUP FOUND AT '~/.quickzsh'. PLEASE MANUALLY MOVE ANY FILES YOU'D LIKE TO '~/.config/ezsh' \n" +# fi echo -e "Installing oh-my-zsh\n" -if [ -d ~/.config/ezsh/oh-my-zsh ]; then +if [ -d $ZSH ]; then echo -e "oh-my-zsh is already installed\n" - git -C ~/.config/ezsh/oh-my-zsh remote set-url origin https://github.com/ohmyzsh/ohmyzsh.git -elif [ -d ~/.oh-my-zsh ]; then - echo -e "oh-my-zsh in already installed at '~/.oh-my-zsh'. Moving it to '~/.config/ezsh/oh-my-zsh'" - export ZSH="$HOME/.config/ezsh/oh-my-zsh" - mv ~/.oh-my-zsh ~/.config/ezsh/oh-my-zsh - git -C ~/.config/ezsh/oh-my-zsh remote set-url origin https://github.com/ohmyzsh/ohmyzsh.git + git -C $ZSH remote set-url origin https://github.com/ohmyzsh/ohmyzsh.git +# elif [ -d ~/.oh-my-zsh ]; then +# echo -e "oh-my-zsh in already installed at '~/.oh-my-zsh'. Moving it to '$ZSH'" +# export ZSH="$HOME/.config/ezsh/oh-my-zsh" +# mv ~/.oh-my-zsh $ZSH +# git -C $ZSH remote set-url origin https://github.com/ohmyzsh/ohmyzsh.git else - git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git ~/.config/ezsh/oh-my-zsh + git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git $ZSH fi -cp -f .zshrc ~/ -cp -f ezshrc.zsh ~/.config/ezsh/ +# 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/rss/branch/master/.zshrc" -O ~/.zshrc -mkdir -p ~/.config/ezsh/zshrc # PLACE YOUR ZSHRC CONFIGURATIONS OVER THERE +# 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 @@ -66,28 +70,28 @@ if [ -f ~/.zcompdump ]; then mv ~/.zcompdump* ~/.cache/zsh/ fi -if [ -d ~/.config/ezsh/oh-my-zsh/plugins/zsh-autosuggestions ]; then - cd ~/.config/ezsh/oh-my-zsh/plugins/zsh-autosuggestions && git pull +if [ -d $ZSH/plugins/zsh-autosuggestions ]; then + cd $ZSH/plugins/zsh-autosuggestions && git pull else - git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions ~/.config/ezsh/oh-my-zsh/plugins/zsh-autosuggestions + git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions $ZSH/plugins/zsh-autosuggestions fi -if [ -d ~/.config/ezsh/oh-my-zsh/custom/plugins/zsh-syntax-highlighting ]; then - cd ~/.config/ezsh/oh-my-zsh/custom/plugins/zsh-syntax-highlighting && git pull +if [ -d $ZSH/custom/plugins/zsh-syntax-highlighting ]; then + cd $ZSH/custom/plugins/zsh-syntax-highlighting && git pull else - git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.config/ezsh/oh-my-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 -if [ -d ~/.config/ezsh/oh-my-zsh/custom/plugins/zsh-completions ]; then - cd ~/.config/ezsh/oh-my-zsh/custom/plugins/zsh-completions && git pull +if [ -d $ZSH/custom/plugins/zsh-completions ]; then + cd $ZSH/custom/plugins/zsh-completions && git pull else - git clone --depth=1 https://github.com/zsh-users/zsh-completions ~/.config/ezsh/oh-my-zsh/custom/plugins/zsh-completions + git clone --depth=1 https://github.com/zsh-users/zsh-completions $ZSH/custom/plugins/zsh-completions fi -if [ -d ~/.config/ezsh/oh-my-zsh/custom/plugins/zsh-history-substring-search ]; then - cd ~/.config/ezsh/oh-my-zsh/custom/plugins/zsh-history-substring-search && git pull +if [ -d $ZSH/custom/plugins/zsh-history-substring-search ]; then + cd $ZSH/custom/plugins/zsh-history-substring-search && git pull else - git clone --depth=1 https://github.com/zsh-users/zsh-history-substring-search ~/.config/ezsh/oh-my-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 @@ -101,62 +105,63 @@ wget -q --show-progress -N https://github.com/ryanoasis/nerd-fonts/raw/master/pa fc-cache -fv ~/.fonts -if [ -d ~/.config/ezsh/oh-my-zsh/custom/themes/powerlevel10k ]; then - cd ~/.config/ezsh/oh-my-zsh/custom/themes/powerlevel10k && git pull +if [ -d $ZSH/custom/themes/powerlevel10k ]; then + cd $ZSH/custom/themes/powerlevel10k && git pull else - git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/.config/ezsh/oh-my-zsh/custom/themes/powerlevel10k + git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH/custom/themes/powerlevel10k fi -if [ -d ~/.~/.config/ezsh/fzf ]; then - cd ~/.config/ezsh/fzf && git pull - ~/.config/ezsh/fzf/install --all --key-bindings --completion --no-update-rc +if [ -d ~/.fzf ]; then + cd ~/.fzf && git pull + ~/.fzf/install --all --key-bindings --completion --no-update-rc else - git clone --depth 1 https://github.com/junegunn/fzf.git ~/.config/ezsh/fzf - ~/.config/ezsh/fzf/install --all --key-bindings --completion --no-update-rc + git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf + ~/.fzf/install --all --key-bindings --completion --no-update-rc fi -if [ -d ~/.config/ezsh/oh-my-zsh/custom/plugins/k ]; then - cd ~/.config/ezsh/oh-my-zsh/custom/plugins/k && git pull +if [ -d $ZSH/custom/plugins/k ]; then + cd $ZSH/custom/plugins/k && git pull else - git clone --depth 1 https://github.com/supercrabtree/k ~/.config/ezsh/oh-my-zsh/custom/plugins/k + git clone --depth 1 https://github.com/supercrabtree/k $ZSH/custom/plugins/k fi -if [ -d ~/.config/ezsh/oh-my-zsh/custom/plugins/fzf-tab ]; then - cd ~/.config/ezsh/oh-my-zsh/custom/plugins/fzf-tab && git pull +if [ -d $ZSH/custom/plugins/fzf-tab ]; then + cd $ZSH/custom/plugins/fzf-tab && git pull else - git clone --depth 1 https://github.com/Aloxaf/fzf-tab ~/.config/ezsh/oh-my-zsh/custom/plugins/fzf-tab + git clone --depth 1 https://github.com/Aloxaf/fzf-tab $ZSH/custom/plugins/fzf-tab fi -if [ -d ~/.config/ezsh/marker ]; then - cd ~/.config/ezsh/marker && git pull +if [ -d ~/.marker ]; then + cd ~/.marker && git pull else - git clone --depth 1 https://github.com/jotyGill/marker ~/.config/ezsh/marker + git clone --depth 1 https://github.com/jotyGill/marker ~/.marker fi -if ~/.config/ezsh/marker/install.py; then +if ~/.marker/install.py; then echo -e "Installed Marker\n" 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 : +# # 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 +# mkdir -p ~/.config/ezsh/todo +# wget -q --show-progress "https://github.com/todotxt/todo.txt-cli/releases/download/v2.12.0/todo.txt_cli-2.12.0.tar.gz" -P ~/.config/ezsh/ +# tar xvf ~/.config/ezsh/todo.txt_cli-2.12.0.tar.gz -C ~/.config/ezsh/todo --strip 1 && rm ~/.config/ezsh/todo.txt_cli-2.12.0.tar.gz +# ln -s -f ~/.config/ezsh/todo/todo.sh ~/.config/ezsh/bin/todo.sh # so only .../bin is included in $PATH +# ln -s -f ~/.config/ezsh/todo/todo.cfg ~/.todo.cfg # it expects it there or ~/todo.cfg or ~/.todo/config # else -# cd ~/.config/ezsh/todo && git fetch --all && git reset --hard origin/master +# echo -e "todo.sh is already instlled in ~/.config/ezsh/todo/bin/\n" # 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 - mkdir -p ~/.config/ezsh/todo - wget -q --show-progress "https://github.com/todotxt/todo.txt-cli/releases/download/v2.12.0/todo.txt_cli-2.12.0.tar.gz" -P ~/.config/ezsh/ - tar xvf ~/.config/ezsh/todo.txt_cli-2.12.0.tar.gz -C ~/.config/ezsh/todo --strip 1 && rm ~/.config/ezsh/todo.txt_cli-2.12.0.tar.gz - ln -s -f ~/.config/ezsh/todo/todo.sh ~/.config/ezsh/bin/todo.sh # so only .../bin is included in $PATH - ln -s -f ~/.config/ezsh/todo/todo.cfg ~/.todo.cfg # it expects it there or ~/todo.cfg or ~/.todo/config -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 diff --git a/patch.sh b/patch.sh new file mode 100644 index 0000000..1726154 --- /dev/null +++ b/patch.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +BASE_URL="https://git.miomio.moe/mio/easyzsh/rss/branch/master/zshrc" + +ZSH_CONFIGS_DIR="$HOME/.config/zshrc" +mkdir -p $ZSH_CONFIGS_DIR + +if [ "$#" -gt 0 ]; then + for arg in "$@"; do + if ! wget "${BASE_URL}/${arg}.zsh" -O "${ZSH_CONFIGS_DIR}/${arg}.zsh"; then + echo "Failed to download ${arg}.zsh from ${BASE_URL}" + exit 1 + fi + done +else + echo "No arguments provided. Please specify the config files to download." + exit 1 +fi