bin: various fixes
This commit is contained in:
parent
3b01d60544
commit
7fad5c8fbe
|
@ -91,7 +91,7 @@ for arg; do
|
|||
(*\ video/*)
|
||||
suffix=_thumbs.jpg
|
||||
mtn -q -i -t -W -r2 -D6 -b 0,6 -c $grid -w $(expr $(tput cols) '*' 20) \
|
||||
-O "$prefix" -o "$suffix" "$arg"
|
||||
-O "$prefix" -o "$suffix" "$arg" &&
|
||||
timg -W "$prefix/$(basename "${arg%.*}")$suffix"
|
||||
;;
|
||||
(*\ image/*)
|
||||
|
@ -134,7 +134,7 @@ for arg; do
|
|||
fi
|
||||
esac
|
||||
;;
|
||||
(*:\ *database*) highlight "Tables" && sqlite3 "$arg" ".tables";;
|
||||
(*:\ SQLite\ *\ database*) highlight "Tables" && sqlite3 "$arg" ".tables";;
|
||||
(*:\ data) ;;
|
||||
(*) bat+=("$arg")
|
||||
timga+=("$arg")
|
||||
|
@ -175,6 +175,7 @@ pager="${PAGER:-'less -RF'}"
|
|||
# bat: unknown files
|
||||
# batplain: files to print without header
|
||||
if test "$bat" -o "$batplain"; then
|
||||
# TODO allow plain less
|
||||
test "$(bat --version | cut -d. -f2)" -gt 16 && rule=,rule
|
||||
if test $# -gt ${#bat[@]} -a $# -gt ${#batplain[@]} && test -z "$flags"
|
||||
then cut="--line-range :7"
|
||||
|
@ -214,7 +215,7 @@ if test "$bat" -o "$batplain"; then
|
|||
else $batcommand "${batpager:-$pager}" $batstyle,header$(test $# -gt 1 && echo ",numbers") "${bat[@]}"
|
||||
fi
|
||||
fi
|
||||
if $inspect || test $# -lt $(expr $(tput lines) / 3);
|
||||
if $inspect || test $# -lt $(expr $(tput lines) / 10);
|
||||
then fileinfo "${bat[@]}"
|
||||
fi
|
||||
fi
|
||||
|
@ -230,7 +231,7 @@ if test "$ls" -o $# -le $(echo "$flags" | wc -w); then
|
|||
if test '$tree'
|
||||
then $elevate tree -a --dirsfirst --du -h -C -L 3 $flags $(printf "'%s' " "${ls[@]:-.}")
|
||||
elif which exa 2>/dev/null >&2
|
||||
then $elevate exa --icons --color=always --long --group --classify --all --all --sort=changed --reverse $flags $(printf "'%s' " "${ls[@]:-.}")
|
||||
then $elevate exa --icons --color=always --long --group --classify --all --all --sort=modified --reverse $flags $(printf "'%s' " "${ls[@]:-.}")
|
||||
else $elevate ls -l $(test $# -gt ${#ls[@]} && echo '-d') --color=always --human-readable --si --group-directories-first --file-type --dereference-command-line-symlink-to-dir --all $flags $(printf "'%s' " "${ls[@]:-.}")
|
||||
fi
|
||||
" || $elevate ls $(test $# -gt ${#ls[@]} && echo "-d") --color=always --human-readable --si --dereference-command-line --all --sort=none $flags "${ls[@]:-.}"
|
||||
|
|
|
@ -78,7 +78,7 @@ highlight "c :: clean electron caches"
|
|||
|
||||
highlight "o :: optimize space extensively"
|
||||
if [[ $1 =~ "o" ]]; then
|
||||
sudo find $XDG_CACHE_HOME /var/cache /var/log /var/tmp -maxdepth 2 -atime +2 -exec rm -r {} +
|
||||
sudo find $XDG_CACHE_HOME /var/cache /var/log /var/tmp -mindepth 1 -maxdepth 2 -atime +2 -exec rm -r {} + -prune
|
||||
|
||||
if test -f "/var/log/apt/history.log"; then
|
||||
aptclean_cur=$(cat "/var/log/apt/history.log" | wc -l)
|
||||
|
@ -90,9 +90,10 @@ if [[ $1 =~ "o" ]]; then
|
|||
|
||||
sudo rm -rf "$XDG_DATA_HOME/baloo"
|
||||
docker image prune
|
||||
which yay &>/dev/null && yay -Sc --noconfirm
|
||||
nix-collect-garbage -d
|
||||
nix-store --optimize
|
||||
which yay &>/dev/null &&
|
||||
yay -Sc --noconfirm
|
||||
nix-collect-garbage -d 2>/dev/null &&
|
||||
nix-store --optimize
|
||||
fi
|
||||
|
||||
df --output="source,avail" -h $(test -n "$local" && echo ".") "$dir"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
# Emacs in the terminal
|
||||
pgrep --full "emacs --daemon" >/dev/null || emacs --daemon
|
||||
pgrep --full "emacs .*-daemon" >/dev/null || emacs --daemon
|
||||
emacsclient --create-frame --tty "$@"
|
||||
exit=$?
|
||||
stty sane
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#!/bin/sh
|
||||
# Grep through all manuals
|
||||
find /usr/share/man -name "*$1*" | xargs gunzip -c | grep $2 --color=auto
|
||||
manual=$1
|
||||
shift
|
||||
find /usr/share/man -name "*$manual*" | xargs gunzip -c | grep "$@" --color=auto
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
# optdepends: highlight(dotfiles)
|
||||
# TODO show tldr page
|
||||
paginate="${PAGER:-less} +Gg"
|
||||
test "$1" = "-d" && browse=1 && shift
|
||||
case "$1" in
|
||||
(-d) browse=1; shift;;
|
||||
(-v) set -o xtrace; shift;;
|
||||
esac
|
||||
|
||||
showinfo() {
|
||||
which info >/dev/null 2>&1 &&
|
||||
|
@ -38,7 +41,8 @@ case "$cmd" in
|
|||
for last; do true; done
|
||||
# need to install zsh-doc package for info pages
|
||||
showinfo zsh $(test "$last" != zsh && echo "$last") ||
|
||||
LESS="$LESS +/^ *$last *\\[" man zshall;;
|
||||
LESS="$LESS$(test "$last" != zsh && echo "+/^ *$last *\\[")" man zshall;;
|
||||
(emacs) man emacs;;
|
||||
(*) showinfo "$@" || man "$@" || return=$?
|
||||
if test "${return:-0}" -gt 0 && which "$cmd" >/dev/null
|
||||
then { unbuffer "$@" --help || { test $? == 1 && "$@" -help; } || { test $? == 1 && "$@" -h; }; } 2>&1 | $paginate
|
||||
|
@ -47,18 +51,19 @@ case "$cmd" in
|
|||
esac
|
||||
docs="/usr/share/doc/$cmd"
|
||||
if test -d "$docs"; then
|
||||
len() { echo "$1" | wc -c; }
|
||||
shortest() {
|
||||
read shortest
|
||||
while read in
|
||||
do test $(len $shortest) -gt $(len $in) && shortest=$in
|
||||
done
|
||||
echo $shortest
|
||||
}
|
||||
file="$(find $docs -name index.html | shortest | grep . || find $docs -name $1*.html | shortest)"
|
||||
|
||||
if test -z "$browse"
|
||||
then echo "Find more in $docs"
|
||||
else
|
||||
len() { echo "$1" | wc -c; }
|
||||
shortest() {
|
||||
read shortest
|
||||
while read in
|
||||
do test $(len $shortest) -gt $(len $in) && shortest=$in
|
||||
done
|
||||
echo $shortest
|
||||
}
|
||||
firefox "file://$(find $docs -name index.html | shortest | grep . || find $docs -name $1*.html | shortest)"
|
||||
then echo "Find more in file://${file:-docs}"
|
||||
else firefox "file://$file"
|
||||
fi
|
||||
fi
|
||||
exit $return
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
# depends: xargs realpath mpc
|
||||
# env: MUSIC
|
||||
# TODO auto-convert unknown types with ffmpeg to flac rather than linking (wav, opus, ...)
|
||||
MUSIC="${MUSIC:-$(cat ${XDG_CONFIG_HOME:-$HOME/.config}/mpd/mpd.conf | grep music_directory | cut -d'"' -f2 | sed "s|~|$HOME|")}"
|
||||
PLAYLISTS="$MUSIC/Playlists"
|
||||
MPD_CONF=${XDG_CONFIG_HOME:-$HOME/.config}/mpd/mpd.conf
|
||||
MUSIC="${MUSIC:-$(cat $MPD_CONF | grep music_directory | cut -d'"' -f2 | sed "s|~|$HOME|")}"
|
||||
PLAYLISTS="${$(cat $MPD_CONF | grep playlist_directory | cut -d'"' -f2 | sed "s|~|$HOME|"):-$MUSIC/Playlists}"
|
||||
LINKS="$MUSIC/links"
|
||||
if test "$1" = "-r"
|
||||
then shift
|
||||
|
|
|
@ -14,8 +14,8 @@ do
|
|||
continue
|
||||
fi
|
||||
|
||||
$elevate find -H "$f" -maxdepth $(expr 1 \& "$f" = "/" \| 5 \& $# \> 0 \| 4) -type d -empty -name .stfolder -exec rm -div {} \;
|
||||
$elevate find -H "$f" -maxdepth $(expr 1 \& "$f" = "/" \| 5 \& $# \> 0 \| 3) -not -name .stfolder \( -type d -o -type f \) -a -empty -printf 'Removing empty %p\n' -delete
|
||||
# $elevate find -H "$f" -maxdepth $(expr 1 \& "$f" = "/" \| 5 \& $# \> 0 \| 4) -type d -empty -name .stfolder -exec rm -div {} \;
|
||||
$elevate find -H "$f" -maxdepth $(expr 1 \& "$f" = "/" \| 5 \& $# \> 0 \| 3) -not \( -name '.stfolder' -o -name '.*keep' \) \( -type d -o -type f \) -a -empty -printf 'Removing empty %p\n' -delete
|
||||
test $# -eq 0 && exit $?
|
||||
if test -e "$f"; then
|
||||
echo -n "$f ($(ls -A "$f" | head -3 | paste -s -d' ')) " >&2 &&
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh -e
|
||||
unbuffer swaymsg -t get_$1 | less -RF
|
Loading…
Reference in New Issue