refactor:

- use `zap-zsh` instead of manual plugin manager
- rename local plugins to meet naming conventions
This commit is contained in:
Tri Vo Khac committed 2023-06-05 13:08:15 +07:00
1 parent c0726ccec6
commit 1d04de7401
6 files changed
+17 -137

No files matched your search

-1
View File
@@ -1,5 +1,4 @@
.zcompdump
.zsh_history
plugins/
.zcompcache/
.zsh_sessions/
+14 -63
View File
@@ -1,77 +1,28 @@
#!/usr/bin/env zsh
# Created by Zap installer
[ -f "${XDG_DATA_HOME:-$HOME/.local/share}/zap/zap.zsh" ] && source "${XDG_DATA_HOME:-$HOME/.local/share}/zap/zap.zsh"
# some useful options (man zshoptions)
setopt AUTO_CD EXTENDED_GLOB NOMATCH MENU_COMPLETE
setopt INTERACTIVE_COMMENTS
stty stop undef # Disable ctrl-s to freeze terminal.
zle_highlight=('paste:none')
# history
setopt APPEND_HISTORY
setopt INC_APPEND_HISTORY
setopt HIST_EXPIRE_DUPS_FIRST
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_SPACE
setopt HIST_FIND_NO_DUPS
setopt HIST_SAVE_NO_DUPS
unsetopt EXTENDED_HISTORY
# beeping is annoying
unsetopt BEEP
# remove % symbol on prompt
unsetopt PROMPT_SP
# completions
# for brew
if type brew &>/dev/null
then
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
fi
autoload -Uz compinit
zstyle ':completion:*' menu select
# zstyle ':completion::complete:lsof:*' menu yes select
zmodload zsh/complist
# compinit
_comp_options+=(globdots) # Include hidden files.
autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
# Colors
autoload -Uz colors && colors
# Useful Functions
source "$ZDOTDIR/zsh-functions"
# Normal files to source
zsh_add_file "zsh-exports"
zsh_add_file "zsh-aliases"
zsh_add_file "zsh-eval"
# Plugins
repos=(
# remote plugins
zsh-users/zsh-autosuggestions
zsh-users/zsh-completions
wintermi/zsh-brew
wintermi/zsh-lsd
zap-zsh/supercharge
zap-zsh/fzf
zap-zsh/fnm
zdharma-continuum/fast-syntax-highlighting
hlissner/zsh-autopair
wintermi/zsh-lsd
# local plugins
"$ZDOTDIR/aliases.zsh"
"$ZDOTDIR/exports.zsh"
"$ZDOTDIR/eval.zsh"
)
plugin-load $repos
for repo in $repos; do plug $repo; done
# Clean startup prompt
! [ -f ~/.hushlogin ] && touch ~/.hushlogin
# Load and initialise completion system
autoload -Uz compinit
compinit
# Edit line in vim with ctrl-e:
autoload edit-command-line; zle -N edit-command-line
# bindkey '^e' edit-command-line
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env zsh
[ -x "$(command -v bat)" ] && alias cat="bat"
[ -x "$(command -v codium)" ] && alias code="codium"
@@ -1,6 +1,5 @@
#!/usr/bin/env bash
#!/usr/bin/env zsh
[ -f /opt/homebrew/bin/brew ] && eval "$(/opt/homebrew/bin/brew shellenv)"
command -v zoxide > /dev/null 2>&1 && eval "$(zoxide init zsh)"
command -v starship > /dev/null 2>&1 && eval "$(starship init zsh)"
command -v opam > /dev/null 2>&1 && eval $(opam env)
@@ -1,11 +1,10 @@
#!/usr/bin/env bash
#!/usr/bin/env zsh
HISTFILE="$ZDOTDIR"/.zsh_history
HISTSIZE=1000000
SAVEHIST=1000000
export MANWIDTH=999
export PATH="$HOME/.local/bin":$PATH
export EDITOR="micro"
export PAGE="bat"
-68
View File
@@ -1,68 +0,0 @@
#!/usr/bin/env zsh
# Function to source files if they exist
function zsh_add_file() {
[ -f "$ZDOTDIR/$1" ] && source "$ZDOTDIR/$1"
}
function zsh_add_plugin() {
PLUGIN_NAME=$(echo $1 | cut -d "/" -f 2)
if [ -d "$ZDOTDIR/plugins/$PLUGIN_NAME" ]; then
# For plugins
zsh_add_file "plugins/$PLUGIN_NAME/$PLUGIN_NAME.plugin.zsh" || \
zsh_add_file "plugins/$PLUGIN_NAME/$PLUGIN_NAME.zsh"
else
git clone "https://github.com/$1.git" "$ZDOTDIR/plugins/$PLUGIN_NAME"
fi
}
function zsh_add_completion() {
PLUGIN_NAME=$(echo $1 | cut -d "/" -f 2)
if [ -d "$ZDOTDIR/plugins/$PLUGIN_NAME" ]; then
# For completions
completion_file_path=$(ls $ZDOTDIR/plugins/$PLUGIN_NAME/_*)
fpath+="$(dirname "${completion_file_path}")"
zsh_add_file "plugins/$PLUGIN_NAME/$PLUGIN_NAME.plugin.zsh"
else
git clone "https://github.com/$1.git" "$ZDOTDIR/plugins/$PLUGIN_NAME"
fpath+=$(ls $ZDOTDIR/plugins/$PLUGIN_NAME/_*)
[ -f $ZDOTDIR/.zccompdump ] && $ZDOTDIR/.zccompdump
fi
completion_file="$(basename "${completion_file_path}")"
[ "$2" = true ] && compinit "${completion_file:1}"
}
# https://github.com/mattmc3/zsh_unplugged
function plugin-load {
local repo plugdir initfile
ZPLUGINDIR=${ZPLUGINDIR:-${ZDOTDIR:-$HOME/.config/zsh}/plugins}
for repo in $@; do
plugdir=$ZPLUGINDIR/${repo:t}
initfile=$plugdir/${repo:t}.plugin.zsh
if [[ ! -d $plugdir ]]; then
echo "Cloning $repo..."
git clone -q --depth 1 --recursive --shallow-submodules https://github.com/$repo $plugdir
fi
if [[ ! -e $initfile ]]; then
local -a initfiles=($plugdir/*.plugin.{z,}sh(N) $plugdir/*.{z,}sh{-theme,}(N))
(( $#initfiles )) || { echo >&2 "No init file found '$repo'." && continue; }
ln -sf "${initfiles[1]}" "$initfile"
fi
fpath+=$plugdir
(( $+functions[zsh-defer] )) && zsh-defer . $initfile || . $initfile
done
}
function plugin-update {
ZPLUGINDIR=${ZPLUGINDIR:-$HOME/.config/zsh/plugins}
for d in $ZPLUGINDIR/*/.git(/); do
echo "Updating ${d:h:t}..."
command git -C "${d:h}" pull --ff --recurse-submodules --depth 1 --rebase --autostash
done
}
function plugin-list {
for d in $ZPLUGINDIR/*/.git; do
git -C "${d:h}" remote get-url origin
done
}