zsh: remove unused functions, add Sc=systemctl cat, tweak history a bit
This commit is contained in:
parent
d368bc7993
commit
e2198a8dc8
1 changed files with 10 additions and 81 deletions
|
@ -41,7 +41,7 @@ alias gitc="git commit"
|
||||||
alias gitp="git push"
|
alias gitp="git push"
|
||||||
alias gitl="git log --shortstat --graph"
|
alias gitl="git log --shortstat --graph"
|
||||||
alias gitd="git diff --word-diff"
|
alias gitd="git diff --word-diff"
|
||||||
alias Y="noglob yt-dlp --no-mtime --no-check-certificate -f 'bestvideo[height<=1080]+bestaudio/best[height<=1080]'"
|
alias Y="noglob yt-dlp --no-mtime --merge-output-format mkv --remux-video mkv --add-metadata --embed-subs --no-check-certificate -f 'bestvideo[height<=1080]+bestaudio/best[height<=1080]'"
|
||||||
alias Ysound="noglob yt-dlp --no-mtime --no-check-certificate -f bestaudio --remux-video opus"
|
alias Ysound="noglob yt-dlp --no-mtime --no-check-certificate -f bestaudio --remux-video opus"
|
||||||
alias battery="upower -i /org/freedesktop/UPower/devices/battery_BAT0"
|
alias battery="upower -i /org/freedesktop/UPower/devices/battery_BAT0"
|
||||||
alias pp=python2
|
alias pp=python2
|
||||||
|
@ -50,6 +50,7 @@ alias Ju="journalctl --unit"
|
||||||
alias Jue="journalctl --pager-end --unit"
|
alias Jue="journalctl --pager-end --unit"
|
||||||
alias Juf="journalctl --follow --unit"
|
alias Juf="journalctl --follow --unit"
|
||||||
alias Ss="systemctl status --no-pager"
|
alias Ss="systemctl status --no-pager"
|
||||||
|
alias Sc="systemctl cat"
|
||||||
alias SE="systemctl enable"
|
alias SE="systemctl enable"
|
||||||
alias SD="systemctl disable"
|
alias SD="systemctl disable"
|
||||||
alias SS="systemctl start"
|
alias SS="systemctl start"
|
||||||
|
@ -68,9 +69,6 @@ alias uSL="systemctl --user reload"
|
||||||
alias uSX="systemctl --user stop"
|
alias uSX="systemctl --user stop"
|
||||||
alias dmesg="dmesg -e"
|
alias dmesg="dmesg -e"
|
||||||
|
|
||||||
# apparently this is the only way of setting GNU Screen to UTF-8
|
|
||||||
alias screen="screen -U"
|
|
||||||
|
|
||||||
# Edit the current command line in $EDITOR
|
# Edit the current command line in $EDITOR
|
||||||
export VISUAL="nano"
|
export VISUAL="nano"
|
||||||
autoload -U edit-command-line
|
autoload -U edit-command-line
|
||||||
|
@ -85,17 +83,6 @@ mkcd () {
|
||||||
mkdir -p "$1" && cd "$1"
|
mkdir -p "$1" && cd "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
mkv-fixtitles () {
|
|
||||||
for arg in "$@"
|
|
||||||
do
|
|
||||||
title="${arg%%.[mM][kK][vV]}"
|
|
||||||
mkvpropedit "$arg" --set "title=$title" --edit track:v1 --delete name > /dev/null
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "$arg failed"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
psg () { ps axu | grep -v grep | grep -i $* } # hledání v běžících procesech
|
psg () { ps axu | grep -v grep | grep -i $* } # hledání v běžících procesech
|
||||||
|
|
||||||
pskill () {
|
pskill () {
|
||||||
|
@ -119,53 +106,16 @@ zres () {
|
||||||
hash -r
|
hash -r
|
||||||
}
|
}
|
||||||
|
|
||||||
# kill GNU Screen pages in the specified range
|
|
||||||
kill_screens () {
|
|
||||||
for p in {$1..$2}
|
|
||||||
do
|
|
||||||
screen -p $p -X stuff "exit\n"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
http-dir () {
|
http-dir () {
|
||||||
echo "Serving $PWD on 0.0.0.0:55555"
|
echo "Serving $PWD on 0.0.0.0:55555"
|
||||||
python3 -m http.server 55555
|
python3 -m http.server 55555
|
||||||
}
|
}
|
||||||
|
|
||||||
function die () {
|
function failed_whike () {
|
||||||
echo "died during ${1}"
|
echo "failed while ${1}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function mkvoid () {
|
|
||||||
__MKVOID_TARGET="$1"
|
|
||||||
__MKVOID_PATH="${__MKVOID_TARGET:P}"
|
|
||||||
__MKVOID_DIR="${__MKVOID_PATH:h}"
|
|
||||||
__MKVOID_NAME="${__MKVOID_PATH:t}"
|
|
||||||
__MKVOID_ID="/dev/shm/void/${__MKVOID_PATH:l:gs/\///:gs/ //}"
|
|
||||||
|
|
||||||
mkdir -p "/dev/shm/void" || die "mkdir void"
|
|
||||||
mkdir "${__MKVOID_ID}" || die "mkdir shm"
|
|
||||||
mkdir -p "${__MKVOID_DIR}" || die "mkdir fs"
|
|
||||||
ln -s "${__MKVOID_ID}" "${__MKVOID_PATH}" || die "ln"
|
|
||||||
pushd "${__MKVOID_PATH}" > /dev/null || die "pushd"
|
|
||||||
OVER_PROMPT_VOIDS="$OVER_PROMPT_VOIDS:$__MKVOID_NAME" zsh
|
|
||||||
popd > /dev/null
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
fuser -s "${__MKVOID_PATH}"
|
|
||||||
if [[ $? == 1 ]]; then
|
|
||||||
break
|
|
||||||
else
|
|
||||||
echo -n ">>> Waiting for other processes to abandon this void.\r"
|
|
||||||
fi
|
|
||||||
sleep 5
|
|
||||||
done
|
|
||||||
|
|
||||||
rm -f "${__MKVOID_PATH}" || die "rm link"
|
|
||||||
rm -rf "${__MKVOID_ID}" || die "rm void"
|
|
||||||
}
|
|
||||||
|
|
||||||
# loop-shell COMMAND creates a shell that takes user_input and runs COMMAND user_input
|
# loop-shell COMMAND creates a shell that takes user_input and runs COMMAND user_input
|
||||||
# e.g. "loop-shell grep -ri" creates a grepping shell
|
# e.g. "loop-shell grep -ri" creates a grepping shell
|
||||||
function loop-shell {
|
function loop-shell {
|
||||||
|
@ -182,34 +132,13 @@ HISTFILE=~/.history
|
||||||
HISTSIZE=10000000
|
HISTSIZE=10000000
|
||||||
SAVEHIST=10000000
|
SAVEHIST=10000000
|
||||||
setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
|
setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
|
||||||
setopt HIST_VERIFY # Don't execute immediately upon history expansion.
|
setopt INC_APPEND_HISTORY_TIME # Append to file immediately.
|
||||||
bindkey '\e[A' history-beginning-search-backward # completion from history with Up/Down keys
|
bindkey '\e[A' history-beginning-search-backward # Completion from history
|
||||||
bindkey '\e[B' history-beginning-search-forward #
|
bindkey '\e[B' history-beginning-search-forward # with Up/Down keys.
|
||||||
|
|
||||||
# general prompt hooks incl. history management
|
|
||||||
# (only commit successful commands, but cache all)
|
|
||||||
# © http://scarff.id.au/blog/2019/zsh-history-conditional-on-command-success/
|
|
||||||
function zshaddhistory() {
|
|
||||||
## called before a history line is saved. See zshmisc(1).
|
|
||||||
|
|
||||||
# Prevent the command from being written to history before it's
|
|
||||||
# executed; save it to LASTHIST instead. Write it to history
|
|
||||||
# in precmd.
|
|
||||||
LASTHIST=$1
|
|
||||||
# Return value 2: "... the history line will be saved on the internal
|
|
||||||
# history list, but not written to the history file".
|
|
||||||
return 2
|
|
||||||
}
|
|
||||||
|
|
||||||
function precmd() {
|
function precmd() {
|
||||||
## zsh hook called before the prompt is printed. See zshmisc(1).
|
## zsh hook called before the prompt is printed. See zshmisc(1).
|
||||||
|
|
||||||
# Write the last command if successful, using the history buffered by
|
|
||||||
# zshaddhistory().
|
|
||||||
if [[ $? == 0 && -n "$LASTHIST" && -n $HISTFILE ]] ; then
|
|
||||||
print -sr "${LASTHIST%%$'\n'}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# over-prompt tie in
|
# over-prompt tie in
|
||||||
if [[ ! -v OVER_PROMPT_DISABLED ]]; then
|
if [[ ! -v OVER_PROMPT_DISABLED ]]; then
|
||||||
__over_prompt_precmd || export OVER_PROMPT_DISABLED=1
|
__over_prompt_precmd || export OVER_PROMPT_DISABLED=1
|
||||||
|
@ -224,8 +153,8 @@ function preexec () {
|
||||||
|
|
||||||
# general settings
|
# general settings
|
||||||
setopt EXTENDED_GLOB
|
setopt EXTENDED_GLOB
|
||||||
unsetopt NO_CLOBBER # prevents cat < file > file but gets in the way
|
setopt NO_CLOBBER # prevents cat < file > file
|
||||||
unsetopt CORRECTALL # hell no
|
unsetopt CORRECTALL # no
|
||||||
setopt NO_BEEP # hell no
|
setopt NO_BEEP # hell no
|
||||||
unsetopt equals # allows me to use strings like =this without escaping
|
unsetopt equals # allows me to use strings like =this without escaping
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue