config zsh
This commit is contained in:
67
polyjuice.sh
67
polyjuice.sh
@@ -1,56 +1,21 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Configure ZSH
|
current_dir=$(dirname "$0")
|
||||||
if [ ! -d $HOME/.oh-my-zsh ]; then
|
|
||||||
git clone https://github.com/ohmyzsh/ohmyzsh.git $HOME/.oh-my-zsh
|
if [ "$1" = "zsh" ]; then
|
||||||
|
if [ $# -gt 1 ]; then
|
||||||
|
for i in "${@:2}"; do
|
||||||
|
if [ "$i" = "install" ]; then
|
||||||
|
echo "Installing Oh My Zsh..."
|
||||||
|
zsh "$current_dir/zsh/install_ohmyzsh.sh"
|
||||||
|
elif [ "$i" = "config" ]; then
|
||||||
|
echo "Config Oh My Zsh..."
|
||||||
|
zsh "$current_dir/zsh/config_ohmyzsh.sh"
|
||||||
|
elif [ "$i" = "p10k" ]; then
|
||||||
|
echo "Config Powerlevel10k..."
|
||||||
|
zsh "$current_dir/zsh/config_p10k.sh"
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
if [ ! -d $HOME/.oh-my-zsh/plugins/zsh-autosuggestions ]; then
|
|
||||||
git clone https://github.com/zsh-users/zsh-autosuggestions.git $HOME/.oh-my-zsh/plugins/zsh-autosuggestions
|
|
||||||
fi
|
fi
|
||||||
|
echo "Run \"exec zsh\" to apply changes."
|
||||||
if [ ! -d $HOME/.oh-my-zsh/plugins/zsh-syntax-highlighting ]; then
|
|
||||||
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $HOME/.oh-my-zsh/plugins/zsh-syntax-highlighting
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $HOME/.oh-my-zsh/plugins/zsh-autocomplete ]; then
|
|
||||||
git clone https://github.com/marlonrichert/zsh-autocomplete.git $HOME/.oh-my-zsh/plugins/zsh-autocomplete
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f $HOME/.zshrc ]; then
|
|
||||||
if [ ! -f $HOME/.zshrc.bkp ]; then
|
|
||||||
mv $HOME/.zshrc $HOME/.zshrc.bkp
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
cp $HOME/.oh-my-zsh/templates/zshrc.zsh-template $HOME/.zshrc
|
|
||||||
|
|
||||||
zsh_theme_line_num=$(grep -rn -m 1 ZSH_THEME= $HOME/.zshrc | cut -d ":" -f 1)
|
|
||||||
sed -i $zsh_theme_line_num"c"\ZSH_THEME=\"polyjuice\" $HOME/.zshrc
|
|
||||||
|
|
||||||
zsh_plugin_line_number=$(grep -rn -m 2 plugins=\(git\) $HOME/.zshrc | cut -d : -f 1)
|
|
||||||
sed -i "$zsh_plugin_line_number"c"\plugins=\(zsh-autosuggestions zsh-syntax-highlighting zsh-autocomplete\)" $HOME/.zshrc
|
|
||||||
|
|
||||||
if [ -f $HOME/.oh-my-zsh/themes/polyjuice.zsh-theme ]; then
|
|
||||||
rm -rf $HOME/.oh-my-zsh/themes/polyjuice.zsh-theme
|
|
||||||
fi
|
|
||||||
|
|
||||||
path_to_theme=$(realpath $0 | sed 's/\.sh/\.zsh-theme/')
|
|
||||||
ln -i -s $path_to_theme $HOME/.oh-my-zsh/themes/polyjuice.zsh-theme
|
|
||||||
|
|
||||||
# Configure the software folder: $HOME/.software
|
|
||||||
if [ ! -d $HOME/.software ]; then
|
|
||||||
mkdir $HOME/.software
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f $HOME/.software/software_env.sh ]; then
|
|
||||||
touch $HOME/.software/software_env.sh
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if [ ! -f $HOME/.zshenv ]; then
|
|
||||||
# touch $HOME/.zshenv
|
|
||||||
# fi
|
|
||||||
|
|
||||||
# nl $HOME/.zshenv | grep \.software/software_env\.sh > /dev/null
|
|
||||||
# if [ ! $? == 0 ]; then
|
|
||||||
# echo ". $HOME/.software/software_env.sh" >> $HOME/.zshenv
|
|
||||||
# fi
|
|
17
zsh/config_ohmyzsh.sh
Normal file
17
zsh/config_ohmyzsh.sh
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
current_dir=$(dirname "$0")
|
||||||
|
|
||||||
|
# copying $HOME/.zshrc
|
||||||
|
if [ -f "$HOME/.zshrc" ]; then
|
||||||
|
if [ ! -f "$HOME/.zshrc.bkp" ]; then
|
||||||
|
mv "$HOME/.zshrc" "$HOME/.zshrc.bkp"
|
||||||
|
cp "$current_dir/zshrc" "$HOME/.zshrc"
|
||||||
|
else
|
||||||
|
echo "Backup file already exists. Please remove $HOME/.zshrc.bkp and try again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
cp "$current_dir/zshrc" "$HOME/.zshrc"
|
||||||
|
fi
|
||||||
|
|
5
zsh/config_p10k.sh
Normal file
5
zsh/config_p10k.sh
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
current_dir=$(dirname "$0")
|
||||||
|
|
||||||
|
cp "$current_dir/p10k.zsh" "$HOME/.p10k.zsh"
|
108
zsh/install_ohmyzsh.sh
Normal file
108
zsh/install_ohmyzsh.sh
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
echo "$SHELL" | grep -q zsh
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Please run this script in zsh shell."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# git, fzf, zoxide are required
|
||||||
|
if ! command -v git >/dev/null 2>&1; then
|
||||||
|
echo "Git is not installed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v fzf >/dev/null 2>&1; then
|
||||||
|
echo "FZF is not installed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v zoxide >/dev/null 2>&1; then
|
||||||
|
echo "Zoxide is not installed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v python >/dev/null 2>&1; then
|
||||||
|
echo "Zoxide is not installed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Path
|
||||||
|
PATH_OHMYZSH="$HOME"/.oh-my-zsh
|
||||||
|
PATH_OHMYZSH_CUSTOM_PLUGINS="$PATH_OHMYZSH"/custom/plugins
|
||||||
|
PATH_OHMYZSH_CUSTOM_THEMES="$PATH_OHMYZSH"/custom/themes
|
||||||
|
|
||||||
|
# git clone oh-my-zsh
|
||||||
|
if [ ! -d "$PATH_OHMYZSH" ]; then
|
||||||
|
echo "Oh My Zsh is not downloaded. Downloading..."
|
||||||
|
git clone https://github.com/ohmyzsh/ohmyzsh.git "$PATH_OHMYZSH"
|
||||||
|
else
|
||||||
|
cd "$PATH_OHMYZSH" || exit 2
|
||||||
|
if [ ! -d .git ]; then
|
||||||
|
echo "Oh My Zsh is not a git repository. Please remove $PATH_OHMYZSH and try again."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Oh My Zsh is already exist. Updating..."
|
||||||
|
git pull
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# git clone zsh-autosuggestions
|
||||||
|
if [ ! -d "$PATH_OHMYZSH_CUSTOM_PLUGINS"/zsh-autosuggestions ]; then
|
||||||
|
echo "Zsh Autosuggestions is not downloaded. Downloading..."
|
||||||
|
git clone https://github.com/zsh-users/zsh-autosuggestions.git "$PATH_OHMYZSH_CUSTOM_PLUGINS"/zsh-autosuggestions
|
||||||
|
else
|
||||||
|
cd "$PATH_OHMYZSH_CUSTOM_PLUGINS"/zsh-autosuggestions || exit 1
|
||||||
|
if [ ! -d .git ]; then
|
||||||
|
echo "Zsh Autosuggestions is not a git repository. Please remove $PATH_OHMYZSH_CUSTOM_PLUGINS/zsh-autosuggestions and try again."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Zsh Autosuggestions is already exist. Updating..."
|
||||||
|
git pull
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# git clone zsh-syntax-highlighting
|
||||||
|
if [ ! -d "$PATH_OHMYZSH_CUSTOM_PLUGINS"/zsh-syntax-highlighting ]; then
|
||||||
|
echo "Zsh Syntax Highlighting is not downloaded. Downloading..."
|
||||||
|
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$PATH_OHMYZSH_CUSTOM_PLUGINS"/zsh-syntax-highlighting
|
||||||
|
else
|
||||||
|
cd "$PATH_OHMYZSH_CUSTOM_PLUGINS"/zsh-syntax-highlighting || exit 1
|
||||||
|
if [ ! -d .git ]; then
|
||||||
|
echo "Zsh Syntax Highlighting is not a git repository. Please remove $PATH_OHMYZSH_CUSTOM_PLUGINS/zsh-syntax-highlighting and try again."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Zsh Syntax Highlighting is already exist. Updating..."
|
||||||
|
git pull
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# git clone zsh-autocomplete
|
||||||
|
if [ ! -d "$PATH_OHMYZSH_CUSTOM_PLUGINS"/zsh-autocomplete ]; then
|
||||||
|
echo "Zsh Autocomplete is not downloaded. Downloading..."
|
||||||
|
git clone https://github.com/marlonrichert/zsh-autocomplete.git "$PATH_OHMYZSH_CUSTOM_PLUGINS"/zsh-autocomplete
|
||||||
|
else
|
||||||
|
cd "$PATH_OHMYZSH_CUSTOM_PLUGINS"/zsh-autocomplete || exit 1
|
||||||
|
if [ ! -d .git ]; then
|
||||||
|
echo "Zsh Autocomplete is not a git repository. Please remove $PATH_OHMYZSH_CUSTOM_PLUGINS/zsh-autocomplete and try again."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Zsh Autocomplete is already exist. Updating..."
|
||||||
|
git pull
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# git clone powerlevel10k
|
||||||
|
if [ ! -d "$PATH_OHMYZSH_CUSTOM_THEMES"/powerlevel10k ]; then
|
||||||
|
echo "Powerlevel10k is not downloaded. Downloading..."
|
||||||
|
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "$PATH_OHMYZSH_CUSTOM_THEMES"/powerlevel10k
|
||||||
|
else
|
||||||
|
cd "$PATH_OHMYZSH_CUSTOM_THEMES/powerlevel10k" || exit 1
|
||||||
|
if [ ! -d .git ]; then
|
||||||
|
echo "Zsh Autocomplete is not a git repository. Please remove $PATH_OHMYZSH_CUSTOM_THEMES/powerlevel10k and try again."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Powerlevel10k is already exist. Updating..."
|
||||||
|
git pull
|
||||||
|
fi
|
||||||
|
fi
|
1746
zsh/p10k.zsh
Normal file
1746
zsh/p10k.zsh
Normal file
File diff suppressed because it is too large
Load Diff
122
zsh/zshrc
Normal file
122
zsh/zshrc
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
|
# If you come from bash you might have to change your $PATH.
|
||||||
|
# export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH
|
||||||
|
|
||||||
|
# Path to your Oh My Zsh installation.
|
||||||
|
export ZSH="$HOME/.oh-my-zsh"
|
||||||
|
|
||||||
|
# Set name of the theme to load --- if set to "random", it will
|
||||||
|
# load a random theme each time Oh My Zsh is loaded, in which case,
|
||||||
|
# to know which specific one was loaded, run: echo $RANDOM_THEME
|
||||||
|
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
|
||||||
|
ZSH_THEME="powerlevel10k/powerlevel10k"
|
||||||
|
|
||||||
|
# Set list of themes to pick from when loading at random
|
||||||
|
# Setting this variable when ZSH_THEME=random will cause zsh to load
|
||||||
|
# a theme from this variable instead of looking in $ZSH/themes/
|
||||||
|
# If set to an empty array, this variable will have no effect.
|
||||||
|
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
|
||||||
|
|
||||||
|
# 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 one of the following lines to change the auto-update behavior
|
||||||
|
# zstyle ':omz:update' mode disabled # disable automatic updates
|
||||||
|
# zstyle ':omz:update' mode auto # update automatically without asking
|
||||||
|
# zstyle ':omz:update' mode reminder # just remind me to update when it's time
|
||||||
|
|
||||||
|
# Uncomment the following line to change how often to auto-update (in days).
|
||||||
|
# zstyle ':omz:update' frequency 13
|
||||||
|
|
||||||
|
# Uncomment the following line if pasting URLs and other text is messed up.
|
||||||
|
# DISABLE_MAGIC_FUNCTIONS="true"
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
# You can also set it to another string to have that shown instead of the default red dots.
|
||||||
|
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
|
||||||
|
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
|
||||||
|
# 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.
|
||||||
|
# You can set one of the optional three formats:
|
||||||
|
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
|
||||||
|
# or set a custom format using the strftime function format specifications,
|
||||||
|
# see 'man strftime' for details.
|
||||||
|
# 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?
|
||||||
|
# Standard plugins can be found in $ZSH/plugins/
|
||||||
|
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
|
||||||
|
# Example format: plugins=(rails git textmate ruby lighthouse)
|
||||||
|
# Add wisely, as too many plugins slow down shell startup.
|
||||||
|
plugins=(
|
||||||
|
zsh-autosuggestions
|
||||||
|
zsh-syntax-highlighting
|
||||||
|
zsh-autocomplete
|
||||||
|
zsh-interactive-cd
|
||||||
|
zoxide
|
||||||
|
fzf
|
||||||
|
python
|
||||||
|
)
|
||||||
|
|
||||||
|
source $ZSH/oh-my-zsh.sh
|
||||||
|
|
||||||
|
# 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='nvim'
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# Compilation flags
|
||||||
|
# export ARCHFLAGS="-arch $(uname -m)"
|
||||||
|
|
||||||
|
# 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 a top-level file in
|
||||||
|
# the $ZSH_CUSTOM folder, with .zsh extension. Examples:
|
||||||
|
# - $ZSH_CUSTOM/aliases.zsh
|
||||||
|
# - $ZSH_CUSTOM/macos.zsh
|
||||||
|
# For a full list of active aliases, run `alias`.
|
||||||
|
#
|
||||||
|
# Example aliases
|
||||||
|
# alias zshconfig="mate ~/.zshrc"
|
||||||
|
# alias ohmyzsh="mate ~/.oh-my-zsh"
|
||||||
|
|
||||||
|
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
|
||||||
|
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
Reference in New Issue
Block a user