[zsh] added tmux plugin, cleaned git plugin and themes
This commit is contained in:
parent
3cb8cae14c
commit
59e4ce27de
11 changed files with 209 additions and 273 deletions
|
@ -1,3 +0,0 @@
|
|||
abbr "i"="sudo pacman -S"
|
||||
abbr "r"="sudo pacman -Rns"
|
||||
abbr "s"="sudo pacman -Ss"
|
|
@ -28,7 +28,6 @@ setopt HIST_SAVE_NO_DUPS
|
|||
setopt HIST_IGNORE_ALL_DUPS
|
||||
setopt HIST_VERIFY
|
||||
|
||||
|
||||
#Set EDITOR AND READER
|
||||
export EDITOR=nvim
|
||||
export VISUAL=nvim
|
||||
|
@ -46,28 +45,25 @@ fpath+=$ZDOTDIR/prompts/pure
|
|||
autoload -U promptinit; promptinit
|
||||
prompt pure
|
||||
|
||||
source $ZDOTDIR/dotfiles.zsh
|
||||
source $ZDOTDIR/qol.zsh
|
||||
source $ZDOTDIR/replacements.zsh
|
||||
source $ZDOTDIR/overrides.zsh
|
||||
source $ZDOTDIR/functions.zsh
|
||||
source $ZDOTDIR/plugins.zsh
|
||||
|
||||
# >>> conda initialize >>>
|
||||
# !! Contents within this block are managed by 'conda init' !!
|
||||
__conda_setup="$('/Users/afonso/.miniforge3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
|
||||
__conda_setup="$('$HOME/.miniforge3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
|
||||
if [ $? -eq 0 ]; then
|
||||
eval "$__conda_setup"
|
||||
else
|
||||
if [ -f "/Users/afonso/.miniforge3/etc/profile.d/conda.sh" ]; then
|
||||
. "/Users/afonso/.miniforge3/etc/profile.d/conda.sh"
|
||||
if [ -f "$HOME/.miniforge3/etc/profile.d/conda.sh" ]; then
|
||||
. "$HOME/.miniforge3/etc/profile.d/conda.sh"
|
||||
else
|
||||
export PATH="/Users/afonso/.miniforge3/bin:$PATH"
|
||||
export PATH="$HOME/.miniforge3/bin:$PATH"
|
||||
fi
|
||||
fi
|
||||
unset __conda_setup
|
||||
|
||||
if [ -f "/Users/afonso/.miniforge3/etc/profile.d/mamba.sh" ]; then
|
||||
. "/Users/afonso/.miniforge3/etc/profile.d/mamba.sh"
|
||||
if [ -f "$HOME/.miniforge3/etc/profile.d/mamba.sh" ]; then
|
||||
. "$HOME/.miniforge3/etc/profile.d/mamba.sh"
|
||||
fi
|
||||
|
||||
# <<< conda initialize <<<
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
# ~/.config/zsh/myfunctions/dotfiles.zsh
|
||||
|
||||
alias config="/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME"
|
||||
|
||||
alias lc="lazygit --git-dir=$HOME/dotfiles/ --work-tree=$HOME/"
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
HISTSIZE=100000000
|
||||
SAVEHIST=100000000
|
||||
setopt BANG_HIST # Treat the '!' character specially during expansion.
|
||||
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
|
||||
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
|
||||
setopt SHARE_HISTORY # Share history between all sessions.
|
||||
setopt HIST_FIND_NO_DUPS # Do not display a line previously found.
|
||||
setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
|
||||
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
|
||||
setopt HIST_SAVE_NO_DUPS
|
||||
setopt HIST_VERIFY
|
||||
|
||||
export EDITOR=nvim
|
||||
export VISUAL=nvim
|
||||
export READER=mupdf
|
||||
|
||||
enable-fzf-tab
|
||||
|
||||
eval "$(direnv hook zsh)"
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
fi
|
|
@ -1,9 +0,0 @@
|
|||
ZSH_AUTOSUGGEST_STRATEGY=(match_prev_cmd history completion)
|
||||
|
||||
if [[ ! $(tty) =~ ^/dev/tty[0-9]*$ ]]; then
|
||||
if [[ -z $TMUX ]]; then
|
||||
tmux new -As0
|
||||
fi
|
||||
fi
|
||||
|
||||
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath'
|
|
@ -1,17 +1,21 @@
|
|||
ZSH_AUTOSUGGEST_STRATEGY=(match_prev_cmd history completion)
|
||||
source $ZDOTDIR/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh
|
||||
|
||||
source $ZDOTDIR/plugins/zsh-history-substring-search/zsh-history-substring-search.plugin.zsh
|
||||
|
||||
source $ZDOTDIR/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh
|
||||
|
||||
zvm_after_init_commands+=('[ -f $HOME/.fzf.zsh ] && source $HOME/.fzf.zsh')
|
||||
source $ZDOTDIR/plugins/fzf-tab/fzf-tab.plugin.zsh
|
||||
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath'
|
||||
enable-fzf-tab
|
||||
|
||||
source $ZDOTDIR/plugins/zsh-vi-mode/zsh-vi-mode.plugin.zsh
|
||||
zvm_after_init_commands+=('[ -f $HOME/.fzf.zsh ] && source $HOME/.fzf.zsh')
|
||||
|
||||
source $ZDOTDIR/plugins/zsh-macos.plugin.zsh
|
||||
|
||||
source $ZDOTDIR/plugins/zsh-git.plugin.zsh
|
||||
|
||||
source $ZDOTDIR/plugins/zsh-sudo.plugins.zsh
|
||||
|
||||
source $ZDOTDIR/plugins/zsh-tmux.plugins.zsh
|
||||
|
|
|
@ -102,31 +102,9 @@ compdef _git ggpnp=git-checkout
|
|||
|
||||
alias ggpur='ggu'
|
||||
alias g='git'
|
||||
alias ga='git add'
|
||||
alias gaa='git add --all'
|
||||
alias gapa='git add --patch'
|
||||
alias gau='git add --update'
|
||||
alias gav='git add --verbose'
|
||||
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"'
|
||||
alias gam='git am'
|
||||
alias gama='git am --abort'
|
||||
alias gamc='git am --continue'
|
||||
alias gamscp='git am --show-current-patch'
|
||||
alias gams='git am --skip'
|
||||
alias gap='git apply'
|
||||
alias gapt='git apply --3way'
|
||||
alias gbs='git bisect'
|
||||
alias gbsb='git bisect bad'
|
||||
alias gbsg='git bisect good'
|
||||
alias gbsn='git bisect new'
|
||||
alias gbso='git bisect old'
|
||||
alias gbsr='git bisect reset'
|
||||
alias gbss='git bisect start'
|
||||
alias gbl='git blame -w'
|
||||
alias gb='git branch'
|
||||
alias gba='git branch --all'
|
||||
alias gbd='git branch --delete'
|
||||
alias gbD='git branch --delete --force'
|
||||
|
||||
function gbda() {
|
||||
git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch --delete 2>/dev/null
|
||||
|
@ -147,25 +125,9 @@ function gbds() {
|
|||
done
|
||||
}
|
||||
|
||||
alias gbgd='LANG=C git branch --no-color -vv | grep ": gone\]" | cut -c 3- | awk '"'"'{print $1}'"'"' | xargs git branch -d'
|
||||
alias gbgD='LANG=C git branch --no-color -vv | grep ": gone\]" | cut -c 3- | awk '"'"'{print $1}'"'"' | xargs git branch -D'
|
||||
alias gbm='git branch --move'
|
||||
alias gbnm='git branch --no-merged'
|
||||
alias gbr='git branch --remote'
|
||||
alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
|
||||
alias gbg='LANG=C git branch -vv | grep ": gone\]"'
|
||||
alias gco='git checkout'
|
||||
alias gcor='git checkout --recurse-submodules'
|
||||
alias gcb='git checkout -b'
|
||||
alias gcB='git checkout -B'
|
||||
alias gcd='git checkout $(git_develop_branch)'
|
||||
alias gcm='git checkout $(git_main_branch)'
|
||||
alias gcp='git cherry-pick'
|
||||
alias gcpa='git cherry-pick --abort'
|
||||
alias gcpc='git cherry-pick --continue'
|
||||
alias gclean='git clean --interactive -d'
|
||||
alias gcl='git clone --recurse-submodules'
|
||||
alias gclf='git clone --recursive --shallow-submodules --filter=blob:none --also-filter-submodules'
|
||||
|
||||
function gccd() {
|
||||
setopt localoptions extendedglob
|
||||
|
@ -183,28 +145,7 @@ function gccd() {
|
|||
compdef _git gccd=git-clone
|
||||
|
||||
alias gcam='git commit --all --message'
|
||||
alias gcas='git commit --all --signoff'
|
||||
alias gcasm='git commit --all --signoff --message'
|
||||
alias gcs='git commit --gpg-sign'
|
||||
alias gcss='git commit --gpg-sign --signoff'
|
||||
alias gcssm='git commit --gpg-sign --signoff --message'
|
||||
alias gcmsg='git commit --message'
|
||||
alias gcsm='git commit --signoff --message'
|
||||
alias gc='git commit --verbose'
|
||||
alias gca='git commit --verbose --all'
|
||||
alias gca!='git commit --verbose --all --amend'
|
||||
alias gcan!='git commit --verbose --all --no-edit --amend'
|
||||
alias gcans!='git commit --verbose --all --signoff --no-edit --amend'
|
||||
alias gcann!='git commit --verbose --all --date=now --no-edit --amend'
|
||||
alias gc!='git commit --verbose --amend'
|
||||
alias gcn!='git commit --verbose --no-edit --amend'
|
||||
alias gcf='git config --list'
|
||||
alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
|
||||
alias gd='git diff'
|
||||
alias gdca='git diff --cached'
|
||||
alias gdcw='git diff --cached --word-diff'
|
||||
alias gds='git diff --staged'
|
||||
alias gdw='git diff --word-diff'
|
||||
|
||||
function gdv() { git diff -w "$@" | view - }
|
||||
compdef _git gdv=git-diff
|
||||
|
@ -216,27 +157,8 @@ function gdnolock() {
|
|||
}
|
||||
compdef _git gdnolock=git-diff
|
||||
|
||||
alias gdt='git diff-tree --no-commit-id --name-only -r'
|
||||
alias gf='git fetch'
|
||||
# --jobs=<n> was added in git 2.8
|
||||
is-at-least 2.8 "$git_version" \
|
||||
&& alias gfa='git fetch --all --prune --jobs=10' \
|
||||
|| alias gfa='git fetch --all --prune'
|
||||
alias gfo='git fetch origin'
|
||||
alias gg='git gui citool'
|
||||
alias gga='git gui citool --amend'
|
||||
alias ghh='git help'
|
||||
alias glgg='git log --graph'
|
||||
alias glgga='git log --graph --decorate --all'
|
||||
alias glgm='git log --graph --max-count=10'
|
||||
alias glods='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset" --date=short'
|
||||
alias glod='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset"'
|
||||
alias glola='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --all'
|
||||
alias glols='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --stat'
|
||||
alias glol='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset"'
|
||||
alias glo='git log --oneline --decorate'
|
||||
alias glog='git log --oneline --decorate --graph'
|
||||
alias gloga='git log --oneline --decorate --graph --all'
|
||||
|
||||
# Pretty log messages
|
||||
function _git_log_prettily(){
|
||||
|
@ -246,25 +168,10 @@ function _git_log_prettily(){
|
|||
}
|
||||
compdef _git _git_log_prettily=git-log
|
||||
|
||||
alias glp='_git_log_prettily'
|
||||
alias glg='git log --stat'
|
||||
alias glgp='git log --stat --patch'
|
||||
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
|
||||
alias gfg='git ls-files | grep'
|
||||
alias gm='git merge'
|
||||
alias gma='git merge --abort'
|
||||
alias gmc='git merge --continue'
|
||||
alias gms="git merge --squash"
|
||||
alias gmom='git merge origin/$(git_main_branch)'
|
||||
alias gmum='git merge upstream/$(git_main_branch)'
|
||||
alias gmtl='git mergetool --no-prompt'
|
||||
alias gmtlvim='git mergetool --no-prompt --tool=vimdiff'
|
||||
|
||||
alias gl='git pull'
|
||||
alias gpr='git pull --rebase'
|
||||
alias gprv='git pull --rebase -v'
|
||||
alias gpra='git pull --rebase --autostash'
|
||||
alias gprav='git pull --rebase --autostash -v'
|
||||
|
||||
function ggu() {
|
||||
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
|
||||
|
@ -272,8 +179,6 @@ function ggu() {
|
|||
}
|
||||
compdef _git ggu=git-checkout
|
||||
|
||||
alias gprom='git pull --rebase origin $(git_main_branch)'
|
||||
alias gpromi='git pull --rebase=interactive origin $(git_main_branch)'
|
||||
alias ggpull='git pull origin "$(git_current_branch)"'
|
||||
|
||||
function ggl() {
|
||||
|
@ -286,10 +191,7 @@ function ggl() {
|
|||
}
|
||||
compdef _git ggl=git-checkout
|
||||
|
||||
alias gluc='git pull upstream $(git_current_branch)'
|
||||
alias glum='git pull upstream $(git_main_branch)'
|
||||
alias gp='git push'
|
||||
alias gpd='git push --dry-run'
|
||||
|
||||
function ggf() {
|
||||
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
|
||||
|
@ -308,13 +210,6 @@ function ggfl() {
|
|||
}
|
||||
compdef _git ggfl=git-checkout
|
||||
|
||||
alias gpsup='git push --set-upstream origin $(git_current_branch)'
|
||||
is-at-least 2.30 "$git_version" \
|
||||
&& alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes' \
|
||||
|| alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease'
|
||||
alias gpv='git push --verbose'
|
||||
alias gpoat='git push origin --all && git push origin --tags'
|
||||
alias gpod='git push origin --delete'
|
||||
alias ggpush='git push origin "$(git_current_branch)"'
|
||||
|
||||
function ggp() {
|
||||
|
@ -328,81 +223,18 @@ function ggp() {
|
|||
compdef _git ggp=git-checkout
|
||||
|
||||
alias gpu='git push upstream'
|
||||
alias grb='git rebase'
|
||||
alias grba='git rebase --abort'
|
||||
alias grbc='git rebase --continue'
|
||||
alias grbi='git rebase --interactive'
|
||||
alias grbo='git rebase --onto'
|
||||
alias grbs='git rebase --skip'
|
||||
alias grbd='git rebase $(git_develop_branch)'
|
||||
alias grbm='git rebase $(git_main_branch)'
|
||||
alias grbom='git rebase origin/$(git_main_branch)'
|
||||
alias grf='git reflog'
|
||||
alias gr='git remote'
|
||||
alias grv='git remote --verbose'
|
||||
alias gra='git remote add'
|
||||
alias grrm='git remote remove'
|
||||
alias grmv='git remote rename'
|
||||
alias grset='git remote set-url'
|
||||
alias grup='git remote update'
|
||||
alias grh='git reset'
|
||||
alias gru='git reset --'
|
||||
alias grhh='git reset --hard'
|
||||
alias grhk='git reset --keep'
|
||||
alias grhs='git reset --soft'
|
||||
alias gpristine='git reset --hard && git clean --force -dfx'
|
||||
alias gwipe='git reset --hard && git clean --force -df'
|
||||
alias groh='git reset origin/$(git_current_branch) --hard'
|
||||
alias grs='git restore'
|
||||
alias grss='git restore --source'
|
||||
alias grst='git restore --staged'
|
||||
alias gunwip='git rev-list --max-count=1 --format="%s" HEAD | grep -q "\--wip--" && git reset HEAD~1'
|
||||
alias grev='git revert'
|
||||
alias greva='git revert --abort'
|
||||
alias grevc='git revert --continue'
|
||||
alias grm='git rm'
|
||||
alias grmc='git rm --cached'
|
||||
alias gcount='git shortlog --summary --numbered'
|
||||
alias gsh='git show'
|
||||
alias gsps='git show --pretty=short --show-signature'
|
||||
alias gstall='git stash --all'
|
||||
alias gstaa='git stash apply'
|
||||
alias gstc='git stash clear'
|
||||
alias gstd='git stash drop'
|
||||
alias gstl='git stash list'
|
||||
alias gstp='git stash pop'
|
||||
# use the default stash push on git 2.13 and newer
|
||||
is-at-least 2.13 "$git_version" \
|
||||
&& alias gsta='git stash push' \
|
||||
|| alias gsta='git stash save'
|
||||
alias gsts='git stash show --patch'
|
||||
alias gst='git status'
|
||||
alias gss='git status --short'
|
||||
alias gsb='git status --short --branch'
|
||||
alias gsi='git submodule init'
|
||||
alias gsu='git submodule update'
|
||||
alias gsd='git svn dcommit'
|
||||
alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
|
||||
alias gsr='git svn rebase'
|
||||
alias gsw='git switch'
|
||||
alias gswc='git switch --create'
|
||||
alias gswd='git switch $(git_develop_branch)'
|
||||
alias gswm='git switch $(git_main_branch)'
|
||||
alias gta='git tag --annotate'
|
||||
alias gts='git tag --sign'
|
||||
alias gtv='git tag | sort -V'
|
||||
alias gignore='git update-index --assume-unchanged'
|
||||
alias gunignore='git update-index --no-assume-unchanged'
|
||||
alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'
|
||||
alias gwt='git worktree'
|
||||
alias gwta='git worktree add'
|
||||
alias gwtls='git worktree list'
|
||||
alias gwtmv='git worktree move'
|
||||
alias gwtrm='git worktree remove'
|
||||
alias gstu='gsta --include-untracked'
|
||||
alias gtl='gtl(){ git tag --sort=-v:refname -n --list "${1}*" }; noglob gtl'
|
||||
alias gk='\gitk --all --branches &!'
|
||||
alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h) &!'
|
||||
|
||||
function gcpr(){
|
||||
git fetch -fu upstream refs/pull/$1/head:pr/$1
|
||||
git checkout pr/$1
|
||||
}
|
||||
|
||||
unset git_version
|
||||
|
||||
|
|
190
.config/zsh/plugins/zsh-tmux.plugins.zsh
Normal file
190
.config/zsh/plugins/zsh-tmux.plugins.zsh
Normal file
|
@ -0,0 +1,190 @@
|
|||
if ! (( $+commands[tmux] )); then
|
||||
print "zsh tmux plugin: tmux not found. Please install tmux before using this plugin." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# CONFIGURATION VARIABLES
|
||||
# Automatically start tmux
|
||||
if [[ ! $(tty) =~ ^/dev/tty[0-9]*$ ]]; then
|
||||
: ${ZSH_TMUX_AUTOSTART:=true}
|
||||
else
|
||||
: ${ZSH_TMUX_AUTOSTART:=false}
|
||||
fi
|
||||
# Only autostart once. If set to false, tmux will attempt to
|
||||
# autostart every time your zsh configs are reloaded.
|
||||
: ${ZSH_TMUX_AUTOSTART_ONCE:=true}
|
||||
# Automatically connect to a previous session if it exists
|
||||
: ${ZSH_TMUX_AUTOCONNECT:=true}
|
||||
# Automatically close the terminal when tmux exits
|
||||
: ${ZSH_TMUX_AUTOQUIT:=false}
|
||||
# Automatically name the new session based on the basename of PWD
|
||||
: ${ZSH_TMUX_AUTONAME_SESSION:=false}
|
||||
# Set term to screen or screen-256color based on current terminal support
|
||||
: ${ZSH_TMUX_DETACHED:=false}
|
||||
# Set detached mode
|
||||
: ${ZSH_TMUX_FIXTERM:=true}
|
||||
# Set '-CC' option for iTerm2 tmux integration
|
||||
: ${ZSH_TMUX_ITERM2:=false}
|
||||
# The TERM to use for non-256 color terminals.
|
||||
# Tmux states this should be tmux|screen, but you may need to change it on
|
||||
# systems without the proper terminfo
|
||||
if [[ -e /usr/share/terminfo/t/tmux ]]; then
|
||||
: ${ZSH_TMUX_FIXTERM_WITHOUT_256COLOR:=tmux}
|
||||
else
|
||||
: ${ZSH_TMUX_FIXTERM_WITHOUT_256COLOR:=screen}
|
||||
fi
|
||||
# The TERM to use for 256 color terminals.
|
||||
# Tmux states this should be (tmux|screen)-256color, but you may need to change it on
|
||||
# systems without the proper terminfo
|
||||
if [[ -e /usr/share/terminfo/t/tmux-256color ]]; then
|
||||
: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=tmux-256color}
|
||||
else
|
||||
: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color}
|
||||
fi
|
||||
# Set the configuration path
|
||||
if [[ -e $HOME/.tmux.conf ]]; then
|
||||
: ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
|
||||
elif [[ -e ${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf ]]; then
|
||||
: ${ZSH_TMUX_CONFIG:=${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf}
|
||||
else
|
||||
: ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
|
||||
fi
|
||||
# Set -u option to support unicode
|
||||
: ${ZSH_TMUX_UNICODE:=false}
|
||||
|
||||
# ALIASES
|
||||
function _build_tmux_alias {
|
||||
setopt localoptions no_rc_expand_param
|
||||
eval "function $1 {
|
||||
if [[ -z \$1 ]] || [[ \${1:0:1} == '-' ]]; then
|
||||
tmux $2 \"\$@\"
|
||||
else
|
||||
tmux $2 $3 \"\$@\"
|
||||
fi
|
||||
}"
|
||||
|
||||
local f s
|
||||
f="_omz_tmux_alias_${1}"
|
||||
s=(${(z)2})
|
||||
|
||||
eval "function ${f}() {
|
||||
shift words;
|
||||
words=(tmux ${@:2} \$words);
|
||||
((CURRENT+=${#s[@]}+1))
|
||||
_tmux
|
||||
}"
|
||||
|
||||
compdef "$f" "$1"
|
||||
}
|
||||
|
||||
alias tksv='tmux kill-server'
|
||||
alias tl='tmux list-sessions'
|
||||
alias tmuxconf='$EDITOR $ZSH_TMUX_CONFIG'
|
||||
|
||||
_build_tmux_alias "ta" "attach" "-t"
|
||||
_build_tmux_alias "tad" "attach -d" "-t"
|
||||
_build_tmux_alias "ts" "new-session" "-s"
|
||||
_build_tmux_alias "tkss" "kill-session" "-t"
|
||||
|
||||
unfunction _build_tmux_alias
|
||||
|
||||
# Determine if the terminal supports 256 colors
|
||||
if [[ $terminfo[colors] == 256 ]]; then
|
||||
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR
|
||||
else
|
||||
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR
|
||||
fi
|
||||
|
||||
# Handle $0 according to the standard:
|
||||
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
|
||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||
|
||||
# Set the correct local config file to use.
|
||||
if [[ "$ZSH_TMUX_ITERM2" == "false" && -e "$ZSH_TMUX_CONFIG" ]]; then
|
||||
export ZSH_TMUX_CONFIG
|
||||
export _ZSH_TMUX_FIXED_CONFIG="${0:h:a}/tmux.extra.conf"
|
||||
else
|
||||
export _ZSH_TMUX_FIXED_CONFIG="${0:h:a}/tmux.only.conf"
|
||||
fi
|
||||
|
||||
# Wrapper function for tmux.
|
||||
function _zsh_tmux_plugin_run() {
|
||||
if [[ -n "$@" ]]; then
|
||||
command tmux "$@"
|
||||
return $?
|
||||
fi
|
||||
|
||||
local -a tmux_cmd
|
||||
tmux_cmd=(command tmux)
|
||||
[[ "$ZSH_TMUX_ITERM2" == "true" ]] && tmux_cmd+=(-CC)
|
||||
[[ "$ZSH_TMUX_UNICODE" == "true" ]] && tmux_cmd+=(-u)
|
||||
|
||||
local _detached=""
|
||||
[[ "$ZSH_TMUX_DETACHED" == "true" ]] && _detached="-d"
|
||||
|
||||
local session_name
|
||||
if [[ "$ZSH_TMUX_AUTONAME_SESSION" == "true" ]]; then
|
||||
# Name the session after the basename of the current directory
|
||||
session_name=${PWD##*/}
|
||||
# If the current directory is the home directory, name it 'HOME'
|
||||
[[ "$PWD" == "$HOME" ]] && session_name="HOME"
|
||||
# If the current directory is the root directory, name it 'ROOT'
|
||||
[[ "$PWD" == "/" ]] && session_name="ROOT"
|
||||
else
|
||||
session_name="$ZSH_TMUX_DEFAULT_SESSION_NAME"
|
||||
fi
|
||||
|
||||
# Try to connect to an existing session.
|
||||
if [[ -n "$session_name" ]]; then
|
||||
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached -t "$session_name"
|
||||
else
|
||||
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached
|
||||
fi
|
||||
|
||||
# If failed, just run tmux, fixing the TERM variable if requested.
|
||||
if [[ $? -ne 0 ]]; then
|
||||
if [[ "$ZSH_TMUX_FIXTERM" == "true" ]]; then
|
||||
tmux_cmd+=(-f "$_ZSH_TMUX_FIXED_CONFIG")
|
||||
elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then
|
||||
tmux_cmd+=(-f "$ZSH_TMUX_CONFIG")
|
||||
fi
|
||||
|
||||
if [[ -n "$session_name" ]]; then
|
||||
$tmux_cmd new-session -s "$session_name"
|
||||
else
|
||||
$tmux_cmd new-session
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]]; then
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
# Use the completions for tmux for our function
|
||||
compdef _tmux _zsh_tmux_plugin_run
|
||||
# Alias tmux to our wrapper function.
|
||||
alias tmux=_zsh_tmux_plugin_run
|
||||
|
||||
function _tmux_directory_session() {
|
||||
# current directory without leading path
|
||||
local dir=${PWD##*/}
|
||||
# md5 hash for the full working directory path
|
||||
local md5=$(printf '%s' "$PWD" | md5sum | cut -d ' ' -f 1)
|
||||
# human friendly unique session name for this directory
|
||||
local session_name="${dir}-${md5:0:6}"
|
||||
# create or attach to the session
|
||||
tmux new -As "$session_name"
|
||||
}
|
||||
|
||||
alias tds=_tmux_directory_session
|
||||
|
||||
# Autostart if not already in tmux and enabled.
|
||||
if [[ -z "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" && -z "$INSIDE_EMACS" && -z "$EMACS" && -z "$VIM" && -z "$INTELLIJ_ENVIRONMENT_READER" ]]; then
|
||||
# Actually don't autostart if we already did and multiple autostarts are disabled.
|
||||
if [[ "$ZSH_TMUX_AUTOSTART_ONCE" == "false" || "$ZSH_TMUX_AUTOSTARTED" != "true" ]]; then
|
||||
export ZSH_TMUX_AUTOSTARTED=true
|
||||
_zsh_tmux_plugin_run
|
||||
fi
|
||||
fi
|
|
@ -1,29 +0,0 @@
|
|||
# ~/.config/zsh/qol.zsh
|
||||
|
||||
backup() {
|
||||
cp $1 $1.bak
|
||||
}
|
||||
|
||||
restore() {
|
||||
mv $1 $(echo $1 | sed 's/\.bak//')
|
||||
}
|
||||
|
||||
capture() {
|
||||
sudo dtrace -p "$1" -qn '
|
||||
syscall::write*:entry
|
||||
/pid == $target && arg0 == 1/ {
|
||||
printf("%s", copyinstr(arg1, arg2));
|
||||
}
|
||||
'
|
||||
}
|
||||
|
||||
sourceall(){
|
||||
set -e
|
||||
pids=$(pgrep zsh)
|
||||
while IFS= read -r pid; do
|
||||
kill -USR1 "$pid"
|
||||
done <<< "$pids"
|
||||
set +e
|
||||
}
|
||||
|
||||
alias routes="netstat -rn -f inet"
|
|
@ -1,19 +0,0 @@
|
|||
# ~/.config/zsh/replacements.zsh
|
||||
|
||||
alias ls="eza --icons -l --sort type"
|
||||
|
||||
function vim {
|
||||
if [[ -z "$@" ]]; then
|
||||
if [[ -f "./.session.vim" ]]; then
|
||||
nvim -S .session.vim --listen /tmp/nvim.pipe -c 'lua vim.g.savesession = true'
|
||||
else
|
||||
nvim --listen /tmp/nvim.pipe -c 'lua vim.g.savesession = true'
|
||||
fi
|
||||
else
|
||||
nvim --listen /tmp/nvim.pipe "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
alias lg="lazygit"
|
||||
alias calcurse-caldav='CALCURSE_CALDAV_PASSWORD=$(keyring get caldav afonso) calcurse-caldav'
|
|
@ -134,6 +134,8 @@ export FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS"\
|
|||
" --color=fg:$color04,header:$color0D,info:$color0A,pointer:$color0C"\
|
||||
" --color=marker:$color0C,fg+:$color06,prompt:$color0A,hl+:$color0D"
|
||||
|
||||
zstyle ":fzf-tab:*" fzf-flags
|
||||
|
||||
}
|
||||
|
||||
_gen_fzf_default_opts
|
||||
|
|
Loading…
Reference in a new issue