Created
July 19, 2022 06:49
-
-
Save salman0ansari/98dd909c1e239430f62e456262533b6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Plugin manager | |
ZPLUGINDIR=$HOME/.zsh/plugins | |
# if you want to use unplugged, you can copy/paste plugin-clone here, or just pull the repo | |
if [[ ! -d $ZPLUGINDIR/zsh_unplugged ]]; then | |
echo "Cloning mattmc3/zsh_unplugged" | |
git clone https://github.com/mattmc3/zsh_unplugged $ZPLUGINDIR/zsh_unplugged --quiet | |
fi | |
source $ZPLUGINDIR/zsh_unplugged/zsh_unplugged.plugin.zsh | |
# use curl download single file and source it | |
function load-files () { | |
local file_name dir_name | |
for url in $@; do | |
file_name=${${url##*/}%} | |
dir_name="${ZPLUGINDIR:-$HOME/.zsh/plugins}/$file_name" | |
if [[ ! -d $dir_name ]]; then | |
mkdir -p $dir_name | |
fi | |
if [[ ! -f $dir_name/$file_name ]]; then | |
echo "Downloading $url..." | |
curl -sSL $url -o $dir_name/$file_name | |
fi | |
fpath+=$dir_name | |
if (( $+functions[zsh-defer] )); then | |
zsh-defer source $dir_name/$file_name | |
else | |
source $dir_name/$file_name | |
fi | |
done | |
} | |
### Basic config | |
autoload -U compinit | |
compinit | |
### History | |
HISTFILE=~/.zsh_history | |
setopt HIST_IGNORE_DUPS | |
HISTSIZE='128000' | |
SAVEHIST='128000' | |
### Plugins | |
plugins=( | |
# use zsh-defer magic to load the remaining plugins at hypersonic speed! | |
romkatv/zsh-defer | |
# core plugins | |
zsh-users/zsh-autosuggestions | |
zsh-users/zsh-history-substring-search | |
zsh-users/zsh-completions | |
# user plugins | |
rupa/z | |
hlissner/zsh-autopair | |
djui/alias-tips | |
peterhurford/up.zsh | |
# load this one last | |
zsh-users/zsh-syntax-highlighting | |
) | |
files=( | |
# ohmyzsh | |
https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/colored-man-pages/colored-man-pages.plugin.zsh | |
https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/git/git.plugin.zsh | |
https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/common-aliases/common-aliases.plugin.zsh | |
https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh | |
https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/extract/extract.plugin.zsh | |
https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/fzf/fzf.plugin.zsh | |
) | |
# clone, source, and add to fpath | |
plugin-load $plugins | |
load-files $files | |
### Fzf | |
export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude .git || git ls-tree -r --name-only HEAD || rg --files --hidden --follow --glob '!.git' || find ." | |
export FZF_DEFAULT_OPTS='--height 40% --layout=reverse' | |
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" | |
export FZF_CTRL_T_OPTS="--preview '(bat --style=plain --color=always {} || cat {} || tree -NC {}) 2> /dev/null | head -200'" | |
export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden:wrap --bind '?:toggle-preview' --exact" | |
export FZF_ALT_C_OPTS="--preview 'tree -NC {} | head -200'" | |
### Alias | |
# Basic | |
alias ls="ls --color" | |
alias python="python3" | |
alias k="kubectl" | |
# Prettify ls | |
if (( $+commands[gls] )); then | |
alias ls='gls --color=tty --group-directories-first' | |
fi | |
# Emacs | |
alias te='emacs -nw --no-desktop' | |
alias me='emacs -q -l ~/.config/emacs/lisp/init-eat.el' | |
alias mte='emacs -nw -q -l ~/.config/emacs/lisp/init-eat.el' | |
alias e='emacsclient -a "" -c -n' | |
# Modern Unix Tools | |
# See https://github.com/ibraheemdev/modern-unix | |
alias diff="delta" | |
alias find="fd" | |
alias grep="rg" | |
alias cat="bat" | |
### Vterm | |
# https://github.com/akermu/emacs-libvterm#shell-side-configuration | |
vterm_printf(){ | |
if [ -n "$TMUX" ] && ([ "${TERM%%-*}" = "tmux" ] || [ "${TERM%%-*}" = "screen" ] ); then | |
# Tell tmux to pass the escape sequences through | |
printf "\ePtmux;\e\e]%s\007\e\\" "$1" | |
elif [ "${TERM%%-*}" = "screen" ]; then | |
# GNU screen (screen, screen-256color, screen-256color-bce) | |
printf "\eP\e]%s\007\e\\" "$1" | |
else | |
printf "\e]%s\e\\" "$1" | |
fi | |
} | |
# https://github.com/akermu/emacs-libvterm#message-passing | |
vterm_cmd() { | |
local vterm_elisp | |
vterm_elisp="" | |
while [ $# -gt 0 ]; do | |
vterm_elisp="$vterm_elisp""$(printf '"%s" ' "$(printf "%s" "$1" | sed -e 's|\\|\\\\|g' -e 's|"|\\"|g')")" | |
shift | |
done | |
vterm_printf "51;E$vterm_elisp" | |
} | |
find_file() { | |
vterm_cmd find-file "$(realpath "${@:-.}")" | |
} | |
if [[ "$INSIDE_EMACS" = 'vterm' ]]; then | |
alias e='find_file' | |
fi | |
### Local customizations, e.g. theme, plugins, aliases, etc. | |
[ -f $HOME/.zshrc.local ] && source $HOME/.zshrc.local |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment