This commit is contained in:
2026-03-27 02:19:37 +01:00
parent 22f55f2ae9
commit bcd2909722
8 changed files with 184 additions and 94 deletions
+14 -5
View File
@@ -13,16 +13,13 @@ setopt HIST_VERIFY
setopt AUTO_CD EXTENDED_GLOB NOTIFY INTERACTIVE_COMMENTS
bindkey -e
# Allow word-based navigation and deletion to work on paths
WORDCHARS=${WORDCHARS//\//}
WORDCHARS=${WORDCHARS//[\/=\*-]/}
# Rookie keybindings :)
bindkey '^[[1;5D' backward-word # C-Left
bindkey '^[[1;5C' forward-word # C-Right
bindkey '^H' backward-kill-word # C-Backspace (also C-H)
bindkey '^Z' undo # C-z
# bindkey '^Z' undo # C-z
# A-s to prepend sudo
uy_prepend_sudo() {
@@ -35,3 +32,15 @@ uy_prepend_sudo() {
}
zle -N uy_prepend_sudo
bindkey '^[s' uy_prepend_sudo
# Edit current command in editor
autoload -Uz edit-command-line
zle -N edit-command-line
bindkey '^X' edit-command-line
# Magic space
# bindkey ' ' magic-space
# This is already handled by tab
# zmv
autoload zmv
+3 -3
View File
@@ -7,11 +7,11 @@ uy_oops_confirm() {
local last_line=$(tail -n 1 "$HISTFILE")
if [[ -z "$last_line" ]]; then
print -P "%F{yellow}History file is empty, nothing to clean. %f"
print -P "%F{yellow}History file is empty, nothing to delete.%f"
return 0
fi
print -P "About to permanently delete the last command from history:"
print -P "About to permanently delete the last command from history file:"
print -P "%F{red} $last_line%f"
local reply
@@ -20,7 +20,7 @@ uy_oops_confirm() {
if [[ -z "$reply" || "$reply" == [yY]* ]]; then
sed -i '$d' "$HISTFILE"
print -P "%F{green}Command removed from history.%f"
print -P "%F{green}Command removed from history file (may still visible in current session).%f"
else
print -P "%F{yellow}Operation cancelled.%f"
fi
+17 -5
View File
@@ -9,7 +9,6 @@ if (( $+commands[fzf] )); then
elif (( $+commands[fdfind] )); then
export FD_CMD="fdfind"
fi
if [[ -n "$FD_CMD" ]]; then
export FZF_DEFAULT_COMMAND="$FD_CMD --type f --hidden --exclude .git"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
@@ -38,7 +37,7 @@ if (( $+commands[fzf] )); then
# fkp: fuzzy find a process and kill
fkp() {
local pids
pids=$(ps -ef | fzf -m --header-lines 1 --preview 'pstree -p $(echo {} | awk "{print \$2}")' --header '[kill process]' | awk '{print $2}')
pids=$(ps -ef | fzf -m --header-lines 1 --preview 'pstree -p $(echo {} | awk "{print \$2}")' --header "[kill process]" | awk '{print $2}')
echo "$pids" | xargs -r kill -${1:-9}
}
@@ -48,7 +47,7 @@ if (( $+commands[fzf] )); then
local pids
# Call sudo separately since one cannot enter password in fzf's window
pids=$(sudo ss -lptn)
pids=$(echo "$pids" | fzf -m --header-lines 1 --header '[kill process]' | grep -oP 'pid=\K\d+')
pids=$(echo "$pids" | fzf -m --header-lines 1 --header "[kill process]" | grep -oP 'pid=\K\d+')
echo "$pids" | xargs -r sudo kill -${1:-9}
}
fi
@@ -60,7 +59,7 @@ if (( $+commands[fzf] )); then
# fyi: fuzzy yay install
fyi() {
local pkg
pkg=$(yay -Sl | awk '{print $1"/"$2}' | fzf -m --preview 'yay -Si {}' --header '[install package]' "$@")
pkg=$(yay -Sl | awk '{print $1"/"$2}' | fzf -m --preview 'yay -Si {}' --header "[install package]" "$@")
# yay supports "repo/package" format
[[ -n "$pkg" ]] && yay -S ${=pkg}
}
@@ -68,7 +67,7 @@ if (( $+commands[fzf] )); then
# fyr: fuzzy yay remove
fyr() {
local pkg
pkg=$(yay -Qq | fzf -m --preview 'yay -Qi {}' --header '[remove package]' "$@")
pkg=$(yay -Qq | fzf -m --preview 'yay -Qi {}' --header "[remove package]" "$@")
[[ -n "$pkg" ]] && yay -Rn ${=pkg}
}
fi
@@ -207,3 +206,16 @@ if (( $+commands[git] )); then
}
fi
fi
# Global aliases (can be used as part of a command)
# wl-paste
if (( $+commands[wl-paste] )); then
alias -g C="| wl-copy"
fi
# Redirects
alias -g NE="2>/dev/null"
alias -g NO=">/dev/null"
alias -g EO="2>&1"
alias -g NUL="&>/dev/null"