bin: script adjustments on debian

This commit is contained in:
xeruf 2022-07-18 11:56:48 +01:00
parent 256df9cf71
commit e86bd6e2b6
7 changed files with 18 additions and 14 deletions

View File

@ -186,7 +186,7 @@ alias jcj='jce -o json-pretty --unit' # JSON View
# Shorthands
alias v='edit'
alias st='synct'
alias ex='dtrx'
which dtrx >/dev/null && alias ex='dtrx'
alias expr='noglob expr'
alias get='noglob ='

View File

@ -1,7 +1,7 @@
#!/bin/bash
# [b]rowse - overview of given files or current directory
# depends: tput stat bat checkaccess(in my dotfiles)
# optdepends: timg, neovim (compressed files), pdftoppm (PDF), mtn (video), audiowaveform
# optdepends: timg, neovim (compressed files), pdftoppm (PDF), mtn (video), audiowaveform, imagemagick (images)
# args: files to inspect, any arg starting with dash is passed on to bat
#
# Supports:
@ -75,13 +75,11 @@ for arg; do
# https://ask.libreoffice.org/t/convert-to-command-line-parameter/840/4
echo Converting "$arg"
soffice --headless --convert-to png --outdir "$prefix" "$arg" >/dev/null
timg+=("${tmpfile%.*}.png")
continue;;
timg+=("${tmpfile%.*}.png");;
(*/x-xcf*)
echo Converting "$arg"
convert -flatten "$arg" png:"$tmpfile"
timg+=("$tmpfile")
continue;;
timg+=("$tmpfile");;
(*\ video/*)
suffix=_thumbs.jpg
mtn -i -t -W -r2 -D6 -b 0,6 -c $grid -w $(expr $(tput cols) '*' 20) \
@ -89,7 +87,8 @@ for arg; do
timg -W "$prefix/$(basename "${arg%.*}")$suffix"
;;
(*\ image/*)
timg+=("$arg"); continue;;
timg+=("$arg")
which identify && continue;;
(*\ inode/directory\;*)
ls+=("$arg")
test -L "$arg" || continue
@ -140,7 +139,7 @@ if test "$timg"; then
$(test $# -gt 1 &&
echo "-t0.2 --center $(test $# -lt 20 && echo "--title") --grid=$((grid < $# ? grid : $#))x2") \
"${timg[@]}" "${timga[@]}" 2>/dev/null || true
if $inspect || test $# -lt 10; then
if which identify && ( $inspect || test $# -lt 10 ); then
tput setaf 6
for img in "${timg[@]}"
do ident="$(identify -ping -precision 3 -format "%wx%h %b %m %[bit-depth]-bit %[colorspace]" "$img")"

View File

@ -1,3 +1,5 @@
#!/bin/sh
# [c]at the given files as prettified [j]son
cat "$@" | while read -r line; do echo -n "$line" | python3 -m json.tool; done | bat --language json --style numbers
# add echo in case file is missing newline at the end
{ cat "$@"; echo; } | while read -r line; do echo -n "$line" | python3 -m json.tool; done | bat --language json --style numbers

View File

@ -27,7 +27,9 @@ case $arg in
(*.7z|*.z01|*.zip|*.jar)
if which 7z >/dev/null
then 7z x $param "$fullpath"
else unzip "$fullpath" | rewrite
else which p7zip >/dev/null &&
p7zip --decompress $param "$fullpath" ||
unzip "$fullpath" | rewrite
fi;;
(*.gz) gunzip "$fullpath" ;;
(*.bz2) bunzip2 "$fullpath" ;;

View File

@ -14,8 +14,8 @@ do
continue
fi
$elevate find "$f" -maxdepth $(expr 1 \& "$f" = "/" \| 5 \& $# \> 0 \| 4) -type d -empty -name .stfolder -exec rm -div {} \;
$elevate find "$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 \( -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 &&

View File

@ -1,7 +1,7 @@
#!/bin/bash -e
# Use grep and sed to replace $1 with $2 recursively and print what is done
grep --null --recursive --files-with-matches \
--binary-files=without-match $(echo $DIRS_IGNORE | sed 's/-x/--exclude-dir/g') "$1" "${@:3}" |
--binary-files=without-match $(echo $DIRS_IGNORE | sed 's/-x/--exclude-dir/g') "${@:3}" -- "$1" |
xargs -0 sed -i "\%${1}%{
s||${2}|g
w /dev/stdout

View File

@ -34,6 +34,7 @@ export GOPATH="$XDG_STATE_HOME"/go
export CARGO_HOME="$XDG_DATA_HOME"/cargo
export RUSTUP_HOME="$XDG_DATA_HOME"/rustup
export NVM_DIR="$XDG_DATA_HOME"/nvm
export KREW_ROOT="$XDG_DATA_HOME"/krew
export CABAL_CONFIG="$XDG_CONFIG_HOME"/cabal/config
export CABAL_DIR="$XDG_CACHE_HOME"/cabal
@ -65,7 +66,7 @@ mkdir -p "$XDG_STATE_HOME/zsh"
# environment
BIN="$HOME/.local/bin"
export PATH="$BIN/scripts:$BIN:$PATH:$XDG_CONFIG_HOME/emacs/bin:$GOPATH/bin:$XDG_DATA_HOME/gem/ruby/3.0.0/bin:$ANDROID_SDK_ROOT/platform-tools:$CARGO_HOME/bin"
export PATH="$BIN/scripts:$BIN:$PATH:$XDG_CONFIG_HOME/emacs/bin:$GOPATH/bin:$XDG_DATA_HOME/gem/ruby/3.0.0/bin:$ANDROID_SDK_ROOT/platform-tools:$CARGO_HOME/bin:$KREW_ROOT/bin"
export ALTERNATE_EDITOR="$(
if which nvim >/dev/null
then echo nvim