switching from zsh to yash
This commit is contained in:
parent
e4a26077c8
commit
b1aa6d93b2
11 changed files with 815 additions and 678 deletions
42
yash/_yashrc
Normal file
42
yash/_yashrc
Normal file
|
@ -0,0 +1,42 @@
|
|||
# yash config
|
||||
set --brace-expand
|
||||
set --extended-glob
|
||||
set --no-clobber
|
||||
set --unset
|
||||
set --hist-space
|
||||
set --notify-le
|
||||
set --le-no-conv-meta
|
||||
set --le-predict
|
||||
! [ -d ~/.cache/yash ] && mkdir -p ~/.cache/yash
|
||||
HISTFILE=~/.cache/yash/history
|
||||
HISTSIZE=100000
|
||||
PS1P="\fi"
|
||||
FCEDIT=hx
|
||||
|
||||
# prompt
|
||||
. ~/skynet/yash/polyglot.sh
|
||||
|
||||
# environment setup
|
||||
export PURE_GIT_PULL=0
|
||||
GPG_TTY=$(tty); export GPG_TTY
|
||||
export XDG_CURRENT_DESKTOP=sway
|
||||
export MOZ_ENABLE_WAYLAND=1
|
||||
export ELECTRON_OZONE_PLATFORM_HINT=wayland
|
||||
export QT_QPA_PLATFORMTHEME=qt6ct
|
||||
export DOTNET_ROOT=$HOME/dotnet
|
||||
export LD_LIBRARY_PATH=$HOME/.local/lib:${LD_LIBRARY_PATH-}
|
||||
export PATH=$HOME/.local/bin:$HOME/dotnet:$HOME/.dotnet/tools:$HOME/go/bin:$HOME/.cargo/bin:$HOME/node/node_modules/.bin:$PATH
|
||||
export MANPATH=$HOME/.local/share/man:${MANPATH-}
|
||||
|
||||
# command replacements
|
||||
if type lsd >/dev/null 2>/dev/null; then
|
||||
ls() { command lsd "$@"; }
|
||||
fi
|
||||
if type bat >/dev/null 2>/dev/null; then
|
||||
cat() { command bat "$@"; }
|
||||
fi
|
||||
|
||||
# aliases
|
||||
if [ -f ~/.yash_alias ]; then
|
||||
. ~/.yash_alias
|
||||
fi
|
9
yash/alias_borges
Normal file
9
yash/alias_borges
Normal file
|
@ -0,0 +1,9 @@
|
|||
alias ~api='cd /home/rudism/mri/cosmic/api'
|
||||
alias ~oot='cd /home/rudism/mri/cosmic/nasa/oot/api'
|
||||
|
||||
alias dockerrm='docker stop $(docker ps -aq); docker rm $(docker ps -aq); docker system prune -f; docker volume prune -af'
|
||||
alias webcamfix='sudo modprobe v4l2loopback devices=1 video_nr=9 card_label=VirtualCam exclusive_caps=1 && ffmpeg -f video4linux2 -framerate 25 -video_size 1280x720 -input_format mjpeg -i /dev/video0 -f v4l2 -pix_fmt yuv420p /dev/video9; sudo rmmod v4l2loopback'
|
||||
alias syncmusic='rsync -av --size-only --times --no-perms --no-owner --no-group --delete /mnt/agrajag/music/'
|
||||
alias watchsync='watch -d grep -e Dirty: -e Writeback: /proc/meminfo'
|
||||
alias win='dbus-run-session sway --unsupported-gpu'
|
||||
alias clearb="printf '\033[2J\033[3J\033[1;1H'"
|
764
yash/polyglot.sh
Normal file
764
yash/polyglot.sh
Normal file
|
@ -0,0 +1,764 @@
|
|||
# _ _ _
|
||||
# _ __ ___ | |_ _ __ _| | ___ | |_
|
||||
# | '_ \ / _ \| | | | |/ _` | |/ _ \| __|
|
||||
# | |_) | (_) | | |_| | (_| | | (_) | |_
|
||||
# | .__/ \___/|_|\__, |\__, |_|\___/ \__|
|
||||
# |_| |___/ |___/
|
||||
#
|
||||
# Polyglot Prompt
|
||||
#
|
||||
# A dynamic color Git prompt for zsh, bash, ksh93, mksh, pdksh, oksh, dash,
|
||||
# yash,busybox ash, and osh
|
||||
#
|
||||
#
|
||||
# Source this file from a relevant dotfile (e.g. .zshrc, .bashrc, .shrc, .kshrc,
|
||||
# .mkshrc, .yashrc, or ~/.config/oil/oshrc) thus:
|
||||
#
|
||||
# . /path/to/polyglot.sh
|
||||
#
|
||||
# Set $POLYGLOT_PROMPT_DIRTRIM to the number of directory elements you would
|
||||
# like to have displayed in your prompt (the default is 2). For example,
|
||||
#
|
||||
# POLYGLOT_PROMPT_DIRTRIM=3
|
||||
#
|
||||
# results in
|
||||
#
|
||||
# ~/foo/bar/bat/quux
|
||||
#
|
||||
# displaying as
|
||||
#
|
||||
# ~/.../bar/bat/quux
|
||||
#
|
||||
#
|
||||
# Copyright 2017-2024 Alexandros Kozak
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# https://github.com/agkozak/polyglot
|
||||
#
|
||||
|
||||
# shellcheck shell=ksh
|
||||
# shellcheck disable=SC2016,SC2034,SC2088,SC3024
|
||||
|
||||
# Only run in interactive shells
|
||||
case $- in
|
||||
*i*) ;;
|
||||
*) return ;;
|
||||
esac
|
||||
|
||||
# Bail if the shell doesn't have command
|
||||
if ! type command > /dev/null 2>&1; then
|
||||
printf '%s\n' 'Polyglot Prompt does not support your shell.' >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Don't let virtual env active scripts alter prompt
|
||||
VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||
|
||||
############################################################
|
||||
# Display non-zero exit status
|
||||
#
|
||||
# Arguments:
|
||||
# $1 exit status of last command (always $?)
|
||||
############################################################
|
||||
_polyglot_exit_status() {
|
||||
case $1 in
|
||||
0) return ;;
|
||||
*) printf '(%d) ' "$1" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
###########################################################
|
||||
# Is the user connected via SSH?
|
||||
###########################################################
|
||||
_polyglot_is_ssh() {
|
||||
[ -n "${SSH_CONNECTION-}${SSH_CLIENT-}${SSH_TTY-}" ]
|
||||
}
|
||||
|
||||
###########################################################
|
||||
# Provide the effective user ID
|
||||
###########################################################
|
||||
_polyglot_euid() {
|
||||
case ${POLYGLOT_UNAME:=$(uname -s)} in
|
||||
SunOS) /usr/xpg4/bin/id -u ;;
|
||||
*) id -u ;;
|
||||
esac
|
||||
}
|
||||
|
||||
###########################################################
|
||||
# Is the user a superuser?
|
||||
###########################################################
|
||||
_polyglot_is_superuser() {
|
||||
# shellcheck disable=SC3028
|
||||
[ ${EUID:-$(_polyglot_euid)} -eq 0 ]
|
||||
}
|
||||
|
||||
###########################################################
|
||||
# Does the terminal support enough colors?
|
||||
###########################################################
|
||||
_polyglot_has_colors() {
|
||||
[ -n "$ZSH_VERSION" ] && setopt LOCAL_OPTIONS NO_WARN_CREATE_GLOBAL
|
||||
|
||||
# The DragonFly BSD system console has trouble displaying colors in pdksh
|
||||
case ${POLYGLOT_UNAME:=$(uname -s)} in
|
||||
DragonFly)
|
||||
case $(who am i) in *ttyv*) return 1 ;; esac
|
||||
;;
|
||||
esac
|
||||
|
||||
case $TERM in
|
||||
*-256color) POLYGLOT_TERM_COLORS=256 ;;
|
||||
vt100|dumb) POLYGLOT_TERM_COLORS=-1 ;;
|
||||
*)
|
||||
if command -v tput > /dev/null 2>&1; then
|
||||
case ${POLYGLOT_UNAME:=$(uname -s)} in
|
||||
FreeBSD|DragonFly) POLYGLOT_TERM_COLORS=$(tput Co) ;;
|
||||
UWIN*) POLYGLOT_TERM_COLORS=$(tput cols) ;;
|
||||
*) POLYGLOT_TERM_COLORS=$(tput colors) ;;
|
||||
esac
|
||||
else
|
||||
POLYGLOT_TERM_COLORS=-1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if [ "${POLYGLOT_TERM_COLORS:-0}" -ge 8 ]; then
|
||||
unset POLYGLOT_TERM_COLORS
|
||||
return 0
|
||||
else
|
||||
unset POLYGLOT_TERM_COLORS
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
############################################################
|
||||
# Emulation of bash's PROMPT_DIRTRIM for all other shells
|
||||
# and for bash before v4.0
|
||||
#
|
||||
# In $PWD, substitute $HOME with ~; if the remainder of the
|
||||
# $PWD has more than a certain number of directory elements
|
||||
# to display (default: 2), abbreviate it with '...', e.g.
|
||||
#
|
||||
# $HOME/dotfiles/polyglot/img
|
||||
#
|
||||
# will be displayed as
|
||||
#
|
||||
# ~/.../polyglot/img
|
||||
#
|
||||
# If $1 is 0, no abbreviation will occur other than that
|
||||
# $HOME will be displayed as ~.
|
||||
#
|
||||
# Arguments:
|
||||
# $1 Number of directory elements to display
|
||||
############################################################
|
||||
_polyglot_prompt_dirtrim() {
|
||||
# Necessary for set -- $1 to undergo field separation in zsh
|
||||
[ -n "$ZSH_VERSION" ] && setopt LOCAL_OPTIONS SH_WORD_SPLIT \
|
||||
NO_WARN_CREATE_GLOBAL NO_WARN_NESTED_VAR 2> /dev/null
|
||||
|
||||
POLYGLOT_DIRTRIM_ELEMENTS="${1:-2}"
|
||||
|
||||
# If root has / as $HOME, print /, not ~
|
||||
[ "$PWD" = '/' ] && printf '%s' '/' && return
|
||||
[ "$PWD" = "$HOME" ] && printf '%s' '~' && return
|
||||
|
||||
case $HOME in
|
||||
/) POLYGLOT_PWD_MINUS_HOME="$PWD" ;; # In case root's $HOME is /
|
||||
*) POLYGLOT_PWD_MINUS_HOME="${PWD#"$HOME"}" ;;
|
||||
esac
|
||||
|
||||
if [ "$POLYGLOT_DIRTRIM_ELEMENTS" -eq 0 ]; then
|
||||
[ "$HOME" = '/' ] && printf '%s' "$PWD" && return
|
||||
case $PWD in
|
||||
${HOME}*) printf '~%s' "$POLYGLOT_PWD_MINUS_HOME" ;;
|
||||
*) printf '%s' "$PWD" ;;
|
||||
esac
|
||||
else
|
||||
# Calculate the part of $PWD that will be displayed in the prompt
|
||||
POLYGLOT_OLD_IFS="$IFS"
|
||||
IFS='/'
|
||||
# shellcheck disable=SC2086
|
||||
set -- $POLYGLOT_PWD_MINUS_HOME
|
||||
shift # Discard empty first field preceding /
|
||||
|
||||
# Discard path elements > $POLYGLOT_PROMPT_DIRTRIM
|
||||
while [ $# -gt "$POLYGLOT_DIRTRIM_ELEMENTS" ]; do
|
||||
shift
|
||||
done
|
||||
|
||||
# Reassemble the remaining path elements with slashes
|
||||
while [ $# -ne 0 ]; do
|
||||
POLYGLOT_ABBREVIATED_PATH="${POLYGLOT_ABBREVIATED_PATH}/$1"
|
||||
shift
|
||||
done
|
||||
|
||||
IFS="$POLYGLOT_OLD_IFS"
|
||||
|
||||
# If the working directory has not been abbreviated, display it thus
|
||||
if [ "$POLYGLOT_ABBREVIATED_PATH" = "${POLYGLOT_PWD_MINUS_HOME}" ]; then
|
||||
if [ "$HOME" = '/' ]; then
|
||||
printf '%s' "$PWD"
|
||||
else
|
||||
case $PWD in
|
||||
${HOME}*) printf '~%s' "${POLYGLOT_PWD_MINUS_HOME}" ;;
|
||||
*) printf '%s' "$PWD" ;;
|
||||
esac
|
||||
fi
|
||||
# Otherwise include an ellipsis to show that abbreviation has taken place
|
||||
else
|
||||
if [ "$HOME" = '/' ]; then
|
||||
printf '...%s' "$POLYGLOT_ABBREVIATED_PATH"
|
||||
else
|
||||
case $PWD in
|
||||
${HOME}*) printf '~/...%s' "$POLYGLOT_ABBREVIATED_PATH" ;;
|
||||
*) printf '...%s' "$POLYGLOT_ABBREVIATED_PATH" ;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
unset POLYGLOT_DIRTRIM_ELEMENTS POLYGLOT_PWD_MINUS_HOME POLYGLOT_OLD_IFS \
|
||||
POLYGLOT_ABBREVIATED_PATH
|
||||
}
|
||||
|
||||
###########################################################
|
||||
# Display current branch name, followed by symbols
|
||||
# representing changes to the working copy
|
||||
#
|
||||
# Arguments:
|
||||
# $1 If ksh, escape ! as !!
|
||||
#
|
||||
# shellcheck disable=SC2120
|
||||
###########################################################
|
||||
_polyglot_branch_status() {
|
||||
[ -n "$ZSH_VERSION" ] && setopt LOCAL_OPTIONS NO_WARN_CREATE_GLOBAL \
|
||||
NO_WARN_NESTED_VAR > /dev/null 2>&1
|
||||
|
||||
POLYGLOT_REF="$(env git symbolic-ref --quiet HEAD 2> /dev/null)"
|
||||
case $? in # See what the exit code is.
|
||||
0) ;; # $POLYGLOT_REF contains the name of a checked-out branch.
|
||||
128) return ;; # No Git repository here.
|
||||
# Otherwise, see if HEAD is in a detached state.
|
||||
*) POLYGLOT_REF="$(env git rev-parse --short HEAD 2> /dev/null)" || return ;;
|
||||
esac
|
||||
|
||||
if [ -n "$POLYGLOT_REF" ]; then
|
||||
if [ "${POLYGLOT_SHOW_UNTRACKED:-1}" -eq 0 ]; then
|
||||
POLYGLOT_GIT_STATUS=$(LC_ALL=C GIT_OPTIONAL_LOCKS=0 env git status -uno 2>&1)
|
||||
else
|
||||
POLYGLOT_GIT_STATUS=$(LC_ALL=C GIT_OPTIONAL_LOCKS=0 env git status 2>&1)
|
||||
fi
|
||||
|
||||
POLYGLOT_SYMBOLS=''
|
||||
|
||||
case $POLYGLOT_GIT_STATUS in
|
||||
*' have diverged,'*) POLYGLOT_SYMBOLS="${POLYGLOT_SYMBOLS}&*" ;;
|
||||
esac
|
||||
case $POLYGLOT_GIT_STATUS in
|
||||
*'Your branch is behind '*) POLYGLOT_SYMBOLS="${POLYGLOT_SYMBOLS}&" ;;
|
||||
esac
|
||||
case $POLYGLOT_GIT_STATUS in
|
||||
*'Your branch is ahead of '*) POLYGLOT_SYMBOLS="${POLYGLOT_SYMBOLS}*" ;;
|
||||
esac
|
||||
case $POLYGLOT_GIT_STATUS in
|
||||
*'new file: '*) POLYGLOT_SYMBOLS="${POLYGLOT_SYMBOLS}+" ;;
|
||||
esac
|
||||
case $POLYGLOT_GIT_STATUS in
|
||||
*'deleted: '*) POLYGLOT_SYMBOLS="${POLYGLOT_SYMBOLS}x" ;;
|
||||
esac
|
||||
case $POLYGLOT_GIT_STATUS in
|
||||
*'modified: '*)
|
||||
if [ "$1" = 'ksh' ]; then
|
||||
POLYGLOT_SYMBOLS="${POLYGLOT_SYMBOLS}!!"
|
||||
else
|
||||
POLYGLOT_SYMBOLS="${POLYGLOT_SYMBOLS}!"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
case $POLYGLOT_GIT_STATUS in
|
||||
*'renamed: '*) POLYGLOT_SYMBOLS="${POLYGLOT_SYMBOLS}>" ;;
|
||||
esac
|
||||
case $POLYGLOT_GIT_STATUS in
|
||||
*'Untracked files:'*) POLYGLOT_SYMBOLS="${POLYGLOT_SYMBOLS}?" ;;
|
||||
esac
|
||||
|
||||
[ -n "$POLYGLOT_SYMBOLS" ] && POLYGLOT_SYMBOLS=" $POLYGLOT_SYMBOLS"
|
||||
|
||||
printf ' (%s%s)' "${POLYGLOT_REF#refs/heads/}" "$POLYGLOT_SYMBOLS"
|
||||
fi
|
||||
|
||||
unset POLYGLOT_REF POLYGLOT_GIT_STATUS POLYGLOT_SYMBOLS
|
||||
}
|
||||
|
||||
###########################################################
|
||||
# Native sh alternative to basename. See
|
||||
# https://github.com/dylanaraps/pure-sh-bible
|
||||
#
|
||||
# Arguments:
|
||||
# $1 Filename
|
||||
# $2 Suffix
|
||||
###########################################################
|
||||
_polyglot_basename() {
|
||||
POLYGLOT_BASENAME_DIR=${1%"${1##*[!/]}"}
|
||||
POLYGLOT_BASENAME_DIR=${POLYGLOT_BASENAME_DIR##*/}
|
||||
POLYGLOT_BASENAME_DIR=${POLYGLOT_BASENAME_DIR%"$2"}
|
||||
|
||||
printf '%s\n' "${POLYGLOT_BASENAME_DIR:-/}"
|
||||
|
||||
unset POLYGLOT_BASENAME_DIR
|
||||
}
|
||||
|
||||
###########################################################
|
||||
# Tests to see if the current shell is busybox ash
|
||||
###########################################################
|
||||
_polyglot_is_busybox() {
|
||||
case $(help 2> /dev/null) in
|
||||
'Built-in commands:'*) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
###########################################################
|
||||
# Test to see if the current shell is pdksh or oksh
|
||||
###########################################################
|
||||
_polyglot_is_pdksh() {
|
||||
case $KSH_VERSION in
|
||||
*'PD KSH'*)
|
||||
if [ "${POLYGLOT_UNAME:=$(uname -s)}" = 'OpenBSD' ] ||
|
||||
[ "${0#-}" = 'oksh' ]; then
|
||||
POLYGLOT_KSH_BANG='ksh'
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
###########################################################
|
||||
# Test to see if the current shell is dtksh (Desktop Korn
|
||||
# Shell).
|
||||
###########################################################
|
||||
_polyglot_is_dtksh() {
|
||||
case ${0#-} in
|
||||
*dtksh) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
###########################################################
|
||||
# Test to see if sh is really dash
|
||||
###########################################################
|
||||
_polyglot_sh_is_dash() {
|
||||
case $(ls -l "$(command -v "${0#-}")") in
|
||||
*dash*) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
_polyglot_is_yash()
|
||||
{
|
||||
case "${0#-}" in
|
||||
*yash) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
###########################################################
|
||||
# Output virtual environment name
|
||||
###########################################################
|
||||
_polyglot_venv() {
|
||||
# pipenv/poetry: when the virtualenv is in the project directory
|
||||
if [ "${VIRTUAL_ENV##*/}" = '.venv' ]; then
|
||||
POLYGLOT_VENV=${VIRTUAL_ENV%/.venv}
|
||||
POLYGLOT_VENV=${POLYGLOT_VENV##*/}
|
||||
# pipenv
|
||||
elif [ -n "$PIPENV_ACTIVE" ]; then
|
||||
POLYGLOT_VENV=${VIRTUAL_ENV%-*}
|
||||
POLYGLOT_VENV=${POLYGLOT_VENV##*/}
|
||||
# virtualenv/venv
|
||||
elif [ -n "$VIRTUAL_ENV" ]; then
|
||||
POLYGLOT_VENV=${VIRTUAL_ENV##*/}
|
||||
# conda
|
||||
elif [ -n "$CONDA_DEFAULT_ENV" ]; then
|
||||
POLYGLOT_VENV=$CONDA_DEFAULT_ENV
|
||||
fi
|
||||
|
||||
[ -n "$POLYGLOT_VENV" ] && printf '(%s) ' "$POLYGLOT_VENV"
|
||||
|
||||
unset POLYGLOT_VENV
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
# zsh
|
||||
#####################################################################
|
||||
|
||||
# Make sure that ZSH is not emulating ksh or bash
|
||||
if [ -n "$ZSH_VERSION" ] && [ "${0#-}" != 'ksh' ] &&
|
||||
[ "${0#-}" != 'bash' ] && [ "${0#-}" != 'sh' ]; then
|
||||
|
||||
setopt PROMPT_SUBST
|
||||
|
||||
###########################################################
|
||||
# Runs right before the prompt is displayed
|
||||
# Imitates bash's PROMPT_DIRTRIM behavior and calculates
|
||||
# working branch and working copy status
|
||||
###########################################################
|
||||
_polyglot_precmd() {
|
||||
psvar[2]=$(_polyglot_prompt_dirtrim "$POLYGLOT_PROMPT_DIRTRIM")
|
||||
psvar[3]=$(_polyglot_branch_status)
|
||||
psvar[5]=$(_polyglot_venv)
|
||||
|
||||
PS1=''
|
||||
# The ZSH vi mode indicator won't work in Emacs shell (but it does in term
|
||||
# and ansi-term)
|
||||
if [ "$TERM" != 'dumb' ]; then
|
||||
PS1+='%(4V.:.+)'
|
||||
fi
|
||||
if _polyglot_has_colors; then
|
||||
PS1+='%(?..%B%F{red}(%?%)%b%f )'
|
||||
PS1+='%5v'
|
||||
PS1+='%(!.%S.%B%F{green})%n%1v%(!.%s.%f%b) '
|
||||
PS1+='%B%F{blue}%2v%f%b'
|
||||
PS1+='%F{yellow}%3v%f %# '
|
||||
else
|
||||
PS1+='%(?..(%?%) )'
|
||||
PS1+='%5v'
|
||||
PS1+='%(!.%S.)%n%1v%(!.%s.) '
|
||||
PS1+='%2v'
|
||||
PS1+='%3v %# '
|
||||
fi
|
||||
}
|
||||
|
||||
###########################################################
|
||||
# Redraw the prompt when the vi mode changes
|
||||
#
|
||||
# Whn in vi mode, the prompt will use a bash 4.3-style
|
||||
# mode indicator at the beginniing of the line: '+' for
|
||||
# insert mode; ':' for command mode
|
||||
#
|
||||
# Underscores are used in this function's name to keep
|
||||
# dash from choking on hyphens
|
||||
###########################################################
|
||||
_polyglot_zle_keymap_select() {
|
||||
[ "$KEYMAP" = 'vicmd' ] && psvar[4]='vicmd' || psvar[4]=''
|
||||
zle reset-prompt
|
||||
zle -R
|
||||
}
|
||||
|
||||
zle -N _polyglot_zle_keymap_select
|
||||
zle -A _polyglot_zle_keymap_select zle-keymap-select
|
||||
zle -A _polyglot_zle_keymap_select zle-line-init
|
||||
|
||||
###########################################################
|
||||
# Redraw prompt when terminal size changes
|
||||
###########################################################
|
||||
TRAPWINCH() {
|
||||
zle && zle -R
|
||||
}
|
||||
|
||||
# TODO: add-zsh-hook was added in ZSH v4.3.4. It would be nice to be
|
||||
# compatible with even earlier versions of ZSH, but that seems to require
|
||||
# use of array syntax that is incompatible with ash.
|
||||
autoload add-zsh-hook
|
||||
add-zsh-hook precmd _polyglot_precmd
|
||||
|
||||
# Only display the $HOSTNAME for an ssh connection, except for a superuser
|
||||
if _polyglot_is_ssh || _polyglot_is_superuser; then
|
||||
psvar[1]="@${HOST%%\.*}"
|
||||
else
|
||||
psvar[1]=''
|
||||
fi
|
||||
|
||||
unset RPROMPT # Clean up detritus from previously loaded prompts
|
||||
|
||||
#####################################################################
|
||||
# bash
|
||||
#####################################################################
|
||||
elif [ -n "$BASH_VERSION" ]; then
|
||||
|
||||
###########################################################
|
||||
# Create the bash $PROMPT_COMMAND
|
||||
#
|
||||
# If $1 is 0, bash's PROMPT_DIRTRIM abbreviations will be
|
||||
# disabled; the only abbreviation that will occur is that
|
||||
# $HOME will be displayed as ~.
|
||||
#
|
||||
# Arguments:
|
||||
# $1 Number of directory elements to display
|
||||
###########################################################
|
||||
_polyglot_prompt_command() {
|
||||
# $POLYGLOT_PROMPT_DIRTRIM must be greater than 0 and defaults to 2
|
||||
[ "$1" ] && PROMPT_DIRTRIM=$1 || PROMPT_DIRTRIM=2
|
||||
|
||||
if ! _polyglot_is_superuser; then
|
||||
if _polyglot_has_colors; then
|
||||
PS1="\[\e[01;31m\]\$(_polyglot_exit_status \$?)\[\e[0m\]"
|
||||
PS1+="\$(_polyglot_venv)"
|
||||
PS1+="\[\e[01;32m\]\u$(printf '%s' "$POLYGLOT_HOSTNAME_STRING")\[\e[0m\] "
|
||||
case $BASH_VERSION in
|
||||
# bash, before v4.0, did not have $PROMPT_DIRTRIM
|
||||
1.*|2.*|3.*)
|
||||
PS1+="\[\e[01;34m\]\$(_polyglot_prompt_dirtrim \$POLYGLOT_PROMPT_DIRTRIM)\[\e[0m\]"
|
||||
;;
|
||||
*) PS1+="\[\e[01;34m\]\w\[\e[0m\]" ;;
|
||||
esac
|
||||
PS1+="\[\e[33m\]\$(_polyglot_branch_status)\[\e[0m\] \$ "
|
||||
else
|
||||
PS1="\$(_polyglot_exit_status \$?)"
|
||||
PS1+="\$(_polyglot_venv)"
|
||||
PS1+="\u$(printf '%s' "$POLYGLOT_HOSTNAME_STRING") "
|
||||
case $BASH_VERSION in
|
||||
1.*|2.*|3.*)
|
||||
PS1="\$(_polyglot_prompt_dirtrim \$POLYGLOT_PROMPT_DIRTRIM)"
|
||||
;;
|
||||
*) PS1+="\w" ;;
|
||||
esac
|
||||
PS1+="\$(_polyglot_branch_status) \$ "
|
||||
fi
|
||||
else # Superuser
|
||||
if _polyglot_has_colors; then
|
||||
PS1="\[\e[01;31m\]\$(_polyglot_exit_status \$?)\[\e[0m\]"
|
||||
PS1+="\$(_polyglot_venv)"
|
||||
PS1+="\[\e[7m\]\u@\h\[\e[0m\] "
|
||||
case $BASH_VERSION in
|
||||
1.*|2.*|3.*)
|
||||
PS1+="\[\e[01;34m\]\$(_polyglot_prompt_dirtrim \$POLYGLOT_PROMPT_DIRTRIM)\[\e[0m\]"
|
||||
;;
|
||||
*) PS1+="\[\e[01;34m\]\w\[\e[0m\]" ;;
|
||||
esac
|
||||
PS1+="\[\e[33m\]\$(_polyglot_branch_status)\[\e[0m\] # "
|
||||
else
|
||||
PS1="\$(_polyglot_exit_status \$?)"
|
||||
PS1+="\$(_polyglot_venv)"
|
||||
PS1+="\[\e[7m\]\u@\h\[\e[0m\] "
|
||||
case $BASH_VERSION in
|
||||
1.*|2.*|3.*)
|
||||
PS1+="\$(_polyglot_prompt_dirtrim \$POLYGLOT_PROMPT_DIRTRIM)"
|
||||
;;
|
||||
*) PS1+="\w" ;;
|
||||
esac
|
||||
PS1+="\$(_polyglot_branch_status) # "
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Only display the $HOSTNAME for an ssh connection
|
||||
if _polyglot_is_ssh; then
|
||||
POLYGLOT_HOSTNAME_STRING='@\h'
|
||||
else
|
||||
POLYGLOT_HOSTNAME_STRING=''
|
||||
fi
|
||||
|
||||
PROMPT_COMMAND='_polyglot_prompt_command $POLYGLOT_PROMPT_DIRTRIM'
|
||||
|
||||
# vi command mode
|
||||
if [ "$TERM" != 'dumb' ]; then # Line editing not enabled in Emacs shell
|
||||
bind 'set show-mode-in-prompt' # Since bash 4.3
|
||||
bind 'set vi-ins-mode-string "+"'
|
||||
bind 'set vi-cmd-mode-string ":"'
|
||||
fi
|
||||
#####################################################################
|
||||
# ksh93, mksh, and zsh in bash, ksh, and sh emulation mode
|
||||
#####################################################################
|
||||
|
||||
elif [ -n "$KSH_VERSION" ] || _polyglot_is_dtksh || [ -n "$ZSH_VERSION" ] &&
|
||||
! _polyglot_is_pdksh ; then
|
||||
# Only display the $HOSTNAME for an ssh connection
|
||||
if _polyglot_is_ssh || _polyglot_is_superuser; then
|
||||
POLYGLOT_HOSTNAME_STRING=$(hostname)
|
||||
POLYGLOT_HOSTNAME_STRING="@${POLYGLOT_HOSTNAME_STRING%%\.*}"
|
||||
else
|
||||
POLYGLOT_HOSTNAME_STRING=''
|
||||
fi
|
||||
|
||||
if [ "${0#-}" = 'bash' ] || [ "${0#-}" = 'sh' ]; then
|
||||
POLYGLOT_KSH_BANG=''
|
||||
else
|
||||
case $KSH_VERSION in
|
||||
*MIRBSD*) POLYGLOT_KSH_BANG='' ;;
|
||||
*) POLYGLOT_KSH_BANG='ksh' ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case $KSH_VERSION in
|
||||
*MIRBSD*)
|
||||
# To know how long the prompt is, and thus to know how far it is to the
|
||||
# edge of the screen, mksh requires an otherwise unused character (in this
|
||||
# case \001) followed by a carriage return at the beginning of the
|
||||
# prompt, which is then used to mark off escape sequences as zero-length.
|
||||
# See https://www.mirbsd.org/htman/i386/man1/mksh.htm
|
||||
if ! _polyglot_is_superuser; then
|
||||
if _polyglot_has_colors; then
|
||||
PS1=$(print "\001\r\001\E[31;1m\001")
|
||||
PS1+='$(_polyglot_exit_status $?)'
|
||||
PS1+=$(print "\001\E[0m")
|
||||
PS1+='$(_polyglot_venv)'
|
||||
PS1+=$(print "\E[32;1m\001")
|
||||
PS1+='${LOGNAME:-$(logname)}$POLYGLOT_HOSTNAME_STRING'
|
||||
PS1+=$(print "\001\E[0m\001")
|
||||
PS1+=' '
|
||||
PS1+=$(print "\001\E[34;1m\001")
|
||||
PS1+='$(_polyglot_prompt_dirtrim "$POLYGLOT_PROMPT_DIRTRIM")'
|
||||
PS1+=$(print "\001\E[0m\E[33m\001")
|
||||
PS1+='$(_polyglot_branch_status $POLYGLOT_KSH_BANG)'
|
||||
PS1+=$(print "\001\E[0m\001")
|
||||
PS1+=' \$ '
|
||||
else
|
||||
PS1='$(_polyglot_exit_status $?)'
|
||||
PS1+='$(_polyglot_venv)'
|
||||
PS1+='${LOGNAME:-$(logname)}$POLYGLOT_HOSTNAME_STRING '
|
||||
PS1+='$(_polyglot_prompt_dirtrim "$POLYGLOT_PROMPT_DIRTRIM")'
|
||||
PS1+='$(_polyglot_branch_status $POLYGLOT_KSH_BANG)'
|
||||
PS1+=' \$ '
|
||||
fi
|
||||
else # Superuser
|
||||
if _polyglot_has_colors; then
|
||||
PS1=$(print "\001\r\001\E[31;1m\001")
|
||||
PS1+='$(_polyglot_exit_status $?)'
|
||||
PS1+=$(print "\001\E[0m")
|
||||
PS1+='$(_polyglot_venv)'
|
||||
PS1+=$(print "\E[7m\001")
|
||||
PS1+='${LOGNAME:-$(logname)}$POLYGLOT_HOSTNAME_STRING'
|
||||
PS1+=$(print "\001\E[0m\001")
|
||||
PS1+=' '
|
||||
PS1+=$(print "\001\E[34;1m\001")
|
||||
PS1+='$(_polyglot_prompt_dirtrim "$POLYGLOT_PROMPT_DIRTRIM")'
|
||||
PS1+=$(print "\001\E[0m\E[33m\001")
|
||||
PS1+='$(_polyglot_branch_status $POLYGLOT_KSH_BANG)'
|
||||
PS1+=$(print "\001\E[0m\001")
|
||||
PS1+=' # '
|
||||
else
|
||||
PS1=$(print "\001\r")
|
||||
PS1+='$(_polyglot_exit_status $?)'
|
||||
PS1+='$(_polyglot_venv)'
|
||||
PS1+=$(print "\001\E[7m\001")
|
||||
PS1+='${LOGNAME:-$(logname)}$POLYGLOT_HOSTNAME_STRING'
|
||||
PS1+=$(print "\001\E[0m\001")
|
||||
PS1+=' '
|
||||
PS1+='$(_polyglot_prompt_dirtrim "$POLYGLOT_PROMPT_DIRTRIM")'
|
||||
PS1+='$(_polyglot_branch_status $POLYGLOT_KSH_BANG)'
|
||||
PS1+=' # '
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if ! _polyglot_is_superuser; then
|
||||
# zsh emulating other shells doesn't handle colors well
|
||||
if _polyglot_has_colors && [ -z "$ZSH_VERSION" ]; then
|
||||
# FreeBSD sh chokes on ANSI C quoting, so I'll avoid it
|
||||
PS1="$(print '\E[31;1m$(_polyglot_exit_status $?)\E[0m$(_polyglot_venv)\E[32;1m${LOGNAME:-$(logname)}$POLYGLOT_HOSTNAME_STRING\E[0m \E[34;1m$(_polyglot_prompt_dirtrim "$POLYGLOT_PROMPT_DIRTRIM")\E[0m\E[33m$(_polyglot_branch_status $POLYGLOT_KSH_BANG)\E[0m \$ ')"
|
||||
else
|
||||
PS1='$(_polyglot_exit_status $?)$(_polyglot_venv)${LOGNAME:-$(logname)}$POLYGLOT_HOSTNAME_STRING $(_polyglot_prompt_dirtrim "$POLYGLOT_PROMPT_DIRTRIM")$(_polyglot_branch_status $POLYGLOT_KSH_BANG) \$ '
|
||||
fi
|
||||
else # Superuser
|
||||
if _polyglot_has_colors && [ -z "$ZSH_VERSION" ]; then
|
||||
PS1="$(print '\E[31;1m$(_polyglot_exit_status $?)\E[0m$(_polyglot_venv)\E[7m${LOGNAME:-$(logname)}$POLYGLOT_HOSTNAME_STRING\E[0m \E[34;1m$(_polyglot_prompt_dirtrim "$POLYGLOT_PROMPT_DIRTRIM")\E[0m\E[33m$(_polyglot_branch_status $POLYGLOT_KSH_BANG)\E[0m\E[0m # ')"
|
||||
else
|
||||
PS1="$(print '$(_polyglot_exit_status $?)$(_polyglot_venv)\E[7m${LOGNAME:-$(logname)}$POLYGLOT_HOSTNAME_STRING\E[0m $(_polyglot_prompt_dirtrim "$POLYGLOT_PROMPT_DIRTRIM")$(_polyglot_branch_status $POLYGLOT_KSH_BANG) # ')"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
####################################################################
|
||||
# pdksh, oksh, dash, busybox ash, yash, osh,
|
||||
# and zsh in sh emulation mode
|
||||
####################################################################
|
||||
|
||||
elif _polyglot_is_pdksh || [ "${0#-}" = 'dash' ] || _polyglot_is_busybox ||
|
||||
_polyglot_is_yash || _polyglot_sh_is_dash || [ "${0#-}" = 'osh' ]; then
|
||||
|
||||
# Only display the $HOSTNAME for an ssh connection
|
||||
if _polyglot_is_ssh || _polyglot_is_superuser; then
|
||||
POLYGLOT_HOSTNAME_STRING=$(hostname)
|
||||
POLYGLOT_HOSTNAME_STRING="@${POLYGLOT_HOSTNAME_STRING%%\.*}"
|
||||
else
|
||||
POLYGLOT_HOSTNAME_STRING=''
|
||||
fi
|
||||
|
||||
# pdksh uses an arbitrary non-printing character to delimit color escape
|
||||
# sequences in the prompt. In practice, however, it is impossible to find
|
||||
# one single non-printing character that will work with all operating systems
|
||||
# and terminals. The Polyglot Prompt defaults to \021 for OpenBSD/NetBSD
|
||||
# and \016 for everything else. If you want to specify your own non-printing
|
||||
# character, do so thus:
|
||||
#
|
||||
# POLYGLOT_NP="\016" # Set this variable to whatever value you like
|
||||
#
|
||||
# Or set POLYGLOT_PDKSH_COLORS=0 to disable color entirely in pdksh.
|
||||
|
||||
case ${POLYGLOT_UNAME} in
|
||||
NetBSD*|OpenBSD*) POLYGLOT_NP=${POLYGLOT_NP:-"\021"} ;;
|
||||
*) POLYGLOT_NP=${POLYGLOT_NP:-"\016"} ;;
|
||||
esac
|
||||
|
||||
if _polyglot_is_pdksh &&
|
||||
_polyglot_has_colors &&
|
||||
[ ${POLYGLOT_PDKSH_COLORS:-1} -ne 0 ]; then
|
||||
|
||||
PS1=$(print "$POLYGLOT_NP\r")
|
||||
case $POLYGLOT_UNAME in
|
||||
NetBSD*|OpenBSD*) PS1=$PS1$(print "$POLYGLOT_NP") ;;
|
||||
esac
|
||||
PS1=$PS1$(print "\033[31;1m$POLYGLOT_NP")
|
||||
PS1=$PS1'$(_polyglot_exit_status $?)'
|
||||
PS1=$PS1$(print "$POLYGLOT_NP\033[0m$POLYGLOT_NP")
|
||||
PS1=$PS1'$(_polyglot_venv)'
|
||||
if ! _polyglot_is_superuser; then
|
||||
PS1=$PS1$(print "$POLYGLOT_NP\033[32;1m$POLYGLOT_NP")
|
||||
else
|
||||
PS1=$PS1$(print "$POLYGLOT_NP\033[7m$POLYGLOT_NP")
|
||||
fi
|
||||
PS1=$PS1'${LOGNAME:-$(logname)}$POLYGLOT_HOSTNAME_STRING'
|
||||
PS1=$PS1$(print "$POLYGLOT_NP\033[0m$POLYGLOT_NP")
|
||||
PS1=$PS1' '
|
||||
PS1=$PS1$(print "$POLYGLOT_NP\033[34;1m$POLYGLOT_NP")
|
||||
PS1=$PS1'$(_polyglot_prompt_dirtrim "$POLYGLOT_PROMPT_DIRTRIM")'
|
||||
PS1=$PS1$(print "$POLYGLOT_NP\033[0m\033[33m$POLYGLOT_NP")
|
||||
PS1=$PS1'$(_polyglot_branch_status $POLYGLOT_KSH_BANG)'
|
||||
PS1=$PS1$(print "$POLYGLOT_NP\033[0m$POLYGLOT_NP")
|
||||
PS1=$PS1' \$ '
|
||||
|
||||
elif _polyglot_is_yash || [ "${0#-}" = 'osh' ] && _polyglot_has_colors; then
|
||||
PS1='\[\e[01;31m\]$(_polyglot_exit_status $?)\[\e[0m\]'
|
||||
PS1=$PS1'$(_polyglot_venv)'
|
||||
if ! _polyglot_is_superuser; then
|
||||
PS1=$PS1'\[\e[01;32m\]${LOGNAME:-$(logname)}$POLYGLOT_HOSTNAME_STRING\[\e[0m\] '
|
||||
else
|
||||
PS1=$PS1'\[\e[7m\]${LOGNAME:-$(logname)}$POLYGLOT_HOSTNAME_STRING\[\e[0m\] '
|
||||
fi
|
||||
PS1=$PS1'\[\e[01;34m\]$(_polyglot_prompt_dirtrim "$POLYGLOT_PROMPT_DIRTRIM")\[\e[0m\]'
|
||||
PS1=$PS1'\[\e[33m\]$(_polyglot_branch_status $POLYGLOT_KSH_BANG)\[\e[0m\] \$ '
|
||||
else
|
||||
PS1='$(_polyglot_exit_status $?)$(_polyglot_venv)${LOGNAME:-$(logname)}$POLYGLOT_HOSTNAME_STRING $(_polyglot_prompt_dirtrim "$POLYGLOT_PROMPT_DIRTRIM")$(_polyglot_branch_status $POLYGLOT_KSH_BANG) '
|
||||
if ! _polyglot_is_superuser; then
|
||||
PS1=$PS1'$ '
|
||||
else
|
||||
PS1=$PS1'# '
|
||||
fi
|
||||
fi
|
||||
else
|
||||
printf '%s\n' 'Polyglot Prompt does not support your shell.' >&2
|
||||
fi
|
||||
|
||||
# Clean up environment
|
||||
unset -f _polyglot_is_ssh _polyglot_basename _polyglot_is_busybox \
|
||||
_polyglot_is_dtksh _polyglot_is_pdksh _polyglot_sh_is_dash
|
||||
|
||||
# vim: ts=2:et:sts=2:sw=2
|
|
@ -1,74 +0,0 @@
|
|||
# Catppuccin Mocha Theme (for zsh-syntax-highlighting)
|
||||
#
|
||||
# Paste this files contents inside your ~/.zshrc before you activate zsh-syntax-highlighting
|
||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main cursor)
|
||||
typeset -gA ZSH_HIGHLIGHT_STYLES
|
||||
|
||||
# Main highlighter styling: https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/main.md
|
||||
#
|
||||
## General
|
||||
### Diffs
|
||||
### Markup
|
||||
## Classes
|
||||
## Comments
|
||||
ZSH_HIGHLIGHT_STYLES[comment]='fg=#585b70'
|
||||
## Constants
|
||||
## Entitites
|
||||
## Functions/methods
|
||||
ZSH_HIGHLIGHT_STYLES[alias]='fg=#a6e3a1'
|
||||
ZSH_HIGHLIGHT_STYLES[suffix-alias]='fg=#a6e3a1'
|
||||
ZSH_HIGHLIGHT_STYLES[global-alias]='fg=#a6e3a1'
|
||||
ZSH_HIGHLIGHT_STYLES[function]='fg=#a6e3a1'
|
||||
ZSH_HIGHLIGHT_STYLES[command]='fg=#a6e3a1'
|
||||
ZSH_HIGHLIGHT_STYLES[precommand]='fg=#a6e3a1,italic'
|
||||
ZSH_HIGHLIGHT_STYLES[autodirectory]='fg=#fab387,italic'
|
||||
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]='fg=#fab387'
|
||||
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]='fg=#fab387'
|
||||
ZSH_HIGHLIGHT_STYLES[back-quoted-argument]='fg=#cba6f7'
|
||||
## Keywords
|
||||
## Built ins
|
||||
ZSH_HIGHLIGHT_STYLES[builtin]='fg=#a6e3a1'
|
||||
ZSH_HIGHLIGHT_STYLES[reserved-word]='fg=#a6e3a1'
|
||||
ZSH_HIGHLIGHT_STYLES[hashed-command]='fg=#a6e3a1'
|
||||
## Punctuation
|
||||
ZSH_HIGHLIGHT_STYLES[commandseparator]='fg=#f38ba8'
|
||||
ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter-unquoted]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[process-substitution-delimiter]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[back-quoted-argument-delimiter]='fg=#f38ba8'
|
||||
ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]='fg=#f38ba8'
|
||||
ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]='fg=#f38ba8'
|
||||
## Serializable / Configuration Languages
|
||||
## Storage
|
||||
## Strings
|
||||
ZSH_HIGHLIGHT_STYLES[command-substitution-quoted]='fg=#f9e2af'
|
||||
ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter-quoted]='fg=#f9e2af'
|
||||
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]='fg=#f9e2af'
|
||||
ZSH_HIGHLIGHT_STYLES[single-quoted-argument-unclosed]='fg=#e64553'
|
||||
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='fg=#f9e2af'
|
||||
ZSH_HIGHLIGHT_STYLES[double-quoted-argument-unclosed]='fg=#e64553'
|
||||
ZSH_HIGHLIGHT_STYLES[rc-quote]='fg=#f9e2af'
|
||||
## Variables
|
||||
ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument-unclosed]='fg=#e64553'
|
||||
ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[assign]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[named-fd]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[numeric-fd]='fg=#cdd6f4'
|
||||
## No category relevant in spec
|
||||
ZSH_HIGHLIGHT_STYLES[unknown-token]='fg=#e64553'
|
||||
ZSH_HIGHLIGHT_STYLES[path]='fg=#cdd6f4,underline'
|
||||
ZSH_HIGHLIGHT_STYLES[path_pathseparator]='fg=#f38ba8,underline'
|
||||
ZSH_HIGHLIGHT_STYLES[path_prefix]='fg=#cdd6f4,underline'
|
||||
ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]='fg=#f38ba8,underline'
|
||||
ZSH_HIGHLIGHT_STYLES[globbing]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[history-expansion]='fg=#cba6f7'
|
||||
#ZSH_HIGHLIGHT_STYLES[command-substitution]='fg=?'
|
||||
#ZSH_HIGHLIGHT_STYLES[command-substitution-unquoted]='fg=?'
|
||||
#ZSH_HIGHLIGHT_STYLES[process-substitution]='fg=?'
|
||||
#ZSH_HIGHLIGHT_STYLES[arithmetic-expansion]='fg=?'
|
||||
ZSH_HIGHLIGHT_STYLES[back-quoted-argument-unclosed]='fg=#e64553'
|
||||
ZSH_HIGHLIGHT_STYLES[redirection]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[arg0]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[default]='fg=#cdd6f4'
|
||||
ZSH_HIGHLIGHT_STYLES[cursor]='fg=#cdd6f4'
|
445
zsh/fzf.zsh
445
zsh/fzf.zsh
|
@ -1,445 +0,0 @@
|
|||
# ____ ____
|
||||
# / __/___ / __/
|
||||
# / /_/_ / / /_
|
||||
# / __/ / /_/ __/
|
||||
# /_/ /___/_/ completion.zsh
|
||||
#
|
||||
# - $FZF_TMUX (default: 0)
|
||||
# - $FZF_TMUX_OPTS (default: '-d 40%')
|
||||
# - $FZF_COMPLETION_TRIGGER (default: '**')
|
||||
# - $FZF_COMPLETION_OPTS (default: empty)
|
||||
|
||||
# Both branches of the following `if` do the same thing -- define
|
||||
# __fzf_completion_options such that `eval $__fzf_completion_options` sets
|
||||
# all options to the same values they currently have. We'll do just that at
|
||||
# the bottom of the file after changing options to what we prefer.
|
||||
#
|
||||
# IMPORTANT: Until we get to the `emulate` line, all words that *can* be quoted
|
||||
# *must* be quoted in order to prevent alias expansion. In addition, code must
|
||||
# be written in a way works with any set of zsh options. This is very tricky, so
|
||||
# careful when you change it.
|
||||
#
|
||||
# Start by loading the builtin zsh/parameter module. It provides `options`
|
||||
# associative array that stores current shell options.
|
||||
if 'zmodload' 'zsh/parameter' 2>'/dev/null' && (( ${+options} )); then
|
||||
# This is the fast branch and it gets taken on virtually all Zsh installations.
|
||||
#
|
||||
# ${(kv)options[@]} expands to array of keys (option names) and values ("on"
|
||||
# or "off"). The subsequent expansion# with (j: :) flag joins all elements
|
||||
# together separated by spaces. __fzf_completion_options ends up with a value
|
||||
# like this: "options=(shwordsplit off aliases on ...)".
|
||||
__fzf_completion_options="options=(${(j: :)${(kv)options[@]}})"
|
||||
else
|
||||
# This branch is much slower because it forks to get the names of all
|
||||
# zsh options. It's possible to eliminate this fork but it's not worth the
|
||||
# trouble because this branch gets taken only on very ancient or broken
|
||||
# zsh installations.
|
||||
() {
|
||||
# That `()` above defines an anonymous function. This is essentially a scope
|
||||
# for local parameters. We use it to avoid polluting global scope.
|
||||
'local' '__fzf_opt'
|
||||
__fzf_completion_options="setopt"
|
||||
# `set -o` prints one line for every zsh option. Each line contains option
|
||||
# name, some spaces, and then either "on" or "off". We just want option names.
|
||||
# Expansion with (@f) flag splits a string into lines. The outer expansion
|
||||
# removes spaces and everything that follow them on every line. __fzf_opt
|
||||
# ends up iterating over option names: shwordsplit, aliases, etc.
|
||||
for __fzf_opt in "${(@)${(@f)$(set -o)}%% *}"; do
|
||||
if [[ -o "$__fzf_opt" ]]; then
|
||||
# Option $__fzf_opt is currently on, so remember to set it back on.
|
||||
__fzf_completion_options+=" -o $__fzf_opt"
|
||||
else
|
||||
# Option $__fzf_opt is currently off, so remember to set it back off.
|
||||
__fzf_completion_options+=" +o $__fzf_opt"
|
||||
fi
|
||||
done
|
||||
# The value of __fzf_completion_options here looks like this:
|
||||
# "setopt +o shwordsplit -o aliases ..."
|
||||
}
|
||||
fi
|
||||
|
||||
# Enable the default zsh options (those marked with <Z> in `man zshoptions`)
|
||||
# but without `aliases`. Aliases in functions are expanded when functions are
|
||||
# defined, so if we disable aliases here, we'll be sure to have no pesky
|
||||
# aliases in any of our functions. This way we won't need prefix every
|
||||
# command with `command` or to quote every word to defend against global
|
||||
# aliases. Note that `aliases` is not the only option that's important to
|
||||
# control. There are several others that could wreck havoc if they are set
|
||||
# to values we don't expect. With the following `emulate` command we
|
||||
# sidestep this issue entirely.
|
||||
'emulate' 'zsh' '-o' 'no_aliases'
|
||||
|
||||
# This brace is the start of try-always block. The `always` part is like
|
||||
# `finally` in lesser languages. We use it to *always* restore user options.
|
||||
{
|
||||
|
||||
# Bail out if not interactive shell.
|
||||
[[ -o interactive ]] || return 0
|
||||
|
||||
# To use custom commands instead of find, override _fzf_compgen_{path,dir}
|
||||
if ! declare -f _fzf_compgen_path > /dev/null; then
|
||||
_fzf_compgen_path() {
|
||||
echo "$1"
|
||||
command find -L "$1" \
|
||||
-name .git -prune -o -name .hg -prune -o -name .svn -prune -o \( -type d -o -type f -o -type l \) \
|
||||
-a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@'
|
||||
}
|
||||
fi
|
||||
|
||||
if ! declare -f _fzf_compgen_dir > /dev/null; then
|
||||
_fzf_compgen_dir() {
|
||||
command find -L "$1" \
|
||||
-name .git -prune -o -name .hg -prune -o -name .svn -prune -o -type d \
|
||||
-a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@'
|
||||
}
|
||||
fi
|
||||
|
||||
###########################################################
|
||||
|
||||
__fzf_comprun() {
|
||||
if [[ "$(type _fzf_comprun 2>&1)" =~ function ]]; then
|
||||
_fzf_comprun "$@"
|
||||
elif [ -n "${TMUX_PANE-}" ] && { [ "${FZF_TMUX:-0}" != 0 ] || [ -n "${FZF_TMUX_OPTS-}" ]; }; then
|
||||
shift
|
||||
if [ -n "${FZF_TMUX_OPTS-}" ]; then
|
||||
fzf-tmux ${(Q)${(Z+n+)FZF_TMUX_OPTS}} -- "$@"
|
||||
else
|
||||
fzf-tmux -d ${FZF_TMUX_HEIGHT:-40%} -- "$@"
|
||||
fi
|
||||
else
|
||||
shift
|
||||
fzf "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# Extract the name of the command. e.g. foo=1 bar baz**<tab>
|
||||
__fzf_extract_command() {
|
||||
local token tokens
|
||||
tokens=(${(z)1})
|
||||
for token in $tokens; do
|
||||
token=${(Q)token}
|
||||
if [[ "$token" =~ [[:alnum:]] && ! "$token" =~ "=" ]]; then
|
||||
echo "$token"
|
||||
return
|
||||
fi
|
||||
done
|
||||
echo "${tokens[1]}"
|
||||
}
|
||||
|
||||
__fzf_generic_path_completion() {
|
||||
local base lbuf cmd compgen fzf_opts suffix tail dir leftover matches
|
||||
base=$1
|
||||
lbuf=$2
|
||||
cmd=$(__fzf_extract_command "$lbuf")
|
||||
compgen=$3
|
||||
fzf_opts=$4
|
||||
suffix=$5
|
||||
tail=$6
|
||||
|
||||
setopt localoptions nonomatch
|
||||
eval "base=$base"
|
||||
[[ $base = *"/"* ]] && dir="$base"
|
||||
while [ 1 ]; do
|
||||
if [[ -z "$dir" || -d ${dir} ]]; then
|
||||
leftover=${base/#"$dir"}
|
||||
leftover=${leftover/#\/}
|
||||
[ -z "$dir" ] && dir='.'
|
||||
[ "$dir" != "/" ] && dir="${dir/%\//}"
|
||||
matches=$(eval "$compgen $(printf %q "$dir")" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} ${FZF_COMPLETION_OPTS-}" __fzf_comprun "$cmd" ${(Q)${(Z+n+)fzf_opts}} -q "$leftover" | while read item; do
|
||||
item="${item%$suffix}$suffix"
|
||||
echo -n "${(q)item} "
|
||||
done)
|
||||
matches=${matches% }
|
||||
if [ -n "$matches" ]; then
|
||||
LBUFFER="$lbuf$matches$tail"
|
||||
fi
|
||||
zle reset-prompt
|
||||
break
|
||||
fi
|
||||
dir=$(dirname "$dir")
|
||||
dir=${dir%/}/
|
||||
done
|
||||
}
|
||||
|
||||
_fzf_path_completion() {
|
||||
__fzf_generic_path_completion "$1" "$2" _fzf_compgen_path \
|
||||
"-m" "" " "
|
||||
}
|
||||
|
||||
_fzf_dir_completion() {
|
||||
__fzf_generic_path_completion "$1" "$2" _fzf_compgen_dir \
|
||||
"" "/" ""
|
||||
}
|
||||
|
||||
_fzf_feed_fifo() (
|
||||
command rm -f "$1"
|
||||
mkfifo "$1"
|
||||
cat <&0 > "$1" &
|
||||
)
|
||||
|
||||
_fzf_complete() {
|
||||
setopt localoptions ksh_arrays
|
||||
# Split arguments around --
|
||||
local args rest str_arg i sep
|
||||
args=("$@")
|
||||
sep=
|
||||
for i in {0..${#args[@]}}; do
|
||||
if [[ "${args[$i]-}" = -- ]]; then
|
||||
sep=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ -n "$sep" ]]; then
|
||||
str_arg=
|
||||
rest=("${args[@]:$((sep + 1)):${#args[@]}}")
|
||||
args=("${args[@]:0:$sep}")
|
||||
else
|
||||
str_arg=$1
|
||||
args=()
|
||||
shift
|
||||
rest=("$@")
|
||||
fi
|
||||
|
||||
local fifo lbuf cmd matches post
|
||||
fifo="${TMPDIR:-/tmp}/fzf-complete-fifo-$$"
|
||||
lbuf=${rest[0]}
|
||||
cmd=$(__fzf_extract_command "$lbuf")
|
||||
post="${funcstack[1]}_post"
|
||||
type $post > /dev/null 2>&1 || post=cat
|
||||
|
||||
_fzf_feed_fifo "$fifo"
|
||||
matches=$(FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore ${FZF_DEFAULT_OPTS-} ${FZF_COMPLETION_OPTS-} $str_arg" __fzf_comprun "$cmd" "${args[@]}" -q "${(Q)prefix}" < "$fifo" | $post | tr '\n' ' ')
|
||||
if [ -n "$matches" ]; then
|
||||
LBUFFER="$lbuf$matches"
|
||||
fi
|
||||
command rm -f "$fifo"
|
||||
}
|
||||
|
||||
_fzf_complete_telnet() {
|
||||
_fzf_complete +m -- "$@" < <(
|
||||
command grep -v '^\s*\(#\|$\)' /etc/hosts | command grep -Fv '0.0.0.0' |
|
||||
awk '{if (length($2) > 0) {print $2}}' | sort -u
|
||||
)
|
||||
}
|
||||
|
||||
_fzf_complete_ssh() {
|
||||
_fzf_complete +m -- "$@" < <(
|
||||
setopt localoptions nonomatch
|
||||
command cat <(command tail -n +1 ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?%]') \
|
||||
<(command grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts | tr ',' '\n' | tr -d '[' | awk '{ print $1 " " $1 }') \
|
||||
<(command grep -v '^\s*\(#\|$\)' /etc/hosts | command grep -Fv '0.0.0.0') |
|
||||
awk '{if (length($2) > 0) {print $2}}' | sort -u
|
||||
)
|
||||
}
|
||||
|
||||
_fzf_complete_export() {
|
||||
_fzf_complete -m -- "$@" < <(
|
||||
declare -xp | sed 's/=.*//' | sed 's/.* //'
|
||||
)
|
||||
}
|
||||
|
||||
_fzf_complete_unset() {
|
||||
_fzf_complete -m -- "$@" < <(
|
||||
declare -xp | sed 's/=.*//' | sed 's/.* //'
|
||||
)
|
||||
}
|
||||
|
||||
_fzf_complete_unalias() {
|
||||
_fzf_complete +m -- "$@" < <(
|
||||
alias | sed 's/=.*//'
|
||||
)
|
||||
}
|
||||
|
||||
_fzf_complete_kill() {
|
||||
_fzf_complete -m --header-lines=1 --preview 'echo {}' --preview-window down:3:wrap --min-height 15 -- "$@" < <(
|
||||
command ps -eo user,pid,ppid,start,time,command 2> /dev/null ||
|
||||
command ps -eo user,pid,ppid,time,args # For BusyBox
|
||||
)
|
||||
}
|
||||
|
||||
_fzf_complete_kill_post() {
|
||||
awk '{print $2}'
|
||||
}
|
||||
|
||||
fzf-completion() {
|
||||
local tokens cmd prefix trigger tail matches lbuf d_cmds
|
||||
setopt localoptions noshwordsplit noksh_arrays noposixbuiltins
|
||||
|
||||
# http://zsh.sourceforge.net/FAQ/zshfaq03.html
|
||||
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
|
||||
tokens=(${(z)LBUFFER})
|
||||
if [ ${#tokens} -lt 1 ]; then
|
||||
zle ${fzf_default_completion:-expand-or-complete}
|
||||
return
|
||||
fi
|
||||
|
||||
cmd=$(__fzf_extract_command "$LBUFFER")
|
||||
|
||||
# Explicitly allow for empty trigger.
|
||||
trigger=${FZF_COMPLETION_TRIGGER-'**'}
|
||||
[ -z "$trigger" -a ${LBUFFER[-1]} = ' ' ] && tokens+=("")
|
||||
|
||||
# When the trigger starts with ';', it becomes a separate token
|
||||
if [[ ${LBUFFER} = *"${tokens[-2]-}${tokens[-1]}" ]]; then
|
||||
tokens[-2]="${tokens[-2]-}${tokens[-1]}"
|
||||
tokens=(${tokens[0,-2]})
|
||||
fi
|
||||
|
||||
lbuf=$LBUFFER
|
||||
tail=${LBUFFER:$(( ${#LBUFFER} - ${#trigger} ))}
|
||||
|
||||
# Trigger sequence given
|
||||
if [ ${#tokens} -gt 1 -a "$tail" = "$trigger" ]; then
|
||||
d_cmds=(${=FZF_COMPLETION_DIR_COMMANDS:-cd pushd rmdir})
|
||||
|
||||
[ -z "$trigger" ] && prefix=${tokens[-1]} || prefix=${tokens[-1]:0:-${#trigger}}
|
||||
[ -n "${tokens[-1]}" ] && lbuf=${lbuf:0:-${#tokens[-1]}}
|
||||
|
||||
if eval "type _fzf_complete_${cmd} > /dev/null"; then
|
||||
prefix="$prefix" eval _fzf_complete_${cmd} ${(q)lbuf}
|
||||
zle reset-prompt
|
||||
elif [ ${d_cmds[(i)$cmd]} -le ${#d_cmds} ]; then
|
||||
_fzf_dir_completion "$prefix" "$lbuf"
|
||||
else
|
||||
_fzf_path_completion "$prefix" "$lbuf"
|
||||
fi
|
||||
# Fall back to default completion
|
||||
else
|
||||
zle ${fzf_default_completion:-expand-or-complete}
|
||||
fi
|
||||
}
|
||||
|
||||
[ -z "$fzf_default_completion" ] && {
|
||||
binding=$(bindkey '^I')
|
||||
[[ $binding =~ 'undefined-key' ]] || fzf_default_completion=$binding[(s: :w)2]
|
||||
unset binding
|
||||
}
|
||||
|
||||
zle -N fzf-completion
|
||||
bindkey '^I' fzf-completion
|
||||
|
||||
} always {
|
||||
# Restore the original options.
|
||||
eval $__fzf_completion_options
|
||||
'unset' '__fzf_completion_options'
|
||||
}
|
||||
# ____ ____
|
||||
# / __/___ / __/
|
||||
# / /_/_ / / /_
|
||||
# / __/ / /_/ __/
|
||||
# /_/ /___/_/ 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'
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
zsh <(curl -s https://raw.githubusercontent.com/zap-zsh/zap/master/install.zsh)
|
|
@ -1,39 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
# path aliases
|
||||
hash -d r2=/mnt/external/rudism
|
||||
hash -d api=/home/rudism/mri/cosmic/api
|
||||
hash -d gql=/home/rudism/mri/cosmic/graphql-server
|
||||
hash -d as2=/home/rudism/mri/appdat/as2
|
||||
hash -d oot=/home/rudism/mri/cosmic/nasa/oot/api
|
||||
hash -d risk=/home/rudism/mri/cosmic/nasa/risk/api
|
||||
hash -d og=/home/rudism/mri/cosmic/nasa/og
|
||||
hash -d schema=/home/rudism/mri/cosmic/api-schema
|
||||
hash -d a=/mnt/agrajag
|
||||
hash -d b=/mnt/beeblebrox
|
||||
hash -d c=/mnt/constantmown
|
||||
|
||||
# command aliases
|
||||
alias nasavpn='/home/rudism/src/nasavpn/nasavpn'
|
||||
alias dockerrm='docker stop $(docker ps -aq); docker rm $(docker ps -aq); docker system prune -f'
|
||||
alias webcamfix='sudo modprobe v4l2loopback devices=1 video_nr=9 card_label=VirtualCam exclusive_caps=1 && ffmpeg -f video4linux2 -framerate 25 -video_size 1280x720 -input_format mjpeg -i /dev/video0 -f v4l2 -pix_fmt yuv420p /dev/video9; sudo rmmod v4l2loopback'
|
||||
alias syncmusic='rsync -av --size-only --times --no-perms --no-owner --no-group --delete /mnt/agrajag/music/ /mnt/usb/Music'
|
||||
alias watchsync='watch -d grep -e Dirty: -e Writeback: /proc/meminfo'
|
||||
alias localai='COMPOSE_FILE=~/.local/share/local-ai/docker-compose.yaml docker compose up -d --force-recreate'
|
||||
alias win='dbus-run-session sway --unsupported-gpu'
|
||||
alias transcrilium='/home/rudism/src/transcrilium/transcrilium /mnt/usb/PRIVATE/SONY/REC_FILE/Voice\ Notes01'
|
||||
alias clearb="printf '\033[2J\033[3J\033[1;1H'"
|
||||
alias airplay="pactl unload-module module-raop-discover; pactl load-module module-raop-discover"
|
||||
|
||||
# llm aliases that use aichat
|
||||
if command -v aichat >/dev/null; then
|
||||
alias ask='f() { echo "$@" | aichat };f'
|
||||
alias define='f() { echo "briefly define $1" | aichat };f'
|
||||
alias synonym='f() { echo "list some synonyms of $1" | aichat };f'
|
||||
fi
|
||||
|
||||
# The next line updates PATH for the Google Cloud SDK.
|
||||
if [ -f '/home/rudism/.local/share/google-cloud-sdk/path.zsh.inc' ]; then . '/home/rudism/.local/share/google-cloud-sdk/path.zsh.inc'; fi
|
||||
|
||||
# The next line enables shell command completion for gcloud.
|
||||
if [ -f '/home/rudism/.local/share/google-cloud-sdk/completion.zsh.inc' ]; then . '/home/rudism/.local/share/google-cloud-sdk/completion.zsh.inc'; fi
|
|
@ -1,4 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
alias vim='nvim'
|
||||
export PATH=/home/rudism/.local/bin:$PATH
|
|
@ -1,12 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
setopt re_match_pcre
|
||||
|
||||
# path aliases
|
||||
hash -d dl=/data/data/com.termux/files/home/storage/downloads
|
||||
|
||||
# command aliases
|
||||
alias hxx='hx -c ~/.config/helix/config-md.toml'
|
||||
|
||||
# path additions
|
||||
export PATH=/data/data/com.termux/files/home/go/bin:/data/data/com.termux/files/home/.cargo/bin:$PATH
|
28
zsh/zsh-grc
28
zsh/zsh-grc
|
@ -1,28 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
# GRC colorizes nifty unix tools all over the place
|
||||
|
||||
unalias grc 2> /dev/null
|
||||
GRC=`command -v grc 2> /dev/null`
|
||||
if [ "$TERM" != dumb ] && [ -n "$GRC" ]; then
|
||||
alias as='colorify as'
|
||||
alias colorify="$GRC -es --colour=auto"
|
||||
alias configure='colorify ./configure'
|
||||
alias df='colorify df -kh'
|
||||
alias diff='colorify diff'
|
||||
alias dig='colorify dig'
|
||||
alias docker='colorify docker'
|
||||
alias du='colorify du'
|
||||
alias g++='colorify g++'
|
||||
alias gas='colorify gas'
|
||||
alias gcc='colorify gcc'
|
||||
alias ld='colorify ld'
|
||||
alias make='colorify make'
|
||||
alias mount='colorify mount'
|
||||
alias mtr='colorify mtr'
|
||||
alias netstat='colorify netstat'
|
||||
alias ping6='colorify ping6'
|
||||
alias ping='colorify ping'
|
||||
alias ps='colorify ps'
|
||||
alias traceroute='colorify /usr/sbin/traceroute'
|
||||
fi
|
73
zsh/zshrc
73
zsh/zshrc
|
@ -1,73 +0,0 @@
|
|||
# set up environment
|
||||
export PURE_GIT_PULL=0
|
||||
export GPG_TTY=$(tty)
|
||||
export HISTSIZE=100000
|
||||
export HISTFILE="$HOME/.zsh_history"
|
||||
export SAVEHIST=$HISTSIZE
|
||||
|
||||
# wayland env
|
||||
export XDG_CURRENT_DESKTOP=sway
|
||||
export MOZ_ENABLE_WAYLAND=1
|
||||
export ELECTRON_OZONE_PLATFORM_HINT=wayland
|
||||
export QT_QPA_PLATFORMTHEME=qt6ct
|
||||
|
||||
# set zsh options and features
|
||||
setopt autocd
|
||||
autoload -Uz compinit && compinit
|
||||
setopt extended_history
|
||||
setopt inc_append_history
|
||||
setopt share_history
|
||||
setopt rmstarsilent
|
||||
|
||||
# load zsh plugins
|
||||
[ -f "$HOME/.local/share/zap/zap.zsh" ] && source "$HOME/.local/share/zap/zap.zsh"
|
||||
|
||||
function zvm_after_init() {
|
||||
plug "zap-zsh/fzf"
|
||||
typeset -A key
|
||||
key[Home]=${terminfo[khome]}
|
||||
key[End]=${terminfo[kend]}
|
||||
key[Delete]=${terminfo[kdch1]}
|
||||
zvm_bindkey viins "${key[Home]}" beginning-of-line
|
||||
zvm_bindkey vicmd "${key[Home]}" beginning-of-line
|
||||
zvm_bindkey viins "${key[End]}" end-of-line
|
||||
zvm_bindkey vicmd "${key[End]}" end-of-line
|
||||
zvm_bindkey viins "${key[Delete]}" delete-char
|
||||
zvm_bindkey vicmd "${key[Delete]}" delete-char
|
||||
}
|
||||
|
||||
plug "mafredri/zsh-async"
|
||||
plug "sindresorhus/pure"
|
||||
plug "zsh-users/zsh-autosuggestions"
|
||||
plug "zsh-users/zsh-syntax-highlighting"
|
||||
plug "zpm-zsh/ls"
|
||||
ZAP_GIT_PREFIX="https://code.sitosis.com/" plug "rudism/zsh-bat"
|
||||
plug "lukechilds/zsh-nvm"
|
||||
plug "jeffreytse/zsh-vi-mode"
|
||||
|
||||
# source external stuff
|
||||
eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
|
||||
source ~/skynet/zsh/catppuccin_mocha-zsh-syntax-highlighting.zsh
|
||||
source ~/skynet/zsh/zsh-grc
|
||||
|
||||
# env and path
|
||||
export DOTNET_ROOT=$HOME/dotnet
|
||||
export LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH
|
||||
export PATH=$HOME/.local/bin:$HOME/dotnet:$HOME/.dotnet/tools:$HOME/go/bin:$HOME/.cargo/bin:$HOME/node/node_modules/.bin:$PATH
|
||||
export MANPATH=$MANPATH:$HOME/.local/share/man
|
||||
|
||||
# keybindings
|
||||
bindkey "^[[1~" beginning-of-line
|
||||
bindkey "^[[4~" end-of-line
|
||||
bindkey "^[[3~" delete-char
|
||||
|
||||
# set up directory hashes
|
||||
if [ -f ~/.zalias ]; then
|
||||
source ~/.zalias
|
||||
fi
|
||||
|
||||
if [ -d "$HOME/.config/plasma-workspace/env" ]; then
|
||||
for sh in $HOME/.config/plasma-workspace/env/*.sh; do
|
||||
source "$sh"
|
||||
done
|
||||
fi
|
Loading…
Add table
Reference in a new issue