changed folder layout
This commit is contained in:
parent
fd30095cd0
commit
b5f657b8a4
9 changed files with 37 additions and 397 deletions
|
@ -1,25 +1,26 @@
|
|||
# For Dotfiles
|
||||
export DOTFLS="${HOME}/dotfiles"
|
||||
export DOTLIB="${DOTFLS}/lib"
|
||||
export DOTBIN="${DOTFLS}/bin"
|
||||
export DOTCFG="${DOTFLS}/cfg"
|
||||
export DOTCFGD="${DOTCFG}/zsh/cfg.d"
|
||||
dotfls="${HOME}/dotfiles"
|
||||
dotlib="${dotfls}/lib"
|
||||
dotcfg="${dotfls}/cfg"
|
||||
|
||||
# Path
|
||||
path+=(${DOTBIN})
|
||||
path+=(/opt/android-sdk/build-tools/26.0.1)
|
||||
# Paths
|
||||
path+=(${dotfls}/bin)
|
||||
path+=(${HOME}/.gem/ruby/2.4.0/bin)
|
||||
path+=(${DOTLIB}/welder/bin)
|
||||
path+=(${DOTLIB}/basher/bin)
|
||||
path+=(${HOME}/basher/bin)
|
||||
path+=(/opt/android-sdk/build-tools/26.0.1)
|
||||
path+=(/home/linuxbrew/.linuxbrew/bin)
|
||||
export PATH
|
||||
manpath+=(/home/linuxbrew/.linuxbrew/share/man)
|
||||
infopath+=(/home/linuxbrew/.linuxbrew/share/info)
|
||||
|
||||
# Editor Setting
|
||||
export EDITOR='nano'
|
||||
EDITOR='nano'
|
||||
|
||||
# Completions Paths
|
||||
fpath+=(${DOTLIB}/completions/src)
|
||||
fpath+=(${DOTLIB}/local)
|
||||
fpath+=(${dotlib}/completions/src)
|
||||
fpath+=(${dotlib}/local)
|
||||
|
||||
# Actually export
|
||||
export dotlib dotcfg PATH MANPATH INFOPATH EDITOR
|
||||
|
||||
# Reload all Prompts
|
||||
autoload -U promptinit && promptinit
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export ZSH="${DOTLIB}/ohmyzsh"
|
||||
export ZSH="${dotlib}/ohmyzsh"
|
||||
DISABLE_AUTO_UPDATE="true"
|
||||
source ${ZSH}/oh-my-zsh.sh
|
||||
|
|
|
@ -1,64 +1,22 @@
|
|||
# -------------------------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010-2016 zsh-syntax-highlighting contributors
|
||||
# Copyright (c) 2017 Sebastian Gniazdowski (modifications)
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
# provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||
# and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software without specific prior
|
||||
# written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# Set $ZERO to the expected value, regardless of functionargzero.
|
||||
typeset -g ZERO=${(%):-%N}
|
||||
|
||||
# Invokes each highlighter that needs updating.
|
||||
# This function is supposed to be called whenever the ZLE state changes.
|
||||
_zsh_highlight()
|
||||
{
|
||||
# Store the previous command return code to restore it whatever happens.
|
||||
local ret=$?
|
||||
|
||||
# Remove all highlighting in isearch, so that only the underlining done by zsh itself remains.
|
||||
# For details see FAQ entry 'Why does syntax highlighting not work while searching history?'.
|
||||
if [[ $WIDGET == zle-isearch-update ]] && ! (( $+ISEARCHMATCH_ACTIVE )); then
|
||||
region_highlight=()
|
||||
return $ret
|
||||
fi
|
||||
|
||||
setopt localoptions warncreateglobal noksharrays
|
||||
local REPLY # don't leak $REPLY into global scope
|
||||
local REPLY
|
||||
local -a reply
|
||||
|
||||
# Do not highlight if there are more than 300 chars in the buffer. It's most
|
||||
# likely a pasted command or a huge list of files in that case..
|
||||
[[ -n ${ZSH_HIGHLIGHT_MAXLENGTH:-} ]] && [[ $#BUFFER -gt $ZSH_HIGHLIGHT_MAXLENGTH ]] && return $ret
|
||||
|
||||
# Do not highlight if there are pending inputs (copy/paste).
|
||||
[[ $PENDING -gt 0 ]] && return $ret
|
||||
|
||||
# Reset region highlight to build it from scratch
|
||||
# may need to remove path_prefix highlighting when the line ends
|
||||
if [[ $WIDGET == zle-line-finish ]] || _zsh_highlight_buffer_modified; then
|
||||
-fast-highlight-init
|
||||
-fast-highlight-process && region_highlight=( $reply ) || region_highlight=()
|
||||
|
@ -68,9 +26,6 @@ _zsh_highlight()
|
|||
local cache_place
|
||||
local -a region_highlight_copy
|
||||
|
||||
# Re-apply zle_highlight settings
|
||||
|
||||
# region
|
||||
if (( REGION_ACTIVE == 1 )); then
|
||||
_zsh_highlight_apply_zle_highlight region standout "$MARK" "$CURSOR"
|
||||
elif (( REGION_ACTIVE == 2 )); then
|
||||
|
@ -88,13 +43,10 @@ _zsh_highlight()
|
|||
}
|
||||
fi
|
||||
|
||||
# yank / paste (zsh-5.1.1 and newer)
|
||||
(( $+YANK_ACTIVE )) && (( YANK_ACTIVE )) && _zsh_highlight_apply_zle_highlight paste standout "$YANK_START" "$YANK_END"
|
||||
|
||||
# isearch
|
||||
(( $+ISEARCHMATCH_ACTIVE )) && (( ISEARCHMATCH_ACTIVE )) && _zsh_highlight_apply_zle_highlight isearch underline "$ISEARCHMATCH_START" "$ISEARCHMATCH_END"
|
||||
|
||||
# suffix
|
||||
(( $+SUFFIX_ACTIVE )) && (( SUFFIX_ACTIVE )) && _zsh_highlight_apply_zle_highlight suffix bold "$SUFFIX_START" "$SUFFIX_END"
|
||||
|
||||
return $ret
|
||||
|
@ -106,28 +58,17 @@ _zsh_highlight()
|
|||
}
|
||||
}
|
||||
|
||||
# Apply highlighting based on entries in the zle_highlight array.
|
||||
# This function takes four arguments:
|
||||
# 1. The exact entry (no patterns) in the zle_highlight array:
|
||||
# region, paste, isearch, or suffix
|
||||
# 2. The default highlighting that should be applied if the entry is unset
|
||||
# 3. and 4. Two integer values describing the beginning and end of the
|
||||
# range. The order does not matter.
|
||||
_zsh_highlight_apply_zle_highlight() {
|
||||
local entry="$1" default="$2"
|
||||
integer first="$3" second="$4"
|
||||
|
||||
# read the relevant entry from zle_highlight
|
||||
local region="${zle_highlight[(r)${entry}:*]}"
|
||||
|
||||
if [[ -z "$region" ]]; then
|
||||
# entry not specified at all, use default value
|
||||
region=$default
|
||||
else
|
||||
# strip prefix
|
||||
region="${region#${entry}:}"
|
||||
|
||||
# no highlighting when set to the empty string or to 'none'
|
||||
if [[ -z "$region" ]] || [[ "$region" == none ]]; then
|
||||
return
|
||||
fi
|
||||
|
@ -143,114 +84,72 @@ _zsh_highlight_apply_zle_highlight() {
|
|||
}
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# API/utility functions for highlighters
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
# Whether the command line buffer has been modified or not.
|
||||
#
|
||||
# Returns 0 if the buffer has changed since _zsh_highlight was last called.
|
||||
_zsh_highlight_buffer_modified()
|
||||
{
|
||||
[[ "${_ZSH_HIGHLIGHT_PRIOR_BUFFER:-}" != "$BUFFER" ]] || [[ "$REGION_ACTIVE" != "$_ZSH_HIGHLIGHT_PRIOR_RACTIVE" ]] || { _zsh_highlight_cursor_moved && [[ "$REGION_ACTIVE" = 1 || "$REGION_ACTIVE" = 2 ]] }
|
||||
}
|
||||
|
||||
# Whether the cursor has moved or not.
|
||||
#
|
||||
# Returns 0 if the cursor has moved since _zsh_highlight was last called.
|
||||
_zsh_highlight_cursor_moved()
|
||||
{
|
||||
[[ -n $CURSOR ]] && [[ -n ${_ZSH_HIGHLIGHT_PRIOR_CURSOR-} ]] && (($_ZSH_HIGHLIGHT_PRIOR_CURSOR != $CURSOR))
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Setup functions
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
# Helper for _zsh_highlight_bind_widgets
|
||||
# $1 is name of widget to call
|
||||
_zsh_highlight_call_widget()
|
||||
{
|
||||
builtin zle "$@" && _zsh_highlight
|
||||
}
|
||||
|
||||
# Rebind all ZLE widgets to make them invoke _zsh_highlights.
|
||||
_zsh_highlight_bind_widgets()
|
||||
{
|
||||
setopt localoptions noksharrays
|
||||
typeset -F SECONDS
|
||||
local prefix=orig-s$SECONDS-r$RANDOM # unique each time, in case we're sourced more than once
|
||||
local prefix=orig-s$SECONDS-r$RANDOM
|
||||
|
||||
# Load ZSH module zsh/zleparameter, needed to override user defined widgets.
|
||||
zmodload zsh/zleparameter 2>/dev/null || {
|
||||
print -r -- >&2 'zsh-syntax-highlighting: failed loading zsh/zleparameter.'
|
||||
return 1
|
||||
}
|
||||
|
||||
# Override ZLE widgets to make them invoke _zsh_highlight.
|
||||
local -U widgets_to_bind
|
||||
widgets_to_bind=(${${(k)widgets}:#(.*|run-help|which-command|beep|set-local-history|yank)})
|
||||
|
||||
# Always wrap special zle-line-finish widget. This is needed to decide if the
|
||||
# current line ends and special highlighting logic needs to be applied.
|
||||
# E.g. remove cursor imprint, don't highlight partial paths, ...
|
||||
widgets_to_bind+=(zle-line-finish)
|
||||
|
||||
# Always wrap special zle-isearch-update widget to be notified of updates in isearch.
|
||||
# This is needed because we need to disable highlighting in that case.
|
||||
widgets_to_bind+=(zle-isearch-update)
|
||||
|
||||
local cur_widget
|
||||
for cur_widget in $widgets_to_bind; do
|
||||
case $widgets[$cur_widget] in
|
||||
|
||||
# Already rebound event: do nothing.
|
||||
user:_zsh_highlight_widget_*);;
|
||||
|
||||
# The "eval"'s are required to make $cur_widget a closure: the value of the parameter at function
|
||||
# definition time is used.
|
||||
#
|
||||
# We can't use ${0/_zsh_highlight_widget_} because these widgets are always invoked with
|
||||
# NO_function_argzero, regardless of the option's setting here.
|
||||
|
||||
# User defined widget: override and rebind old one with prefix "orig-".
|
||||
user:*) zle -N $prefix-$cur_widget ${widgets[$cur_widget]#*:}
|
||||
eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget ${(q)prefix}-${(q)cur_widget} -- \"\$@\" }"
|
||||
zle -N $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;;
|
||||
|
||||
# Completion widget: override and rebind old one with prefix "orig-".
|
||||
completion:*) zle -C $prefix-$cur_widget ${${(s.:.)widgets[$cur_widget]}[2,3]}
|
||||
eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget ${(q)prefix}-${(q)cur_widget} -- \"\$@\" }"
|
||||
zle -N $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;;
|
||||
|
||||
# Builtin widget: override and make it call the builtin ".widget".
|
||||
builtin) eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget .${(q)cur_widget} -- \"\$@\" }"
|
||||
zle -N $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;;
|
||||
|
||||
# Incomplete or nonexistent widget: Bind to z-sy-h directly.
|
||||
*)
|
||||
*)
|
||||
if [[ $cur_widget == zle-* ]] && [[ -z $widgets[$cur_widget] ]]; then
|
||||
_zsh_highlight_widget_${cur_widget}() { :; _zsh_highlight }
|
||||
zle -N $cur_widget _zsh_highlight_widget_$cur_widget
|
||||
else
|
||||
# Default: unhandled case.
|
||||
print -r -- >&2 "zsh-syntax-highlighting: unhandled ZLE widget ${(qq)cur_widget}"
|
||||
fi
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# Setup
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
# Try binding widgets.
|
||||
_zsh_highlight_bind_widgets || {
|
||||
print -r -- >&2 'zsh-syntax-highlighting: failed binding ZLE widgets, exiting.'
|
||||
return 1
|
||||
}
|
||||
|
||||
# Reset scratch variables when commandline is done.
|
||||
_zsh_highlight_preexec_hook()
|
||||
{
|
||||
typeset -g _ZSH_HIGHLIGHT_PRIOR_BUFFER=
|
||||
|
@ -264,11 +163,10 @@ add-zsh-hook preexec _zsh_highlight_preexec_hook 2>/dev/null || {
|
|||
|
||||
ZSH_HIGHLIGHT_MAXLENGTH=10000
|
||||
|
||||
# Load zsh/parameter module if available
|
||||
zmodload zsh/parameter 2>/dev/null
|
||||
|
||||
autoload -U is-at-least
|
||||
source "${DOTLIB}/highlight"
|
||||
source "${dotlib}/highlight"
|
||||
|
||||
[[ "${+termcap[Co]}" = 1 && "${termcap[Co]}" = "256" ]] && FAST_HIGHLIGHT_STYLES[variable]="fg=112"
|
||||
|
||||
|
|
|
@ -1,55 +1,11 @@
|
|||
# Fish-like fast/unobtrusive autosuggestions for zsh.
|
||||
# https://github.com/zsh-users/zsh-autosuggestions
|
||||
# v0.4.0
|
||||
# Copyright (c) 2013 Thiago de Arruda
|
||||
# Copyright (c) 2016-2017 Eric Freese
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person
|
||||
# obtaining a copy of this software and associated documentation
|
||||
# files (the "Software"), to deal in the Software without
|
||||
# restriction, including without limitation the rights to use,
|
||||
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following
|
||||
# conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#--------------------------------------------------------------------#
|
||||
# Setup #
|
||||
#--------------------------------------------------------------------#
|
||||
|
||||
# Precmd hooks for initializing the library and starting pty's
|
||||
autoload -Uz add-zsh-hook
|
||||
|
||||
# Asynchronous suggestions are generated in a pty
|
||||
zmodload zsh/zpty
|
||||
|
||||
#--------------------------------------------------------------------#
|
||||
# Global Configuration Variables #
|
||||
#--------------------------------------------------------------------#
|
||||
|
||||
# Color to use when highlighting suggestion
|
||||
# Uses format of `region_highlight`
|
||||
# More info: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Widgets
|
||||
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8'
|
||||
|
||||
# Prefix to use when saving original versions of bound widgets
|
||||
ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
|
||||
|
||||
ZSH_AUTOSUGGEST_STRATEGY=default
|
||||
|
||||
# Widgets that clear the suggestion
|
||||
ZSH_AUTOSUGGEST_CLEAR_WIDGETS=(
|
||||
history-search-forward
|
||||
history-search-backward
|
||||
|
@ -62,7 +18,6 @@ ZSH_AUTOSUGGEST_CLEAR_WIDGETS=(
|
|||
accept-line
|
||||
)
|
||||
|
||||
# Widgets that accept the entire suggestion
|
||||
ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=(
|
||||
forward-char
|
||||
end-of-line
|
||||
|
@ -71,11 +26,9 @@ ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=(
|
|||
vi-add-eol
|
||||
)
|
||||
|
||||
# Widgets that accept the entire suggestion and execute it
|
||||
ZSH_AUTOSUGGEST_EXECUTE_WIDGETS=(
|
||||
)
|
||||
|
||||
# Widgets that accept the suggestion as far as the cursor moves
|
||||
ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(
|
||||
forward-word
|
||||
vi-forward-word
|
||||
|
@ -84,7 +37,6 @@ ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(
|
|||
vi-forward-blank-word-end
|
||||
)
|
||||
|
||||
# Widgets that should be ignored (globbing supported but must be escaped)
|
||||
ZSH_AUTOSUGGEST_IGNORE_WIDGETS=(
|
||||
orig-\*
|
||||
beep
|
||||
|
@ -94,27 +46,14 @@ ZSH_AUTOSUGGEST_IGNORE_WIDGETS=(
|
|||
yank
|
||||
)
|
||||
|
||||
# Max size of buffer to trigger autosuggestion. Leave undefined for no upper bound.
|
||||
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=
|
||||
|
||||
# Pty name for calculating autosuggestions asynchronously
|
||||
ZSH_AUTOSUGGEST_ASYNC_PTY_NAME=zsh_autosuggest_pty
|
||||
|
||||
#--------------------------------------------------------------------#
|
||||
# Utility Functions #
|
||||
#--------------------------------------------------------------------#
|
||||
|
||||
_zsh_autosuggest_escape_command() {
|
||||
setopt localoptions EXTENDED_GLOB
|
||||
|
||||
# Escape special chars in the string (requires EXTENDED_GLOB)
|
||||
echo -E "${1//(#m)[\"\'\\()\[\]|*?~]/\\$MATCH}"
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------#
|
||||
# Feature Detection #
|
||||
#--------------------------------------------------------------------#
|
||||
|
||||
_zsh_autosuggest_feature_detect_zpty_returns_fd() {
|
||||
typeset -g _ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD
|
||||
typeset -h REPLY
|
||||
|
@ -130,10 +69,6 @@ _zsh_autosuggest_feature_detect_zpty_returns_fd() {
|
|||
zpty -d zsh_autosuggest_feature_detect
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------#
|
||||
# Widget Helpers #
|
||||
#--------------------------------------------------------------------#
|
||||
|
||||
_zsh_autosuggest_incr_bind_count() {
|
||||
if ((${+_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]})); then
|
||||
((_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]++))
|
||||
|
@ -152,7 +87,6 @@ _zsh_autosuggest_get_bind_count() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Bind a single widget to an autosuggest widget, saving a reference to the original widget
|
||||
_zsh_autosuggest_bind_widget() {
|
||||
typeset -gA _ZSH_AUTOSUGGEST_BIND_COUNTS
|
||||
|
||||
|
@ -162,25 +96,21 @@ _zsh_autosuggest_bind_widget() {
|
|||
|
||||
local -i bind_count
|
||||
|
||||
# Save a reference to the original widget
|
||||
case $widgets[$widget] in
|
||||
# Already bound
|
||||
user:_zsh_autosuggest_(bound|orig)_*);;
|
||||
|
||||
# User-defined widget
|
||||
user:*)
|
||||
_zsh_autosuggest_incr_bind_count $widget
|
||||
zle -N $prefix${bind_count}-$widget ${widgets[$widget]#*:}
|
||||
;;
|
||||
|
||||
# Built-in widget
|
||||
builtin)
|
||||
_zsh_autosuggest_incr_bind_count $widget
|
||||
eval "_zsh_autosuggest_orig_${(q)widget}() { zle .${(q)widget} }"
|
||||
zle -N $prefix${bind_count}-$widget _zsh_autosuggest_orig_$widget
|
||||
;;
|
||||
|
||||
# Completion widget
|
||||
completion:*)
|
||||
_zsh_autosuggest_incr_bind_count $widget
|
||||
eval "zle -C $prefix${bind_count}-${(q)widget} ${${(s.:.)widgets[$widget]}[2,3]}"
|
||||
|
@ -189,21 +119,13 @@ _zsh_autosuggest_bind_widget() {
|
|||
|
||||
_zsh_autosuggest_get_bind_count $widget
|
||||
|
||||
# Pass the original widget's name explicitly into the autosuggest
|
||||
# function. Use this passed in widget name to call the original
|
||||
# widget instead of relying on the $WIDGET variable being set
|
||||
# correctly. $WIDGET cannot be trusted because other plugins call
|
||||
# zle without the `-w` flag (e.g. `zle self-insert` instead of
|
||||
# `zle self-insert -w`).
|
||||
eval "_zsh_autosuggest_bound_${bind_count}_${(q)widget}() {
|
||||
_zsh_autosuggest_widget_$autosuggest_action $prefix$bind_count-${(q)widget} \$@
|
||||
}"
|
||||
|
||||
# Create the bound widget
|
||||
zle -N $widget _zsh_autosuggest_bound_${bind_count}_$widget
|
||||
}
|
||||
|
||||
# Map all configured widgets to the right autosuggest widgets
|
||||
_zsh_autosuggest_bind_widgets() {
|
||||
local widget
|
||||
local ignore_widgets
|
||||
|
@ -217,7 +139,6 @@ _zsh_autosuggest_bind_widgets() {
|
|||
$ZSH_AUTOSUGGEST_IGNORE_WIDGETS
|
||||
)
|
||||
|
||||
# Find every widget we might want to bind and bind it appropriately
|
||||
for widget in ${${(f)"$(builtin zle -la)"}:#${(j:|:)~ignore_widgets}}; do
|
||||
if [ ${ZSH_AUTOSUGGEST_CLEAR_WIDGETS[(r)$widget]} ]; then
|
||||
_zsh_autosuggest_bind_widget $widget clear
|
||||
|
@ -228,15 +149,12 @@ _zsh_autosuggest_bind_widgets() {
|
|||
elif [ ${ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS[(r)$widget]} ]; then
|
||||
_zsh_autosuggest_bind_widget $widget partial_accept
|
||||
else
|
||||
# Assume any unspecified widget might modify the buffer
|
||||
_zsh_autosuggest_bind_widget $widget modify
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Given the name of an original widget and args, invoke it, if it exists
|
||||
_zsh_autosuggest_invoke_original_widget() {
|
||||
# Do nothing unless called with at least one arg
|
||||
[ $# -gt 0 ] || return
|
||||
|
||||
local original_widget_name="$1"
|
||||
|
@ -248,11 +166,6 @@ _zsh_autosuggest_invoke_original_widget() {
|
|||
fi
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------#
|
||||
# Highlighting #
|
||||
#--------------------------------------------------------------------#
|
||||
|
||||
# If there was a highlight, remove it
|
||||
_zsh_autosuggest_highlight_reset() {
|
||||
typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
|
||||
|
||||
|
@ -262,7 +175,6 @@ _zsh_autosuggest_highlight_reset() {
|
|||
fi
|
||||
}
|
||||
|
||||
# If there's a suggestion, highlight it
|
||||
_zsh_autosuggest_highlight_apply() {
|
||||
typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
|
||||
|
||||
|
@ -274,17 +186,11 @@ _zsh_autosuggest_highlight_apply() {
|
|||
fi
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------#
|
||||
# Autosuggest Widget Implementations #
|
||||
#--------------------------------------------------------------------#
|
||||
|
||||
# Disable suggestions
|
||||
_zsh_autosuggest_disable() {
|
||||
typeset -g _ZSH_AUTOSUGGEST_DISABLED
|
||||
_zsh_autosuggest_clear
|
||||
}
|
||||
|
||||
# Enable suggestions
|
||||
_zsh_autosuggest_enable() {
|
||||
unset _ZSH_AUTOSUGGEST_DISABLED
|
||||
|
||||
|
@ -293,7 +199,6 @@ _zsh_autosuggest_enable() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Toggle suggestions (enable/disable)
|
||||
_zsh_autosuggest_toggle() {
|
||||
if [ -n "${_ZSH_AUTOSUGGEST_DISABLED+x}" ]; then
|
||||
_zsh_autosuggest_enable
|
||||
|
@ -302,60 +207,47 @@ _zsh_autosuggest_toggle() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Clear the suggestion
|
||||
_zsh_autosuggest_clear() {
|
||||
# Remove the suggestion
|
||||
unset POSTDISPLAY
|
||||
|
||||
_zsh_autosuggest_invoke_original_widget $@
|
||||
}
|
||||
|
||||
# Modify the buffer and get a new suggestion
|
||||
_zsh_autosuggest_modify() {
|
||||
local -i retval
|
||||
|
||||
# Only added to zsh very recently
|
||||
local -i KEYS_QUEUED_COUNT
|
||||
|
||||
# Save the contents of the buffer/postdisplay
|
||||
local orig_buffer="$BUFFER"
|
||||
local orig_postdisplay="$POSTDISPLAY"
|
||||
|
||||
# Clear suggestion while waiting for next one
|
||||
unset POSTDISPLAY
|
||||
|
||||
# Original widget may modify the buffer
|
||||
_zsh_autosuggest_invoke_original_widget $@
|
||||
retval=$?
|
||||
|
||||
# Don't fetch a new suggestion if there's more input to be read immediately
|
||||
if [[ $PENDING > 0 ]] || [[ $KEYS_QUEUED_COUNT > 0 ]]; then
|
||||
return $retval
|
||||
fi
|
||||
|
||||
# Optimize if manually typing in the suggestion
|
||||
if [ $#BUFFER -gt $#orig_buffer ]; then
|
||||
local added=${BUFFER#$orig_buffer}
|
||||
|
||||
# If the string added matches the beginning of the postdisplay
|
||||
if [ "$added" = "${orig_postdisplay:0:$#added}" ]; then
|
||||
POSTDISPLAY="${orig_postdisplay:$#added}"
|
||||
return $retval
|
||||
fi
|
||||
fi
|
||||
|
||||
# Don't fetch a new suggestion if the buffer hasn't changed
|
||||
if [ "$BUFFER" = "$orig_buffer" ]; then
|
||||
POSTDISPLAY="$orig_postdisplay"
|
||||
return $retval
|
||||
fi
|
||||
|
||||
# Bail out if suggestions are disabled
|
||||
if [ -n "${_ZSH_AUTOSUGGEST_DISABLED+x}" ]; then
|
||||
return $?
|
||||
fi
|
||||
|
||||
# Get a new suggestion if the buffer is not empty after modification
|
||||
if [ $#BUFFER -gt 0 ]; then
|
||||
if [ -z "$ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" -o $#BUFFER -le "$ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" ]; then
|
||||
_zsh_autosuggest_fetch
|
||||
|
@ -365,7 +257,6 @@ _zsh_autosuggest_modify() {
|
|||
return $retval
|
||||
}
|
||||
|
||||
# Fetch a new suggestion based on what's currently in the buffer
|
||||
_zsh_autosuggest_fetch() {
|
||||
if zpty -t "$ZSH_AUTOSUGGEST_ASYNC_PTY_NAME" &>/dev/null; then
|
||||
_zsh_autosuggest_async_request "$BUFFER"
|
||||
|
@ -376,7 +267,6 @@ _zsh_autosuggest_fetch() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Offer a suggestion
|
||||
_zsh_autosuggest_suggest() {
|
||||
local suggestion="$1"
|
||||
|
||||
|
@ -387,67 +277,39 @@ _zsh_autosuggest_suggest() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Accept the entire suggestion
|
||||
_zsh_autosuggest_accept() {
|
||||
local -i max_cursor_pos=$#BUFFER
|
||||
|
||||
# When vicmd keymap is active, the cursor can't move all the way
|
||||
# to the end of the buffer
|
||||
if [ "$KEYMAP" = "vicmd" ]; then
|
||||
max_cursor_pos=$((max_cursor_pos - 1))
|
||||
fi
|
||||
|
||||
# Only accept if the cursor is at the end of the buffer
|
||||
if [ $CURSOR -eq $max_cursor_pos ]; then
|
||||
# Add the suggestion to the buffer
|
||||
BUFFER="$BUFFER$POSTDISPLAY"
|
||||
|
||||
# Remove the suggestion
|
||||
unset POSTDISPLAY
|
||||
|
||||
# Move the cursor to the end of the buffer
|
||||
CURSOR=${#BUFFER}
|
||||
fi
|
||||
|
||||
_zsh_autosuggest_invoke_original_widget $@
|
||||
}
|
||||
|
||||
# Accept the entire suggestion and execute it
|
||||
_zsh_autosuggest_execute() {
|
||||
# Add the suggestion to the buffer
|
||||
BUFFER="$BUFFER$POSTDISPLAY"
|
||||
|
||||
# Remove the suggestion
|
||||
unset POSTDISPLAY
|
||||
|
||||
# Call the original `accept-line` to handle syntax highlighting or
|
||||
# other potential custom behavior
|
||||
_zsh_autosuggest_invoke_original_widget "accept-line"
|
||||
}
|
||||
|
||||
# Partially accept the suggestion
|
||||
_zsh_autosuggest_partial_accept() {
|
||||
local -i retval
|
||||
|
||||
# Save the contents of the buffer so we can restore later if needed
|
||||
local original_buffer="$BUFFER"
|
||||
|
||||
# Temporarily accept the suggestion.
|
||||
BUFFER="$BUFFER$POSTDISPLAY"
|
||||
|
||||
# Original widget moves the cursor
|
||||
_zsh_autosuggest_invoke_original_widget $@
|
||||
retval=$?
|
||||
|
||||
# If we've moved past the end of the original buffer
|
||||
if [ $CURSOR -gt $#original_buffer ]; then
|
||||
# Set POSTDISPLAY to text right of the cursor
|
||||
POSTDISPLAY="$RBUFFER"
|
||||
|
||||
# Clip the buffer at the cursor
|
||||
BUFFER="$LBUFFER"
|
||||
else
|
||||
# Restore the original buffer
|
||||
BUFFER="$original_buffer"
|
||||
fi
|
||||
|
||||
|
@ -480,115 +342,50 @@ zle -N autosuggest-enable _zsh_autosuggest_widget_enable
|
|||
zle -N autosuggest-disable _zsh_autosuggest_widget_disable
|
||||
zle -N autosuggest-toggle _zsh_autosuggest_widget_toggle
|
||||
|
||||
#--------------------------------------------------------------------#
|
||||
# Default Suggestion Strategy #
|
||||
#--------------------------------------------------------------------#
|
||||
# Suggests the most recent history item that matches the given
|
||||
# prefix.
|
||||
#
|
||||
|
||||
_zsh_autosuggest_strategy_default() {
|
||||
# Reset options to defaults and enable LOCAL_OPTIONS
|
||||
emulate -L zsh
|
||||
|
||||
# Enable globbing flags so that we can use (#m)
|
||||
setopt EXTENDED_GLOB
|
||||
|
||||
# Escape backslashes and all of the glob operators so we can use
|
||||
# this string as a pattern to search the $history associative array.
|
||||
# - (#m) globbing flag enables setting references for match data
|
||||
local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}"
|
||||
|
||||
# Get the history items that match
|
||||
# - (r) subscript flag makes the pattern match on values
|
||||
suggestion="${history[(r)$prefix*]}"
|
||||
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------#
|
||||
# Match Previous Command Suggestion Strategy #
|
||||
#--------------------------------------------------------------------#
|
||||
# Suggests the most recent history item that matches the given
|
||||
# prefix and whose preceding history item also matches the most
|
||||
# recently executed command.
|
||||
#
|
||||
# For example, suppose your history has the following entries:
|
||||
# - pwd
|
||||
# - ls foo
|
||||
# - ls bar
|
||||
# - pwd
|
||||
#
|
||||
# Given the history list above, when you type 'ls', the suggestion
|
||||
# will be 'ls foo' rather than 'ls bar' because your most recently
|
||||
# executed command (pwd) was previously followed by 'ls foo'.
|
||||
#
|
||||
# Note that this strategy won't work as expected with ZSH options that don't
|
||||
# preserve the history order such as `HIST_IGNORE_ALL_DUPS` or
|
||||
# `HIST_EXPIRE_DUPS_FIRST`.
|
||||
|
||||
_zsh_autosuggest_strategy_match_prev_cmd() {
|
||||
local prefix="${1//(#m)[\\()\[\]|*?~]/\\$MATCH}"
|
||||
|
||||
# Get all history event numbers that correspond to history
|
||||
# entries that match pattern $prefix*
|
||||
local history_match_keys
|
||||
history_match_keys=(${(k)history[(R)$prefix*]})
|
||||
|
||||
# By default we use the first history number (most recent history entry)
|
||||
local histkey="${history_match_keys[1]}"
|
||||
|
||||
# Get the previously executed command
|
||||
local prev_cmd="$(_zsh_autosuggest_escape_command "${history[$((HISTCMD-1))]}")"
|
||||
|
||||
# Iterate up to the first 200 history event numbers that match $prefix
|
||||
for key in "${(@)history_match_keys[1,200]}"; do
|
||||
# Stop if we ran out of history
|
||||
[[ $key -gt 1 ]] || break
|
||||
|
||||
# See if the history entry preceding the suggestion matches the
|
||||
# previous command, and use it if it does
|
||||
if [[ "${history[$((key - 1))]}" == "$prev_cmd" ]]; then
|
||||
histkey="$key"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Give back the matched history entry
|
||||
suggestion="$history[$histkey]"
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------#
|
||||
# Async #
|
||||
#--------------------------------------------------------------------#
|
||||
|
||||
# Zpty process is spawned running this function
|
||||
_zsh_autosuggest_async_server() {
|
||||
emulate -R zsh
|
||||
|
||||
# There is a bug in zpty module (fixed in zsh/master) by which a
|
||||
# zpty that exits will kill all zpty processes that were forked
|
||||
# before it. Here we set up a zsh exit hook to SIGKILL the zpty
|
||||
# process immediately, before it has a chance to kill any other
|
||||
# zpty processes.
|
||||
zshexit() {
|
||||
kill -KILL $$
|
||||
sleep 1 # Block for long enough for the signal to come through
|
||||
sleep 1
|
||||
}
|
||||
|
||||
# Output only newlines (not carriage return + newline)
|
||||
stty -onlcr
|
||||
|
||||
# Silence any error messages
|
||||
exec 2>/dev/null
|
||||
|
||||
local strategy=$1
|
||||
local last_pid
|
||||
|
||||
while IFS='' read -r -d $'\0' query; do
|
||||
# Kill last bg process
|
||||
kill -KILL $last_pid &>/dev/null
|
||||
|
||||
# Run suggestion search in the background
|
||||
(
|
||||
local suggestion
|
||||
_zsh_autosuggest_strategy_$ZSH_AUTOSUGGEST_STRATEGY "$query"
|
||||
|
@ -600,13 +397,9 @@ _zsh_autosuggest_async_server() {
|
|||
}
|
||||
|
||||
_zsh_autosuggest_async_request() {
|
||||
# Write the query to the zpty process to fetch a suggestion
|
||||
zpty -w -n $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME "${1}"$'\0'
|
||||
}
|
||||
|
||||
# Called when new data is ready to be read from the pty
|
||||
# First arg will be fd ready for reading
|
||||
# Second arg will be passed in case of error
|
||||
_zsh_autosuggest_async_response() {
|
||||
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
||||
|
||||
|
@ -617,36 +410,29 @@ _zsh_autosuggest_async_response() {
|
|||
}
|
||||
|
||||
_zsh_autosuggest_async_pty_create() {
|
||||
# With newer versions of zsh, REPLY stores the fd to read from
|
||||
typeset -h REPLY
|
||||
|
||||
# If we won't get a fd back from zpty, try to guess it
|
||||
if [ $_ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD -eq 0 ]; then
|
||||
integer -l zptyfd
|
||||
exec {zptyfd}>&1 # Open a new file descriptor (above 10).
|
||||
exec {zptyfd}>&- # Close it so it's free to be used by zpty.
|
||||
exec {zptyfd}>&1
|
||||
exec {zptyfd}>&-
|
||||
fi
|
||||
|
||||
# Fork a zpty process running the server function
|
||||
zpty -b $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME "_zsh_autosuggest_async_server _zsh_autosuggest_strategy_$ZSH_AUTOSUGGEST_STRATEGY"
|
||||
|
||||
# Store the fd so we can remove the handler later
|
||||
if (( REPLY )); then
|
||||
_ZSH_AUTOSUGGEST_PTY_FD=$REPLY
|
||||
else
|
||||
_ZSH_AUTOSUGGEST_PTY_FD=$zptyfd
|
||||
fi
|
||||
|
||||
# Set up input handler from the zpty
|
||||
zle -F $_ZSH_AUTOSUGGEST_PTY_FD _zsh_autosuggest_async_response
|
||||
}
|
||||
|
||||
_zsh_autosuggest_async_pty_destroy() {
|
||||
if zpty -t $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME &>/dev/null; then
|
||||
# Remove the input handler
|
||||
zle -F $_ZSH_AUTOSUGGEST_PTY_FD &>/dev/null
|
||||
|
||||
# Destroy the zpty
|
||||
zpty -d $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME &>/dev/null
|
||||
fi
|
||||
}
|
||||
|
@ -662,24 +448,14 @@ _zsh_autosuggest_async_start() {
|
|||
_zsh_autosuggest_feature_detect_zpty_returns_fd
|
||||
_zsh_autosuggest_async_pty_recreate
|
||||
|
||||
# We recreate the pty to get a fresh list of history events
|
||||
add-zsh-hook precmd _zsh_autosuggest_async_pty_recreate
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------#
|
||||
# Start #
|
||||
#--------------------------------------------------------------------#
|
||||
|
||||
# Start the autosuggestion widgets
|
||||
_zsh_autosuggest_start() {
|
||||
add-zsh-hook -d precmd _zsh_autosuggest_start
|
||||
|
||||
_zsh_autosuggest_bind_widgets
|
||||
|
||||
# Re-bind widgets on every precmd to ensure we wrap other wrappers.
|
||||
# Specifically, highlighting breaks if our widgets are wrapped by
|
||||
# zsh-syntax-highlighting widgets. This also allows modifications
|
||||
# to the widget list variables to take effect on the next precmd.
|
||||
add-zsh-hook precmd _zsh_autosuggest_bind_widgets
|
||||
|
||||
if [ -n "${ZSH_AUTOSUGGEST_USE_ASYNC+x}" ]; then
|
||||
|
@ -687,6 +463,5 @@ _zsh_autosuggest_start() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Start the autosuggestion widgets on the next precmd
|
||||
add-zsh-hook precmd _zsh_autosuggest_start
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
eval `dircolors ${DOTCFG}/dir/cfg`
|
||||
eval `dircolors ${dotcfg}/dir/cfg`
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export ZSH_PLUGIN_GITIGNORE_PATH=$(dirname $0)
|
||||
export ZSH_PLUGIN_GITIGNORE_TEMPLATE_PATHS=${DOTLIB}/gitignore
|
||||
ZSH_PLUGIN_GITIGNORE_PATH=$(dirname $0)
|
||||
ZSH_PLUGIN_GITIGNORE_TEMPLATE_PATHS=${dotlib}/gitignore
|
||||
|
||||
function gie () { ${EDITOR} .gitignore }
|
||||
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
#
|
||||
# Aliases
|
||||
#
|
||||
|
||||
alias ta='tmux attach -t'
|
||||
alias tad='tmux attach -d -t'
|
||||
alias ts='tmux new-session -s'
|
||||
|
@ -9,84 +5,52 @@ alias tl='tmux list-sessions'
|
|||
alias tksv='tmux kill-server'
|
||||
alias tkss='tmux kill-session -t'
|
||||
|
||||
# Only run if tmux is actually installed
|
||||
if which tmux &> /dev/null
|
||||
then
|
||||
# Configuration variables
|
||||
#
|
||||
# Automatically start tmux
|
||||
then
|
||||
[[ -n "$ZSH_TMUX_AUTOSTART" ]] || ZSH_TMUX_AUTOSTART=false
|
||||
# Only autostart once. If set to false, tmux will attempt to
|
||||
# autostart every time your zsh configs are reloaded.
|
||||
[[ -n "$ZSH_TMUX_AUTOSTART_ONCE" ]] || ZSH_TMUX_AUTOSTART_ONCE=true
|
||||
# Automatically connect to a previous session if it exists
|
||||
[[ -n "$ZSH_TMUX_AUTOCONNECT" ]] || ZSH_TMUX_AUTOCONNECT=true
|
||||
# Automatically close the terminal when tmux exits
|
||||
[[ -n "$ZSH_TMUX_AUTOQUIT" ]] || ZSH_TMUX_AUTOQUIT=$ZSH_TMUX_AUTOSTART
|
||||
# Set term to screen or screen-256color based on current terminal support
|
||||
[[ -n "$ZSH_TMUX_FIXTERM" ]] || ZSH_TMUX_FIXTERM=true
|
||||
# Set '-CC' option for iTerm2 tmux integration
|
||||
[[ -n "$ZSH_TMUX_ITERM2" ]] || ZSH_TMUX_ITERM2=false
|
||||
# The TERM to use for non-256 color terminals.
|
||||
# Tmux states this should be screen, but you may need to change it on
|
||||
# systems without the proper terminfo
|
||||
[[ -n "$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR" ]] || ZSH_TMUX_FIXTERM_WITHOUT_256COLOR="screen"
|
||||
# The TERM to use for 256 color terminals.
|
||||
# Tmux states this should be screen-256color, but you may need to change it on
|
||||
# systems without the proper terminfo
|
||||
[[ -n "$ZSH_TMUX_FIXTERM_WITH_256COLOR" ]] || ZSH_TMUX_FIXTERM_WITH_256COLOR="screen-256color"
|
||||
|
||||
local zsh_tmux_plugin_path=${dotcfg}/tmux
|
||||
|
||||
# Get the absolute path to the current directory
|
||||
local zsh_tmux_plugin_path=${DOTCFG}/tmux
|
||||
|
||||
# Determine if the terminal supports 256 colors
|
||||
if [[ `tput colors` == "256" ]]
|
||||
then
|
||||
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR
|
||||
ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR
|
||||
else
|
||||
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR
|
||||
ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR
|
||||
fi
|
||||
|
||||
# Set the correct local config file to use.
|
||||
if [[ "$ZSH_TMUX_ITERM2" == "false" ]] && [[ -f $HOME/.tmux.conf || -h $HOME/.tmux.conf ]]
|
||||
if [[ "$ZSH_TMUX_ITERM2" == "false" ]] && [[ -f $HOME/.tmux.conf || -h $HOME/.tmux.conf ]]
|
||||
then
|
||||
#use this when they have a ~/.tmux.conf
|
||||
export _ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.extra.conf"
|
||||
_ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.extra.conf"
|
||||
else
|
||||
#use this when they don't have a ~/.tmux.conf
|
||||
export _ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.only.conf"
|
||||
_ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.only.conf"
|
||||
fi
|
||||
|
||||
# Wrapper function for tmux.
|
||||
function _zsh_tmux_plugin_run()
|
||||
{
|
||||
# We have other arguments, just run them
|
||||
if [[ -n "$@" ]]
|
||||
then
|
||||
\tmux $@
|
||||
# Try to connect to an existing session.
|
||||
elif [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]]
|
||||
then
|
||||
\tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` attach || \tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` `[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && echo '-f '$_ZSH_TMUX_FIXED_CONFIG` new-session
|
||||
[[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit
|
||||
# Just run tmux, fixing the TERM variable if requested.
|
||||
else
|
||||
\tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` `[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && echo '-f '$_ZSH_TMUX_FIXED_CONFIG`
|
||||
[[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && 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
|
||||
|
||||
# Autostart if not already in tmux and enabled.
|
||||
if [[ ! -n "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" ]]
|
||||
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
|
||||
|
|
|
@ -4,6 +4,6 @@ alias mv='mv -i'
|
|||
alias la='ls -lAh'
|
||||
clearall () { clear; printf '\033[3J' }
|
||||
|
||||
for file in ${DOTCFGD}/source.d/*.zsh; do
|
||||
for file in ${dotcfg}/zsh/cfg.d/source.d/*.zsh; do
|
||||
source $file
|
||||
done
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# Source all files
|
||||
for file in ${HOME}/dotfiles/cfg/zsh/cfg.d/*.zsh; do source $file; done
|
||||
for file in ${HOME}/dotfiles/cfg/zsh/cfg.d/*.zsh; do
|
||||
source $file
|
||||
done
|
||||
|
||||
# Prompt
|
||||
prompt z4rr3t
|
||||
|
|
Loading…
Add table
Reference in a new issue