Adjust formatting to be more suckless, and do something else \(I forgot\)
This commit is contained in:
parent
efb71aeb6b
commit
211765727f
1 changed files with 196 additions and 195 deletions
|
@ -1,3 +1,4 @@
|
|||
#!/bin/zsh
|
||||
#############
|
||||
# Autostart #
|
||||
#############
|
||||
|
@ -18,7 +19,7 @@ if [ -e /home/vehementham/.nix-profile/etc/profile.d/nix.sh ]; then . /home/vehe
|
|||
# Prompt #
|
||||
##########
|
||||
if [[ $(tty) != "/dev/tty"* ]]; then
|
||||
eval "$(starship init zsh)"
|
||||
eval "$(starship init zsh)"
|
||||
else
|
||||
autoload -U colors && colors
|
||||
|
||||
|
@ -206,26 +207,26 @@ source $Z_PATH
|
|||
# Foot Integration #
|
||||
####################
|
||||
function osc7-pwd() {
|
||||
emulate -L zsh # also sets localoptions for us
|
||||
setopt extendedglob
|
||||
local LC_ALL=C
|
||||
printf '\e]7;file://%s%s\e\' $HOST ${PWD//(#m)([^@-Za-z&-;_~])/%${(l:2::0:)$(([##16]#MATCH))}}
|
||||
emulate -L zsh # also sets localoptions for us
|
||||
setopt extendedglob
|
||||
local LC_ALL=C
|
||||
printf '\e]7;file://%s%s\e\' $HOST ${PWD//(#m)([^@-Za-z&-;_~])/%${(l:2::0:)$(([##16]#MATCH))}}
|
||||
}
|
||||
|
||||
function chpwd-osc7-pwd() {
|
||||
(( ZSH_SUBSHELL )) || osc7-pwd
|
||||
(( ZSH_SUBSHELL )) || osc7-pwd
|
||||
}
|
||||
add-zsh-hook -Uz chpwd chpwd-osc7-pwd
|
||||
|
||||
# Add functionality to pipe the output of the last command
|
||||
function precmd {
|
||||
if ! builtin zle; then
|
||||
print -n "\e]133;D\e\\"
|
||||
fi
|
||||
if ! builtin zle; then
|
||||
print -n "\e]133;D\e\\"
|
||||
fi
|
||||
}
|
||||
|
||||
function preexec {
|
||||
print -n "\e]133;C\e\\"
|
||||
print -n "\e]133;C\e\\"
|
||||
}
|
||||
|
||||
##################
|
||||
|
@ -334,234 +335,234 @@ export KEY_CTRL_BACKSPACE='^H'
|
|||
# copy selected terminal text to clipboard
|
||||
zle -N widget::copy-selection
|
||||
function widget::copy-selection {
|
||||
if ((REGION_ACTIVE)); then
|
||||
zle copy-region-as-kill
|
||||
printf "%s" $CUTBUFFER | wl-copy
|
||||
fi
|
||||
if ((REGION_ACTIVE)); then
|
||||
zle copy-region-as-kill
|
||||
printf "%s" $CUTBUFFER | wl-copy
|
||||
fi
|
||||
}
|
||||
|
||||
# cut selected terminal text to clipboard
|
||||
zle -N widget::cut-selection
|
||||
function widget::cut-selection() {
|
||||
if ((REGION_ACTIVE)) then
|
||||
zle kill-region
|
||||
printf "%s" $CUTBUFFER | wl-copy
|
||||
fi
|
||||
if ((REGION_ACTIVE)) then
|
||||
zle kill-region
|
||||
printf "%s" $CUTBUFFER | wl-copy
|
||||
fi
|
||||
}
|
||||
|
||||
# paste clipboard contents
|
||||
zle -N widget::paste
|
||||
function widget::paste() {
|
||||
((REGION_ACTIVE)) && zle kill-region
|
||||
RBUFFER="$(pbpaste)${RBUFFER}"
|
||||
CURSOR=$(( CURSOR + $(echo -n "$(pbpaste)" | wc -m | bc) ))
|
||||
((REGION_ACTIVE)) && zle kill-region
|
||||
RBUFFER="$(pbpaste)${RBUFFER}"
|
||||
CURSOR=$(( CURSOR + $(echo -n "$(pbpaste)" | wc -m | bc) ))
|
||||
}
|
||||
|
||||
# select entire prompt
|
||||
zle -N widget::select-all
|
||||
function widget::select-all() {
|
||||
local buflen=$(echo -n "$BUFFER" | wc -m | bc)
|
||||
CURSOR=$buflen # if this is messing up try: CURSOR=9999999
|
||||
zle set-mark-command
|
||||
while [[ $CURSOR > 0 ]]; do
|
||||
zle beginning-of-line
|
||||
done
|
||||
local buflen=$(echo -n "$BUFFER" | wc -m | bc)
|
||||
CURSOR=$buflen # if this is messing up try: CURSOR=9999999
|
||||
zle set-mark-command
|
||||
while [[ $CURSOR > 0 ]]; do
|
||||
zle beginning-of-line
|
||||
done
|
||||
}
|
||||
|
||||
# scrolls the screen up, in effect clearing it
|
||||
zle -N widget::scroll-and-clear-screen
|
||||
function widget::scroll-and-clear-screen() {
|
||||
printf "\n%.0s" {1..$LINES}
|
||||
zle clear-screen
|
||||
printf "\n%.0s" {1..$LINES}
|
||||
zle clear-screen
|
||||
}
|
||||
|
||||
function widget::util-select() {
|
||||
((REGION_ACTIVE)) || zle set-mark-command
|
||||
local widget_name=$1
|
||||
shift
|
||||
zle $widget_name -- $@
|
||||
zle copy-region-as-kill
|
||||
printf "%s" $CUTBUFFER | wl-copy --primary
|
||||
((REGION_ACTIVE)) || zle set-mark-command
|
||||
local widget_name=$1
|
||||
shift
|
||||
zle $widget_name -- $@
|
||||
zle copy-region-as-kill
|
||||
printf "%s" $CUTBUFFER | wl-copy --primary
|
||||
}
|
||||
|
||||
function widget::util-unselect() {
|
||||
REGION_ACTIVE=0
|
||||
local widget_name=$1
|
||||
shift
|
||||
zle $widget_name -- $@
|
||||
REGION_ACTIVE=0
|
||||
local widget_name=$1
|
||||
shift
|
||||
zle $widget_name -- $@
|
||||
}
|
||||
|
||||
function widget::util-delselect() {
|
||||
if ((REGION_ACTIVE)) then
|
||||
zle kill-region
|
||||
else
|
||||
local widget_name=$1
|
||||
shift
|
||||
zle $widget_name -- $@
|
||||
fi
|
||||
if ((REGION_ACTIVE)) then
|
||||
zle kill-region
|
||||
else
|
||||
local widget_name=$1
|
||||
shift
|
||||
zle $widget_name -- $@
|
||||
fi
|
||||
}
|
||||
|
||||
function widget::util-insertchar() {
|
||||
((REGION_ACTIVE)) && zle kill-region
|
||||
RBUFFER="${1}${RBUFFER}"
|
||||
zle forward-char
|
||||
((REGION_ACTIVE)) && zle kill-region
|
||||
RBUFFER="${1}${RBUFFER}"
|
||||
zle forward-char
|
||||
}
|
||||
|
||||
# | key sequence | command
|
||||
# --------------------- | ------------------------------- | -------------
|
||||
# | key sequence | command
|
||||
# ------------------- | ------------------------------- | -------------
|
||||
|
||||
bindkey $KEY_ALT_F forward-word
|
||||
bindkey $KEY_ALT_B backward-word
|
||||
bindkey $KEY_ALT_D kill-word
|
||||
bindkey $KEY_CTRL_U backward-kill-line
|
||||
bindkey $KEY_CTRL_BACKSPACE backward-kill-word
|
||||
bindkey $KEY_CTRL_Z undo
|
||||
bindkey $KEY_SHIFT_CTRL_Z redo
|
||||
bindkey $KEY_CTRL_R history-incremental-search-backward
|
||||
bindkey $KEY_SHIFT_CTRL_C widget::copy-selection
|
||||
bindkey $KEY_SHIFT_CTRL_X widget::cut-selection
|
||||
bindkey $KEY_SHIFT_CTRL_V widget::paste
|
||||
bindkey $KEY_SHIFT_CTRL_A widget::select-all
|
||||
bindkey $KEY_CTRL_L widget::scroll-and-clear-screen
|
||||
bindkey $KEY_ALT_F forward-word
|
||||
bindkey $KEY_ALT_B backward-word
|
||||
bindkey $KEY_ALT_D kill-word
|
||||
bindkey $KEY_CTRL_U backward-kill-line
|
||||
bindkey $KEY_CTRL_BACKSPACE backward-kill-word
|
||||
bindkey $KEY_CTRL_Z undo
|
||||
bindkey $KEY_SHIFT_CTRL_Z redo
|
||||
bindkey $KEY_CTRL_R history-incremental-search-backward
|
||||
bindkey $KEY_SHIFT_CTRL_C widget::copy-selection
|
||||
bindkey $KEY_SHIFT_CTRL_X widget::cut-selection
|
||||
bindkey $KEY_SHIFT_CTRL_V widget::paste
|
||||
bindkey $KEY_SHIFT_CTRL_A widget::select-all
|
||||
bindkey $KEY_CTRL_L widget::scroll-and-clear-screen
|
||||
|
||||
for keyname kcap seq mode widget (
|
||||
for keyname kcap seq mode widget (
|
||||
|
||||
left kcub1 $KEY_LEFT unselect backward-char
|
||||
right kcuf1 $KEY_RIGHT unselect forward-char
|
||||
left kcub1 $KEY_LEFT unselect backward-char
|
||||
right kcuf1 $KEY_RIGHT unselect forward-char
|
||||
|
||||
shift-up kri $KEY_SHIFT_UP select up-line-or-history
|
||||
shift-down kind $KEY_SHIFT_DOWN select down-line-or-history
|
||||
shift-right kRIT $KEY_SHIFT_RIGHT select forward-char
|
||||
shift-left kLFT $KEY_SHIFT_LEFT select backward-char
|
||||
shift-up kri $KEY_SHIFT_UP select up-line-or-history
|
||||
shift-down kind $KEY_SHIFT_DOWN select down-line-or-history
|
||||
shift-right kRIT $KEY_SHIFT_RIGHT select forward-char
|
||||
shift-left kLFT $KEY_SHIFT_LEFT select backward-char
|
||||
|
||||
alt-right x $KEY_ALT_RIGHT unselect forward-word
|
||||
alt-left x $KEY_ALT_LEFT unselect backward-word
|
||||
shift-alt-right x $KEY_SHIFT_ALT_RIGHT select forward-word
|
||||
shift-alt-left x $KEY_SHIFT_ALT_LEFT select backward-word
|
||||
alt-right x $KEY_ALT_RIGHT unselect forward-word
|
||||
alt-left x $KEY_ALT_LEFT unselect backward-word
|
||||
shift-alt-right x $KEY_SHIFT_ALT_RIGHT select forward-word
|
||||
shift-alt-left x $KEY_SHIFT_ALT_LEFT select backward-word
|
||||
|
||||
ctrl-right x $KEY_CTRL_RIGHT unselect forward-word
|
||||
ctrl-left x $KEY_CTRL_LEFT unselect backward-word
|
||||
shift-cmd-right x $KEY_SHIFT_CTRL_RIGHT select end-of-line
|
||||
shift-cmd-left x $KEY_SHIFT_CTRL_LEFT select beginning-of-line
|
||||
ctrl-right x $KEY_CTRL_RIGHT unselect forward-word
|
||||
ctrl-left x $KEY_CTRL_LEFT unselect backward-word
|
||||
shift-cmd-right x $KEY_SHIFT_CTRL_RIGHT select end-of-line
|
||||
shift-cmd-left x $KEY_SHIFT_CTRL_LEFT select beginning-of-line
|
||||
|
||||
ctrl-e x $KEY_CTRL_E unselect end-of-line
|
||||
ctrl-a x $KEY_CTRL_A unselect beginning-of-line
|
||||
shift-ctrl-e x $KEY_SHIFT_CTRL_E select end-of-line
|
||||
shift-ctrl-a x $KEY_SHIFT_CTRL_A select beginning-of-line
|
||||
shift-ctrl-right x $KEY_SHIFT_CTRL_RIGHT select forward-word
|
||||
shift-ctrl-left x $KEY_SHIFT_CTRL_LEFT select backward-word
|
||||
ctrl-e x $KEY_CTRL_E unselect end-of-line
|
||||
ctrl-a x $KEY_CTRL_A unselect beginning-of-line
|
||||
shift-ctrl-e x $KEY_SHIFT_CTRL_E select end-of-line
|
||||
shift-ctrl-a x $KEY_SHIFT_CTRL_A select beginning-of-line
|
||||
shift-ctrl-right x $KEY_SHIFT_CTRL_RIGHT select forward-word
|
||||
shift-ctrl-left x $KEY_SHIFT_CTRL_LEFT select backward-word
|
||||
|
||||
end kend $KEY_END unselect end-of-line
|
||||
shift-end kEND $KEY_SHIFT_END select end-of-line
|
||||
end kend $KEY_END unselect end-of-line
|
||||
shift-end kEND $KEY_SHIFT_END select end-of-line
|
||||
|
||||
home khome $KEY_HOME unselect beginning-of-line
|
||||
shift-home kHOM $KEY_SHIFT_HOME select beginning-of-line
|
||||
home khome $KEY_HOME unselect beginning-of-line
|
||||
shift-home kHOM $KEY_SHIFT_HOME select beginning-of-line
|
||||
|
||||
del x $KEY_DELETE delselect delete-char
|
||||
backspace x $KEY_BACKSPACE delselect backward-delete-char
|
||||
del x $KEY_DELETE delselect delete-char
|
||||
backspace x $KEY_BACKSPACE delselect backward-delete-char
|
||||
|
||||
a x 'a' insertchar 'a'
|
||||
b x 'b' insertchar 'b'
|
||||
c x 'c' insertchar 'c'
|
||||
d x 'd' insertchar 'd'
|
||||
e x 'e' insertchar 'e'
|
||||
f x 'f' insertchar 'f'
|
||||
g x 'g' insertchar 'g'
|
||||
h x 'h' insertchar 'h'
|
||||
i x 'i' insertchar 'i'
|
||||
j x 'j' insertchar 'j'
|
||||
k x 'k' insertchar 'k'
|
||||
l x 'l' insertchar 'l'
|
||||
m x 'm' insertchar 'm'
|
||||
n x 'n' insertchar 'n'
|
||||
o x 'o' insertchar 'o'
|
||||
p x 'p' insertchar 'p'
|
||||
q x 'q' insertchar 'q'
|
||||
r x 'r' insertchar 'r'
|
||||
s x 's' insertchar 's'
|
||||
t x 't' insertchar 't'
|
||||
u x 'u' insertchar 'u'
|
||||
v x 'v' insertchar 'v'
|
||||
w x 'w' insertchar 'w'
|
||||
x x 'x' insertchar 'x'
|
||||
y x 'y' insertchar 'y'
|
||||
z x 'z' insertchar 'z'
|
||||
A x 'A' insertchar 'A'
|
||||
B x 'B' insertchar 'B'
|
||||
C x 'C' insertchar 'C'
|
||||
D x 'D' insertchar 'D'
|
||||
E x 'E' insertchar 'E'
|
||||
F x 'F' insertchar 'F'
|
||||
G x 'G' insertchar 'G'
|
||||
H x 'H' insertchar 'H'
|
||||
I x 'I' insertchar 'I'
|
||||
J x 'J' insertchar 'J'
|
||||
K x 'K' insertchar 'K'
|
||||
L x 'L' insertchar 'L'
|
||||
M x 'M' insertchar 'M'
|
||||
N x 'N' insertchar 'N'
|
||||
O x 'O' insertchar 'O'
|
||||
P x 'P' insertchar 'P'
|
||||
Q x 'Q' insertchar 'Q'
|
||||
R x 'R' insertchar 'R'
|
||||
S x 'S' insertchar 'S'
|
||||
T x 'T' insertchar 'T'
|
||||
U x 'U' insertchar 'U'
|
||||
V x 'V' insertchar 'V'
|
||||
W x 'W' insertchar 'W'
|
||||
X x 'X' insertchar 'X'
|
||||
Y x 'Y' insertchar 'Y'
|
||||
Z x 'Z' insertchar 'Z'
|
||||
0 x '0' insertchar '0'
|
||||
1 x '1' insertchar '1'
|
||||
2 x '2' insertchar '2'
|
||||
3 x '3' insertchar '3'
|
||||
4 x '4' insertchar '4'
|
||||
5 x '5' insertchar '5'
|
||||
6 x '6' insertchar '6'
|
||||
7 x '7' insertchar '7'
|
||||
8 x '8' insertchar '8'
|
||||
9 x '9' insertchar '9'
|
||||
a x 'a' insertchar 'a'
|
||||
b x 'b' insertchar 'b'
|
||||
c x 'c' insertchar 'c'
|
||||
d x 'd' insertchar 'd'
|
||||
e x 'e' insertchar 'e'
|
||||
f x 'f' insertchar 'f'
|
||||
g x 'g' insertchar 'g'
|
||||
h x 'h' insertchar 'h'
|
||||
i x 'i' insertchar 'i'
|
||||
j x 'j' insertchar 'j'
|
||||
k x 'k' insertchar 'k'
|
||||
l x 'l' insertchar 'l'
|
||||
m x 'm' insertchar 'm'
|
||||
n x 'n' insertchar 'n'
|
||||
o x 'o' insertchar 'o'
|
||||
p x 'p' insertchar 'p'
|
||||
q x 'q' insertchar 'q'
|
||||
r x 'r' insertchar 'r'
|
||||
s x 's' insertchar 's'
|
||||
t x 't' insertchar 't'
|
||||
u x 'u' insertchar 'u'
|
||||
v x 'v' insertchar 'v'
|
||||
w x 'w' insertchar 'w'
|
||||
x x 'x' insertchar 'x'
|
||||
y x 'y' insertchar 'y'
|
||||
z x 'z' insertchar 'z'
|
||||
A x 'A' insertchar 'A'
|
||||
B x 'B' insertchar 'B'
|
||||
C x 'C' insertchar 'C'
|
||||
D x 'D' insertchar 'D'
|
||||
E x 'E' insertchar 'E'
|
||||
F x 'F' insertchar 'F'
|
||||
G x 'G' insertchar 'G'
|
||||
H x 'H' insertchar 'H'
|
||||
I x 'I' insertchar 'I'
|
||||
J x 'J' insertchar 'J'
|
||||
K x 'K' insertchar 'K'
|
||||
L x 'L' insertchar 'L'
|
||||
M x 'M' insertchar 'M'
|
||||
N x 'N' insertchar 'N'
|
||||
O x 'O' insertchar 'O'
|
||||
P x 'P' insertchar 'P'
|
||||
Q x 'Q' insertchar 'Q'
|
||||
R x 'R' insertchar 'R'
|
||||
S x 'S' insertchar 'S'
|
||||
T x 'T' insertchar 'T'
|
||||
U x 'U' insertchar 'U'
|
||||
V x 'V' insertchar 'V'
|
||||
W x 'W' insertchar 'W'
|
||||
X x 'X' insertchar 'X'
|
||||
Y x 'Y' insertchar 'Y'
|
||||
Z x 'Z' insertchar 'Z'
|
||||
0 x '0' insertchar '0'
|
||||
1 x '1' insertchar '1'
|
||||
2 x '2' insertchar '2'
|
||||
3 x '3' insertchar '3'
|
||||
4 x '4' insertchar '4'
|
||||
5 x '5' insertchar '5'
|
||||
6 x '6' insertchar '6'
|
||||
7 x '7' insertchar '7'
|
||||
8 x '8' insertchar '8'
|
||||
9 x '9' insertchar '9'
|
||||
|
||||
exclamation-mark x '!' insertchar '!'
|
||||
hash-sign x '\#' insertchar '\#'
|
||||
dollar-sign x '$' insertchar '$'
|
||||
percent-sign x '%' insertchar '%'
|
||||
ampersand-sign x '\&' insertchar '\&'
|
||||
star x '\*' insertchar '\*'
|
||||
plus x '+' insertchar '+'
|
||||
comma x ',' insertchar ','
|
||||
dot x '.' insertchar '.'
|
||||
forwardslash x '\\' insertchar '\\'
|
||||
backslash x '/' insertchar '/'
|
||||
colon x ':' insertchar ':'
|
||||
semi-colon x '\;' insertchar '\;'
|
||||
left-angle-bracket x '\<' insertchar '\<'
|
||||
right-angle-bracket x '\>' insertchar '\>'
|
||||
equal-sign x '=' insertchar '='
|
||||
question-mark x '\?' insertchar '\?'
|
||||
left-square-bracket x '[' insertchar '['
|
||||
right-square-bracket x ']' insertchar ']'
|
||||
hat-sign x '^' insertchar '^'
|
||||
underscore x '_' insertchar '_'
|
||||
left-brace x '{' insertchar '{'
|
||||
right-brace x '\}' insertchar '\}'
|
||||
left-parenthesis x '\(' insertchar '\('
|
||||
right-parenthesis x '\)' insertchar '\)'
|
||||
pipe x '\|' insertchar '\|'
|
||||
tilde x '\~' insertchar '\~'
|
||||
at-sign x '@' insertchar '@'
|
||||
dash x '\-' insertchar '\-'
|
||||
double-quote x '\"' insertchar '\"'
|
||||
single-quote x "\'" insertchar "\'"
|
||||
backtick x '\`' insertchar '\`'
|
||||
whitespace x '\ ' insertchar '\ '
|
||||
exclamation-mark x '!' insertchar '!'
|
||||
hash-sign x '\#' insertchar '\#'
|
||||
dollar-sign x '$' insertchar '$'
|
||||
percent-sign x '%' insertchar '%'
|
||||
ampersand-sign x '\&' insertchar '\&'
|
||||
star x '\*' insertchar '\*'
|
||||
plus x '+' insertchar '+'
|
||||
comma x ',' insertchar ','
|
||||
dot x '.' insertchar '.'
|
||||
forwardslash x '\\' insertchar '\\'
|
||||
backslash x '/' insertchar '/'
|
||||
colon x ':' insertchar ':'
|
||||
semi-colon x '\;' insertchar '\;'
|
||||
left-angle-bracket x '\<' insertchar '\<'
|
||||
right-angle-bracket x '\>' insertchar '\>'
|
||||
equal-sign x '=' insertchar '='
|
||||
question-mark x '\?' insertchar '\?'
|
||||
left-square-bracket x '[' insertchar '['
|
||||
right-square-bracket x ']' insertchar ']'
|
||||
hat-sign x '^' insertchar '^'
|
||||
underscore x '_' insertchar '_'
|
||||
left-brace x '{' insertchar '{'
|
||||
right-brace x '\}' insertchar '\}'
|
||||
left-parenthesis x '\(' insertchar '\('
|
||||
right-parenthesis x '\)' insertchar '\)'
|
||||
pipe x '\|' insertchar '\|'
|
||||
tilde x '\~' insertchar '\~'
|
||||
at-sign x '@' insertchar '@'
|
||||
dash x '\-' insertchar '\-'
|
||||
double-quote x '\"' insertchar '\"'
|
||||
single-quote x "\'" insertchar "\'"
|
||||
backtick x '\`' insertchar '\`'
|
||||
whitespace x '\ ' insertchar '\ '
|
||||
) {
|
||||
eval "function widget::key-$keyname() {
|
||||
widget::util-$mode $widget \$@
|
||||
}"
|
||||
zle -N widget::key-$keyname
|
||||
bindkey $seq widget::key-$keyname
|
||||
eval "function widget::key-$keyname() {
|
||||
widget::util-$mode $widget \$@
|
||||
}"
|
||||
zle -N widget::key-$keyname
|
||||
bindkey $seq widget::key-$keyname
|
||||
}
|
||||
|
||||
# Fixes autosuggest completion being overriden by keybindings:
|
||||
|
@ -571,8 +572,8 @@ for keyname kcap seq mode widget (
|
|||
# functions are triggered, they will also complete any visible
|
||||
# suggestion. Example:
|
||||
export ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=(
|
||||
widget::key-right
|
||||
widget::key-shift-right
|
||||
widget::key-cmd-right
|
||||
widget::key-shift-cmd-right
|
||||
widget::key-right
|
||||
widget::key-shift-right
|
||||
widget::key-cmd-right
|
||||
widget::key-shift-cmd-right
|
||||
)
|
Loading…
Reference in a new issue