config/shell: various tweaks
This commit is contained in:
parent
634b39ed9c
commit
b7227a1ab5
|
@ -7,43 +7,43 @@ cdd() { cd "$@" 2>/dev/null || cd "$(dirname "$1")" "${@:2}" }
|
|||
|
||||
# Go up a number of dirs
|
||||
up() {
|
||||
if [[ $# < 1 ]] ; then
|
||||
cd ..
|
||||
else
|
||||
CDSTR=""
|
||||
for i in {1..$1} ; do
|
||||
CDSTR="../$CDSTR"
|
||||
done
|
||||
cd $CDSTR
|
||||
fi
|
||||
if [[ $# < 1 ]] ; then
|
||||
cd ..
|
||||
else
|
||||
CDSTR=""
|
||||
for i in {1..$1} ; do
|
||||
CDSTR="../$CDSTR"
|
||||
done
|
||||
cd $CDSTR
|
||||
fi
|
||||
}
|
||||
|
||||
# Switch directory & ls
|
||||
cl() {
|
||||
builtin cd $1
|
||||
ls --almost-all --group-directories-first --file-type
|
||||
builtin cd $1
|
||||
ls --almost-all --group-directories-first --file-type
|
||||
}
|
||||
|
||||
# cd but search for data dirs and ls in new dir
|
||||
cd() {
|
||||
if test -d "$DATA" && test "${1:--}" != "-" -a ! -d "$1" -a $# -eq 1
|
||||
then
|
||||
dir=$(fd --no-ignore --glob "$1*" "$DATA" --maxdepth 2 --type d --max-results 1)
|
||||
test -n "$dir" && cd "$dir"
|
||||
else
|
||||
builtin cd $1 &&
|
||||
command ls --literal --file-type --color=always --format=vertical -U -w $COLUMNS |
|
||||
#pr -4 -l1 -W $COLUMNS -S" " |
|
||||
head -3
|
||||
code=$? && test $code -eq 141 || return $code
|
||||
fi
|
||||
if test -d "$DATA" && test "${1:--}" != "-" -a ! -d "$1" -a $# -eq 1
|
||||
then
|
||||
dir=$(fd --no-ignore --glob "$1*" "$DATA" --maxdepth 2 --type d --max-results 1)
|
||||
test -n "$dir" && cd "$dir"
|
||||
else
|
||||
builtin cd "$1" &&
|
||||
command ls --literal --file-type --color=always --format=vertical -U -w $COLUMNS |
|
||||
#pr -4 -l1 -W $COLUMNS -S" " |
|
||||
head -3
|
||||
code=$? && test $code -eq 141 || return $code
|
||||
fi
|
||||
}
|
||||
|
||||
# LOCATE
|
||||
alias fselect='fzf -0 -1 --reverse --height=30% | while read f; do test -d "$f" && cd "$f" || b "$f"; done'
|
||||
loci() {
|
||||
locate --all --ignore-case --basename --existing "$@" |
|
||||
command grep --extended-regexp --ignore-case --color=always $(echo "$|${@:$#}" | sed 's/ /|/g') | fselect
|
||||
locate --all --ignore-case --basename --existing "$@" |
|
||||
command grep --extended-regexp --ignore-case --color=always $(echo "$|${@:$#}" | sed 's/ /|/g') | fselect
|
||||
}
|
||||
alias loc='noglob loci'
|
||||
alias uloc='noglob sudo updatedb && loci'
|
||||
|
@ -56,17 +56,19 @@ alias loca='noglob sudo updatedb --prunenames "" -o /var/lib/mlocate/all.db && l
|
|||
# ZOXIDE
|
||||
alias c=z
|
||||
d() {
|
||||
test "$1" != "-" -a ! -d "$1" -a $# -eq 1 || { cd "$@" && return }
|
||||
local query="$(zf "$@")"
|
||||
# First find out whether there is an obvious match
|
||||
# (score at least ten times above runner-up and score above 20)
|
||||
# If not select with fzf, using locate to find extra options
|
||||
cd "$(if test -n "$query" && expr "$(echo "$query" | head -1 | cut -d' ' -f1)" \> 20 \& $(echo "$query" | sed 'N;s|/.* \([0-9]\)|> 10 * \1|;q' | sed 's| */.*||') >/dev/null #2>&1
|
||||
then echo "$query" | head -1
|
||||
else test -n "$query" && echo "$query"; locz "$@"
|
||||
fi | zfz)"
|
||||
test "$1" != "-" -a ! -d "$1" -a $# -eq 1 || { cd "$@" && return }
|
||||
local query="$(zf "$@")"
|
||||
# First find out whether there is an obvious match
|
||||
# (score at least ten times above runner-up and score above 20)
|
||||
# If not select with fzf, using locate to find extra options
|
||||
cd "$(if test -n "$query" &&
|
||||
expr "$(echo "$query" | head -1 | cut -d' ' -f1)" \> 20 \& \
|
||||
$(echo "$query" | sed 'N;s|/.* \([0-9]\)|> 10 * \1|;q' | sed 's| */.*||') >/dev/null #2>&1
|
||||
then echo "$query" | head -1
|
||||
else test -n "$query" && echo "$query"; locz "$@"
|
||||
fi | zfz)"
|
||||
}
|
||||
di() {
|
||||
test "$1" = "-" || local dir=$({ zf "$@"; locz "$@" } | zfz)
|
||||
cd "${dir:-$1}"
|
||||
test "$1" = "-" || local dir=$({ zf "$@"; locz "$@" } | zfz)
|
||||
cd "${dir:-$1}"
|
||||
}
|
||||
|
|
|
@ -26,17 +26,12 @@ which lsb_release >/dev/null && export DIST=$(lsb_release --id | cut -d' ' -f2)
|
|||
|
||||
unalias rd 2>/dev/null
|
||||
|
||||
# System helpers {{{1
|
||||
# System help {{{1
|
||||
|
||||
alias h='help'
|
||||
compdef help=man
|
||||
alias info='info --vi-keys'
|
||||
|
||||
alias v=edit
|
||||
|
||||
alias println='printf "\n"'
|
||||
alias dedup='awk '"'"'!a[$0]++'"'"
|
||||
|
||||
# Shows source code for command, resolving nested aliases
|
||||
wh() {
|
||||
res=$(which "$@")
|
||||
|
@ -157,16 +152,21 @@ alias jcj='jcl -o json-pretty -u'
|
|||
|
||||
# Applications {{{1
|
||||
|
||||
alias u='topgrade'
|
||||
# Shorthands
|
||||
alias v='edit'
|
||||
alias u='topgrade --only emacs --yes; topgrade --disable emacs'
|
||||
alias st='synct'
|
||||
alias expr='noglob expr'
|
||||
|
||||
alias lst='( last; last -f /var/log/wtmp.1 ) | grep -v "pts/" | tac | less +G'
|
||||
alias lar='last | tac'
|
||||
|
||||
alias calc='rlwrap -a bc -l'
|
||||
# Shortcuts
|
||||
alias logoff="loginctl terminate-user $USER"
|
||||
blues() { bluedevil-sendfile $(echo "$@" | xargs -n 1 realpath | xargs -n 1 echo -n " --files") }
|
||||
alias calc='rlwrap -a bc -l'
|
||||
|
||||
# Process
|
||||
alias println='printf "\n"'
|
||||
alias dedup='awk '"'"'!a[$0]++'"'"
|
||||
alias lar='last | tac'
|
||||
alias lst='( last; last -f /var/log/wtmp.1 ) | grep -v "pts/" | tac | less +G'
|
||||
|
||||
# Remote
|
||||
alias delta="sc restart openvpn-client@deltaPeak.service"
|
||||
|
@ -318,7 +318,7 @@ mvln() {
|
|||
# Move into an xdg dir (default XDG_DATA_HOME) and create a symlink
|
||||
mvx() {
|
||||
mvln "$1" "${2:-$XDG_DATA_HOME}/${1#.}"
|
||||
yadm add "$1" ".config/$1"
|
||||
yadm add "$1" ".config/$1" 2>/dev/null
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
# Send given files via bluetooth
|
||||
bluedevil-sendfile $(echo "$@" | xargs -n 1 realpath | xargs -n 1 echo -n " --files")
|
|
@ -9,7 +9,7 @@ case $1 in
|
|||
info --vi-keys $(test $last != zsh && echo --index-search=$last) zsh || LESS="$LESS +/^ *$last *\\[" man zshall;;
|
||||
(vlc) unbuffer vlc --full-help "${@:2}" | $paginate;;
|
||||
(gh|chordpro) $@ --help | $paginate;;
|
||||
(caddy) $1 help ${@:2} | $paginate;;
|
||||
(caddy|stretchly) $1 help ${@:2} | $paginate;;
|
||||
(*) man "$@" || { info "$1" -w | grep -v "manpages" && pinfo "$@"; } || { "$@" --help || "$@" -help; } 2>&1 | ${PAGER:-less} || which "$@";;
|
||||
esac
|
||||
docs="/usr/share/doc/$1"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
# Install pre-commit, ignoring globally set core.hooksPath
|
||||
git config --unset core.hooksPath
|
||||
git config --unset-all core.hooksPath
|
||||
GIT_CONFIG_GLOBAL=/dev/null pre-commit install
|
||||
GIT_CONFIG_GLOBAL=/dev/null pre-commit install -t pre-push
|
||||
git config --add core.hooksPath .git/hooks
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh -e
|
||||
# Move roam files into subfolders
|
||||
cd $DATA/2-standards/notes
|
||||
cd $DATA/2-standards/box
|
||||
find . -mindepth 1 -type d -printf '%f\n' |
|
||||
while read dir; do
|
||||
grep -l --directories=skip "#+filetags: :$dir" * |
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#!/bin/sh
|
||||
while true
|
||||
do case $1 in
|
||||
(-o) out=$2; shift 2;;
|
||||
(-q) quality=$2; shift 2;;
|
||||
(-o) out="$2"; shift 2;;
|
||||
(-q) quality="$2"; shift 2;;
|
||||
(*) break;;
|
||||
esac
|
||||
done
|
||||
magick '$@' -strip -interlace Plane -define jpeg:dct-method=float -sampling-factor 4:2:0 -gaussian-blur 0.05 -quality "${quality:-85}" "$out"
|
||||
test $# -eq 0 && echo "Usage: $0 [-q quality (default 85)] [-o outfile] <images...>" && exit 1
|
||||
magick "$@" -strip -interlace Plane -define jpeg:dct-method=float -sampling-factor 4:2:0 -gaussian-blur 0.05 -quality "${quality:-85}" "$out"
|
||||
|
||||
|
|
Loading…
Reference in New Issue