zsh: fix hl
This commit is contained in:
parent
d4c7579b69
commit
0dbdac1918
8 changed files with 232 additions and 11 deletions
|
@ -25,7 +25,10 @@ alias slog='journalctl --user -u'
|
||||||
|
|
||||||
alias ls='ls --color=tty --hyperlink=auto'
|
alias ls='ls --color=tty --hyperlink=auto'
|
||||||
alias l='ls -lh'
|
alias l='ls -lh'
|
||||||
|
alias la='l -a'
|
||||||
|
|
||||||
alias _=sudo
|
alias _=sudo
|
||||||
|
|
||||||
|
# make rg and fd trustworthy
|
||||||
alias rg='rg --no-ignore'
|
alias rg='rg --no-ignore'
|
||||||
|
alias fd='fd -HI'
|
||||||
|
|
113
dot_config/zsh/include/kitty.zsh
Normal file
113
dot_config/zsh/include/kitty.zsh
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
return
|
||||||
|
local csi="\x1b\x5b27u\x1b\x5b"
|
||||||
|
local ESCAPE="${csi}27u"
|
||||||
|
local ENTER="${csi}13u"
|
||||||
|
local TAB="${csi}9u"
|
||||||
|
local BACKSPACE="${csi}127u"
|
||||||
|
local INSERT="${csi}2~"
|
||||||
|
local DELETE="${csi}3~"
|
||||||
|
local LEFT="${csi}1D"
|
||||||
|
local RIGHT="${csi}1C"
|
||||||
|
local UP="${csi}1A"
|
||||||
|
local DOWN="${csi}1B"
|
||||||
|
local PAGE_UP="${csi}5~"
|
||||||
|
local PAGE_DOWN="${csi}6~"
|
||||||
|
local HOME="${csi}1H or 7 ~"
|
||||||
|
local END="${csi}1F or 8 ~"
|
||||||
|
local CAPS_LOCK="${csi}57358u"
|
||||||
|
local SCROLL_LOCK="${csi}57359u"
|
||||||
|
local NUM_LOCK="${csi}57360u"
|
||||||
|
local PRINT_SCREEN="${csi}57361u"
|
||||||
|
local PAUSE="${csi}57362u"
|
||||||
|
local MENU="${csi}57363u"
|
||||||
|
local F1="${csi}1P or 11 ~"
|
||||||
|
local F2="${csi}1Q or 12 ~"
|
||||||
|
local F3="${csi}1R or 13 ~"
|
||||||
|
local F4="${csi}1S or 14 ~"
|
||||||
|
local F5="${csi}15~"
|
||||||
|
local F6="${csi}17~"
|
||||||
|
local F7="${csi}18~"
|
||||||
|
local F8="${csi}19~"
|
||||||
|
local F9="${csi}20~"
|
||||||
|
local F10="${csi}21~"
|
||||||
|
local F11="${csi}23~"
|
||||||
|
local F12="${csi}24~"
|
||||||
|
local F13="${csi}57376u"
|
||||||
|
local F14="${csi}57377u"
|
||||||
|
local F15="${csi}57378u"
|
||||||
|
local F16="${csi}57379u"
|
||||||
|
local F17="${csi}57380u"
|
||||||
|
local F18="${csi}57381u"
|
||||||
|
local F19="${csi}57382u"
|
||||||
|
local F20="${csi}57383u"
|
||||||
|
local F21="${csi}57384u"
|
||||||
|
local F22="${csi}57385u"
|
||||||
|
local F23="${csi}57386u"
|
||||||
|
local F24="${csi}57387u"
|
||||||
|
local F25="${csi}57388u"
|
||||||
|
local F26="${csi}57389u"
|
||||||
|
local F27="${csi}57390u"
|
||||||
|
local F28="${csi}57391u"
|
||||||
|
local F29="${csi}57392u"
|
||||||
|
local F30="${csi}57393u"
|
||||||
|
local F31="${csi}57394u"
|
||||||
|
local F32="${csi}57395u"
|
||||||
|
local F33="${csi}57396u"
|
||||||
|
local F34="${csi}57397u"
|
||||||
|
local F35="${csi}57398u"
|
||||||
|
local KP_0="${csi}57399u"
|
||||||
|
local KP_1="${csi}57400u"
|
||||||
|
local KP_2="${csi}57401u"
|
||||||
|
local KP_3="${csi}57402u"
|
||||||
|
local KP_4="${csi}57403u"
|
||||||
|
local KP_5="${csi}57404u"
|
||||||
|
local KP_6="${csi}57405u"
|
||||||
|
local KP_7="${csi}57406u"
|
||||||
|
local KP_8="${csi}57407u"
|
||||||
|
local KP_9="${csi}57408u"
|
||||||
|
local KP_DECIMAL="${csi}57409u"
|
||||||
|
local KP_DIVIDE="${csi}57410u"
|
||||||
|
local KP_MULTIPLY="${csi}57411u"
|
||||||
|
local KP_SUBTRACT="${csi}57412u"
|
||||||
|
local KP_ADD="${csi}57413u"
|
||||||
|
local KP_ENTER="${csi}57414u"
|
||||||
|
local KP_EQUAL="${csi}57415u"
|
||||||
|
local KP_SEPARATOR="${csi}57416u"
|
||||||
|
local KP_LEFT="${csi}57417u"
|
||||||
|
local KP_RIGHT="${csi}57418u"
|
||||||
|
local KP_UP="${csi}57419u"
|
||||||
|
local KP_DOWN="${csi}57420u"
|
||||||
|
local KP_PAGE_UP="${csi}57421u"
|
||||||
|
local KP_PAGE_DOWN="${csi}57422u"
|
||||||
|
local KP_HOME="${csi}57423u"
|
||||||
|
local KP_END="${csi}57424u"
|
||||||
|
local KP_INSERT="${csi}57425u"
|
||||||
|
local KP_DELETE="${csi}57426u"
|
||||||
|
local KP_BEGIN="${csi}1E or 57427 ~"
|
||||||
|
local MEDIA_PLAY="${csi}57428u"
|
||||||
|
local MEDIA_PAUSE="${csi}57429u"
|
||||||
|
local MEDIA_PLAY_PAUSE="${csi}57430u"
|
||||||
|
local MEDIA_REVERSE="${csi}57431u"
|
||||||
|
local MEDIA_STOP="${csi}57432u"
|
||||||
|
local MEDIA_FAST_FORWARD="${csi}57433u"
|
||||||
|
local MEDIA_REWIND="${csi}57434u"
|
||||||
|
local MEDIA_TRACK_NEXT="${csi}57435u"
|
||||||
|
local MEDIA_TRACK_PREVIOUS="${csi}57436u"
|
||||||
|
local MEDIA_RECORD="${csi}57437u"
|
||||||
|
local LOWER_VOLUME="${csi}57438u"
|
||||||
|
local RAISE_VOLUME="${csi}57439u"
|
||||||
|
local MUTE_VOLUME="${csi}57440u"
|
||||||
|
local LEFT_SHIFT="${csi}57441u"
|
||||||
|
local LEFT_CONTROL="${csi}57442u"
|
||||||
|
local LEFT_ALT="${csi}57443u"
|
||||||
|
local LEFT_SUPER="${csi}57444u"
|
||||||
|
local LEFT_HYPER="${csi}57445u"
|
||||||
|
local LEFT_META="${csi}57446u"
|
||||||
|
local RIGHT_SHIFT="${csi}57447u"
|
||||||
|
local RIGHT_CONTROL="${csi}57448u"
|
||||||
|
local RIGHT_ALT="${csi}57449u"
|
||||||
|
local RIGHT_SUPER="${csi}57450u"
|
||||||
|
local RIGHT_HYPER="${csi}57451u"
|
||||||
|
local RIGHT_META="${csi}57452u"
|
||||||
|
local ISO_LEVEL3_SHIFT="${csi}57453u"
|
||||||
|
local ISO_LEVEL5_SHIFT="${csi}57454u"
|
108
dot_config/zsh/include/sudo.zsh
Normal file
108
dot_config/zsh/include/sudo.zsh
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Description
|
||||||
|
# -----------
|
||||||
|
#
|
||||||
|
# sudo or sudo -e (replacement for sudoedit) will be inserted before the command
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Authors
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# * Dongweiming <ciici123@gmail.com>
|
||||||
|
# * Subhaditya Nath <github.com/subnut>
|
||||||
|
# * Marc Cornellà <github.com/mcornella>
|
||||||
|
# * Carlo Sala <carlosalag@protonmail.com>
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
__sudo-replace-buffer() {
|
||||||
|
local old=$1 new=$2 space=${2:+ }
|
||||||
|
|
||||||
|
# if the cursor is positioned in the $old part of the text, make
|
||||||
|
# the substitution and leave the cursor after the $new text
|
||||||
|
if [[ $CURSOR -le ${#old} ]]; then
|
||||||
|
BUFFER="${new}${space}${BUFFER#$old }"
|
||||||
|
CURSOR=${#new}
|
||||||
|
# otherwise just replace $old with $new in the text before the cursor
|
||||||
|
else
|
||||||
|
LBUFFER="${new}${space}${LBUFFER#$old }"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
sudo-command-line() {
|
||||||
|
# If line is empty, get the last run command from history
|
||||||
|
[[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)"
|
||||||
|
|
||||||
|
# Save beginning space
|
||||||
|
local WHITESPACE=""
|
||||||
|
if [[ ${LBUFFER:0:1} = " " ]]; then
|
||||||
|
WHITESPACE=" "
|
||||||
|
LBUFFER="${LBUFFER:1}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
{
|
||||||
|
# If $SUDO_EDITOR or $VISUAL are defined, then use that as $EDITOR
|
||||||
|
# Else use the default $EDITOR
|
||||||
|
local EDITOR=${SUDO_EDITOR:-${VISUAL:-$EDITOR}}
|
||||||
|
|
||||||
|
# If $EDITOR is not set, just toggle the sudo prefix on and off
|
||||||
|
if [[ -z "$EDITOR" ]]; then
|
||||||
|
case "$BUFFER" in
|
||||||
|
sudo\ -e\ *) __sudo-replace-buffer "sudo -e" "" ;;
|
||||||
|
sudo\ *) __sudo-replace-buffer "sudo" "" ;;
|
||||||
|
*) LBUFFER="sudo $LBUFFER" ;;
|
||||||
|
esac
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the typed command is really an alias to $EDITOR
|
||||||
|
|
||||||
|
# Get the first part of the typed command
|
||||||
|
local cmd="${${(Az)BUFFER}[1]}"
|
||||||
|
# Get the first part of the alias of the same name as $cmd, or $cmd if no alias matches
|
||||||
|
local realcmd="${${(Az)aliases[$cmd]}[1]:-$cmd}"
|
||||||
|
# Get the first part of the $EDITOR command ($EDITOR may have arguments after it)
|
||||||
|
local editorcmd="${${(Az)EDITOR}[1]}"
|
||||||
|
|
||||||
|
# Note: ${var:c} makes a $PATH search and expands $var to the full path
|
||||||
|
# The if condition is met when:
|
||||||
|
# - $realcmd is '$EDITOR'
|
||||||
|
# - $realcmd is "cmd" and $EDITOR is "cmd"
|
||||||
|
# - $realcmd is "cmd" and $EDITOR is "cmd --with --arguments"
|
||||||
|
# - $realcmd is "/path/to/cmd" and $EDITOR is "cmd"
|
||||||
|
# - $realcmd is "/path/to/cmd" and $EDITOR is "/path/to/cmd"
|
||||||
|
# or
|
||||||
|
# - $realcmd is "cmd" and $EDITOR is "cmd"
|
||||||
|
# - $realcmd is "cmd" and $EDITOR is "/path/to/cmd"
|
||||||
|
# or
|
||||||
|
# - $realcmd is "cmd" and $EDITOR is /alternative/path/to/cmd that appears in $PATH
|
||||||
|
if [[ "$realcmd" = (\$EDITOR|$editorcmd|${editorcmd:c}) \
|
||||||
|
|| "${realcmd:c}" = ($editorcmd|${editorcmd:c}) ]] \
|
||||||
|
|| builtin which -a "$realcmd" | command grep -Fx -q "$editorcmd"; then
|
||||||
|
__sudo-replace-buffer "$cmd" "sudo -e"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for editor commands in the typed command and replace accordingly
|
||||||
|
case "$BUFFER" in
|
||||||
|
$editorcmd\ *) __sudo-replace-buffer "$editorcmd" "sudo -e" ;;
|
||||||
|
\$EDITOR\ *) __sudo-replace-buffer '$EDITOR' "sudo -e" ;;
|
||||||
|
sudo\ -e\ *) __sudo-replace-buffer "sudo -e" "$EDITOR" ;;
|
||||||
|
sudo\ *) __sudo-replace-buffer "sudo" "" ;;
|
||||||
|
*) LBUFFER="sudo $LBUFFER" ;;
|
||||||
|
esac
|
||||||
|
} always {
|
||||||
|
# Preserve beginning space
|
||||||
|
LBUFFER="${WHITESPACE}${LBUFFER}"
|
||||||
|
|
||||||
|
# Redisplay edit buffer (compatibility with zsh-syntax-highlighting)
|
||||||
|
zle redisplay
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
zle -N sudo-command-line
|
||||||
|
|
||||||
|
# Defined shortcut keys: [Esc] [Esc]
|
||||||
|
bindkey -M emacs '\e\e' sudo-command-line
|
||||||
|
bindkey -M vicmd '\e\e' sudo-command-line
|
||||||
|
bindkey -M viins '\e\e' sudo-command-line
|
|
@ -18,7 +18,7 @@ if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then
|
||||||
https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
|
https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for cf in ~/.config/zsh/init/*.zsh ; do
|
for cf in ~/.config/zsh/include/*.zsh ; do
|
||||||
source $cf
|
source $cf
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -28,8 +28,5 @@ fi
|
||||||
|
|
||||||
source ${ZIM_HOME}/init.zsh
|
source ${ZIM_HOME}/init.zsh
|
||||||
|
|
||||||
for cf in ~/.config/zsh/include/*.zsh ; do
|
|
||||||
source $cf
|
|
||||||
done
|
|
||||||
|
|
||||||
unset cachedir datadir confdir
|
unset cachedir datadir confdir
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
[base]
|
[base]
|
||||||
default = none
|
default = none
|
||||||
unknown-token = #cc241d,bold
|
unknown-token = #cc241d,bold,undercurl
|
||||||
commandseparator = none
|
commandseparator = none
|
||||||
redirection = none
|
redirection = none
|
||||||
here-string-tri = #8ec07c
|
here-string-tri = #8ec07c
|
||||||
here-string-text = bg:#fabd2f
|
here-string-text = bg:#fabd2f
|
||||||
here-string-var =#cc241d,bg:#fabd2f
|
here-string-var = #cc241d,bg:#fabd2f
|
||||||
exec-descriptor = #fb4934,bold
|
exec-descriptor = #fb4934,bold
|
||||||
comment = 8
|
comment = 8
|
||||||
correct-subtle = #83a598
|
correct-subtle = #83a598
|
||||||
|
@ -31,21 +31,21 @@ double-sq-bracket = #458588
|
||||||
double-paren = #b16286
|
double-paren = #b16286
|
||||||
|
|
||||||
[paths]
|
[paths]
|
||||||
path = #fb4934
|
path = none
|
||||||
pathseparator =
|
pathseparator =
|
||||||
path-to-dir = #fb4934,underline
|
path-to-dir = #b8bb26
|
||||||
globbing = #689d6a
|
globbing = #689d6a
|
||||||
globbing-ext = #689d6a,bold
|
globbing-ext = #689d6a,bold
|
||||||
|
|
||||||
[brackets]
|
[brackets]
|
||||||
paired-bracket = bg:8
|
paired-bracket = bg:8
|
||||||
bracket-level-1 =#d79921,bold
|
bracket-level-1 = #d79921,bold
|
||||||
bracket-level-2 = #689d6a,bold
|
bracket-level-2 = #689d6a,bold
|
||||||
bracket-level-3 = #98971a,bold
|
bracket-level-3 = #98971a,bold
|
||||||
|
|
||||||
[arguments]
|
[arguments]
|
||||||
single-hyphen-option =#d79921
|
single-hyphen-option = #d79921
|
||||||
double-hyphen-option =#d79921
|
double-hyphen-option = #d79921
|
||||||
back-quoted-argument = none
|
back-quoted-argument = none
|
||||||
single-quoted-argument = #98971a
|
single-quoted-argument = #98971a
|
||||||
double-quoted-argument = #98971a
|
double-quoted-argument = #98971a
|
||||||
|
|
Loading…
Add table
Reference in a new issue