Commit 69591154 authored by cupric's avatar cupric
Browse files

Revert "broken"

This reverts commit 9efd4cf6.
No related merge requests found
Showing with 92 additions and 176 deletions
+92 -176
......@@ -24,6 +24,7 @@ fi
# The completion system needs to be activated.
autoload -Uz compinit && compinit
autoload -Uz promptinit && promptinit && prompt powerlevel10k
# Auto-completion case-insensitive
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
......@@ -89,51 +90,44 @@ if [ "$(ls $ZLOCAL)" ]; then
fi
# Antidote Plug Manager
# ~/.zshrc
# You can change the names/locations of these if you prefer.
antidote_dir=$HOME/.cache/antidote
export ANTIDOTE_HOME=$antidote_dir
plugins_txt=$ZSH_CUSTOM/plugins.txt
static_file=$ZSH_CUSTOM/plugins.zsh
# Clone antidote if necessary and generate a static plugin file.
if [[ ! $static_file -nt $plugins_txt ]]; then
[[ -e $antidote_dir ]] ||
git clone --depth=1 https://github.com/mattmc3/antidote.git $antidote_dir
(
source $antidote_dir/antidote.zsh
[[ -e $plugins_txt ]] || touch $plugins_txt
antidote bundle <$plugins_txt >$static_file
)
fi
# Uncomment this if you want antidote commands like `antidote update` available
# in your interactive shell session:
autoload -Uz $antidote_dir/functions/antidote
# Check to see if it's installed (and in the path)
[ ! -d "$antidote_dir" ] && git clone --depth=1 https://github.com/mattmc3/antidote.git $antidote_dir
source $antidote_dir/antidote.zsh
# generate zsh_plugins.zsh
antidote bundle <$ZHOME/plugins.txt >$ZHOME/plugins.zsh
# source the static plugins file
source $static_file
# Powerline loading
# powerline-daemon -q
# . /usr/share/powerline/bindings/zsh/powerline.zsh
# Initialize enhancd
ENHANCD_FILTER=fzf; export ENHANCD_FILTER
source "$antidote_dir/https-COLON--SLASH--SLASH-github.com-SLASH-b4b4r07-SLASH-enhancd/init.sh"
# cleanup
unset antidote_dir plugins_txt static_file
ENHANCD_FILTER=fzy; export ENHANCD_FILTER
source "$HOME/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-b4b4r07-SLASH-enhancd/init.sh"
# Set docker-compose alias for v1
docker-compose --version &> /dev/null
if [ $? -eq 0 ]; then
alias dc="docker-compose"
# Set docker-compose alias for v2
docker compose --version &> /dev/null
elif [ $? -eq 0 ]; then
alias dc="docker compose"
fi
# Load custom key bindings
source "$ZSH_CUSTOM/keybindings.zsh"
# Fzf configuration
source "$ZSH_CUSTOM/fzf_keybindings.zsh"
bindkey '^G' fzf-file-widget
bindkey '^D' fzf-file-widget
# export FZF_COMPLETION_TRIGGER=''
# bindkey '^Tab' fzf-completion
# bindkey '^I' $fzf_default_completion
# Start tmux by default
# ZSH_TMUX_AUTOSTART=false
# Load tmux bundle if installed
command -v tmux &>/dev/null && ZSH_TMUX_AUTOSTART=false
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f $ZSH_CUSTOM/p10k.zsh ]] || source $ZSH_CUSTOM/p10k.zsh
# autoload -Uz promptinit && promptinit && prompt p10k
......@@ -32,5 +32,7 @@ zdharma-continuum/fast-syntax-highlighting kind:defer
zsh-users/zsh-autosuggestions
# prompts:
# with prompt plugins, remember to add this to your .zshrc:
# `autoload -Uz promptinit && promptinit && prompt pure`
# Powerlevel 10k
romkatv/powerlevel10k kind:fpath
File moved
......@@ -24,17 +24,6 @@ if [ $? -eq 0 ]; then
export EDITOR=nvim;
fi
# Set docker-compose alias for v1
docker-compose --version &> /dev/null
if [ $? -eq 0 ]; then
alias dc="docker-compose"
# Set docker-compose alias for v2
docker compose --version &> /dev/null
elif [ $? -eq 0 ]; then
alias dc="docker compose"
fi
alias ...=../..
alias ....=../../..
alias .....=../../../..
......@@ -51,8 +40,9 @@ alias 9='cd -9'
alias _='sudo '
alias afind='ack -il'
alias bwe='export BW_SESSION=$( bw unlock --raw )'
alias cd='__enhancd::cd'
alias cd=__enhancd::cd
alias cp='nocorrect cp'
# dc alias set in init file
alias dcd='dc down'
alias dcl='dc logs -f'
alias dcu='dc up'
......@@ -70,8 +60,8 @@ alias di='wget -O - https://gitlab.ogbase.net/cupric/dot/-/raw/main/init.sh | ba
alias dri='ssh -o RemoteCommand="wget -O - https://gitlab.ogbase.net/cupric/dot/-/raw/main/init.sh | bash"'
alias ebuild='nocorrect ebuild'
alias egrep='egrep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}'
alias explain='explain-command'
alias explain-last='explain-last-command'
alias explain=explain-command
alias explain-last=explain-last-command
alias ezsh='subl ~/.zsh/.zshrc'
alias fgrep='fgrep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}'
alias g=git
......@@ -122,9 +112,9 @@ alias gco='git checkout'
alias gcor='git checkout --recurse-submodules'
alias gcount='git shortlog -sn'
alias gcp='git cherry-pick'
alias gcpa='git cherry-pick --abort'
alias gcpc='git cherry-pick --continue'
alias gcs='git commit -S'
alias gcpa='git cherry-pick --abort'curl -sS https://starship.rs/install.sh | sh
alias gcpc='git cherry-pick --continue' alias gcs='git commit -S'
alias gcsm='git commit -s -m'
alias gcss='git commit -S -s'
alias gcssm='git commit -S -s -m'
......@@ -142,7 +132,7 @@ alias gfo='git fetch origin'
alias gg='git gui citool'
alias gga='git gui citool --amend'
alias ggpull='git pull origin "$(git_current_branch)"'
alias ggpur='ggu'
alias ggpur=ggu
alias ggpush='git push origin "$(git_current_branch)"'
alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
alias ghh='git help'
......@@ -167,7 +157,7 @@ alias gloga='git log --oneline --decorate --graph --all'
alias glol='git log --graph --pretty='\''%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'
alias glola='git log --graph --pretty='\''%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --all'
alias glols='git log --graph --pretty='\''%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --stat'
alias glp='_git_log_prettily'
alias glp=_git_log_prettily
alias glum='git pull upstream $(git_main_branch)'
alias gm='git merge'
alias gma='git merge --abort'
......@@ -265,8 +255,8 @@ alias pipir='pip install -r requirements.txt'
alias pipreq='pip freeze > requirements.txt'
alias pipunall='pipreq && pip uninstall -r requirements.txt -y && rm -rf requirements.txt'
alias pipupall='pipreq && sed -i '\''s/==/>=/g'\'' requirements.txt && pip install -r requirements.txt --upgrade && rm -rf requirements.txt'
alias please='sudo'
alias plz='sudo'
alias please=sudo
alias plz=sudo
alias rd='rm -d'
alias reboot_windows='sudo gksu grub-reboot 2 && sudo gksu reboot'
alias rsynccopy='rsync --stats --partial --progress --append --rsh=ssh -r -h'
......@@ -275,9 +265,9 @@ alias sc='sudo systemctl'
alias scstart='sudo systemctl start'
alias scstat='sudo systemctl status'
alias scstop='sudo systemctl stop'
alias subl='/opt/sublime_text/sublime_text'
alias subl=/opt/sublime_text/sublime_text
alias sudo=$'nocorrect sudo\t'
alias which-command='whence'
alias which-command=whence
alias xc='xclip -selection clipboard'
alias zgu='git -C ~/.zsh pull origin master && exec zsh'
alias zgi='wget -O - https://gitlab.ogbase.net/cupric/zsh/-/raw/master/init.sh | bash'
......
# ZSH Theme - Preview: http://dl.dropbox.com/u/4109351/pics/gnzh-zsh-theme.png
# Based on bira theme
setopt prompt_subst
() {
local PR_USER PR_USER_OP PR_PROMPT PR_HOST
# Check the UID
if [[ $UID -ne 0 ]]; then # normal user
PR_USER='%F{green}%n%f'
PR_USER_OP='%F{green}%#%f'
PR_PROMPT='%f➤ %f'
else # root
PR_USER='%F{red}%n%f'
PR_USER_OP='%F{red}%#%f'
PR_PROMPT='%F{red}➤ %f'
fi
# Check if we are on SSH or not
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
PR_HOST='%F{red}%M%f' # SSH
else
PR_HOST='%F{green}%M%f' # no SSH
fi
local return_code="%(?..%F{red}%? ↵%f)"
local user_host="${PR_USER}%F{cyan}@${PR_HOST}"
local current_dir="%B%F{blue}%~%f%b"
local rvm_ruby=''
if ${HOME}/.rvm/bin/rvm-prompt &> /dev/null; then # detect user-local rvm installation
rvm_ruby='%F{red}‹$(${HOME}/.rvm/bin/rvm-prompt i v g s)›%f'
elif which rvm-prompt &> /dev/null; then # detect system-wide rvm installation
rvm_ruby='%F{red}‹$(rvm-prompt i v g s)›%f'
elif which rbenv &> /dev/null; then # detect Simple Ruby Version Management
rvm_ruby='%F{red}‹$(rbenv version | sed -e "s/ (set.*$//")›%f'
fi
local git_branch='$(git_prompt_info)'
PROMPT="╭─${user_host} ${current_dir} ${rvm_ruby} ${git_branch}
╰─$PR_PROMPT "
RPROMPT="[%D{%y/%m/%f}|%@]${return_code}"
ZSH_THEME_GIT_PROMPT_PREFIX="%F{yellow}‹"
ZSH_THEME_GIT_PROMPT_SUFFIX="› %f"
}
# ____ ____
# / __/___ / __/
# / /_/_ / / /_
# / __/ / /_/ __/
# /_/ /___/_/ key-bindings.zsh
#
# - $FZF_TMUX_OPTS
# - $FZF_CTRL_T_COMMAND
# - $FZF_CTRL_T_OPTS
# - $FZF_CTRL_R_OPTS
# - $FZF_ALT_C_COMMAND
# - $FZF_ALT_C_OPTS
# Key bindings
# ------------
# The code at the top and the bottom of this file is the same as in completion.zsh.
# Refer to that file for explanation.
if 'zmodload' 'zsh/parameter' 2>'/dev/null' && (( ${+options} )); then
__fzf_key_bindings_options="options=(${(j: :)${(kv)options[@]}})"
else
() {
__fzf_key_bindings_options="setopt"
'local' '__fzf_opt'
for __fzf_opt in "${(@)${(@f)$(set -o)}%% *}"; do
if [[ -o "$__fzf_opt" ]]; then
__fzf_key_bindings_options+=" -o $__fzf_opt"
else
__fzf_key_bindings_options+=" +o $__fzf_opt"
fi
done
}
fi
'emulate' 'zsh' '-o' 'no_aliases'
{
[[ -o interactive ]] || return 0
# CTRL-T - Paste the selected file path(s) into the command line
__fsel() {
local cmd="${FZF_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
-o -type f -print \
-o -type d -print \
-o -type l -print 2> /dev/null | cut -b3-"}"
setopt localoptions pipefail no_aliases 2> /dev/null
local item
eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} ${FZF_CTRL_T_OPTS-}" $(__fzfcmd) -m "$@" | while read item; do
echo -n "${(q)item} "
done
local ret=$?
echo
return $ret
}
__fzfcmd() {
[ -n "${TMUX_PANE-}" ] && { [ "${FZF_TMUX:-0}" != 0 ] || [ -n "${FZF_TMUX_OPTS-}" ]; } &&
echo "fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- " || echo "fzf"
}
fzf-file-widget() {
LBUFFER="${LBUFFER}$(__fsel)"
local ret=$?
zle reset-prompt
return $ret
}
zle -N fzf-file-widget
bindkey -M emacs '^T' fzf-file-widget
bindkey -M vicmd '^T' fzf-file-widget
bindkey -M viins '^T' fzf-file-widget
# ALT-C - cd into the selected directory
fzf-cd-widget() {
local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
-o -type d -print 2> /dev/null | cut -b3-"}"
setopt localoptions pipefail no_aliases 2> /dev/null
local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} ${FZF_ALT_C_OPTS-}" $(__fzfcmd) +m)"
if [[ -z "$dir" ]]; then
zle redisplay
return 0
fi
zle push-line # Clear buffer. Auto-restored on next prompt.
BUFFER="builtin cd -- ${(q)dir}"
zle accept-line
local ret=$?
unset dir # ensure this doesn't end up appearing in prompt expansion
zle reset-prompt
return $ret
}
zle -N fzf-cd-widget
bindkey -M emacs '\ec' fzf-cd-widget
bindkey -M vicmd '\ec' fzf-cd-widget
bindkey -M viins '\ec' fzf-cd-widget
# CTRL-R - Paste the selected command from history into the command line
fzf-history-widget() {
local selected num
setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2> /dev/null
selected=( $(fc -rl 1 | awk '{ cmd=$0; sub(/^[ \t]*[0-9]+\**[ \t]+/, "", cmd); if (!seen[cmd]++) print $0 }' |
FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} ${FZF_DEFAULT_OPTS-} -n2..,.. --scheme=history --bind=ctrl-r:toggle-sort,ctrl-z:ignore ${FZF_CTRL_R_OPTS-} --query=${(qqq)LBUFFER} +m" $(__fzfcmd)) )
local ret=$?
if [ -n "$selected" ]; then
num=$selected[1]
if [ -n "$num" ]; then
zle vi-fetch-history -n $num
fi
fi
zle reset-prompt
return $ret
}
zle -N fzf-history-widget
bindkey -M emacs '^R' fzf-history-widget
bindkey -M vicmd '^R' fzf-history-widget
bindkey -M viins '^R' fzf-history-widget
} always {
eval $__fzf_key_bindings_options
'unset' '__fzf_key_bindings_options'
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment