From 69ddc06b67c82da691d5a7633bbbcc0f481210a7 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Mon, 27 Jun 2022 13:03:11 +0200 Subject: [PATCH] bin: various usability improvements --- .config/shell/browse | 6 +++--- .config/topgrade.toml | 6 +++--- .local/bin/scripts/b | 2 +- .local/bin/scripts/edconf | 4 ++-- .local/bin/scripts/ex | 7 ++++--- .local/bin/scripts/ffmeta | 2 +- .local/bin/scripts/fmpc | 10 ++++++---- .local/bin/scripts/freq | 2 +- .local/bin/scripts/xdg-mime-file | 3 ++- README.org | 2 +- 10 files changed, 24 insertions(+), 20 deletions(-) diff --git a/.config/shell/browse b/.config/shell/browse index faa84c7..932f7d9 100644 --- a/.config/shell/browse +++ b/.config/shell/browse @@ -45,7 +45,7 @@ cd() { # pr -4 -l1 -W $COLUMNS -S" " command ls --sort=none --quote-name | head -12 | - xargs ls --sort=time --format=vertical --directory --literal --file-type --color=always --width $COLUMNS | + xargs ls --sort=time --format=vertical --directory --literal --classify --color=always --width $COLUMNS | head -3 code=$? && test $code -eq 141 || return $code fi @@ -53,7 +53,7 @@ cd() { # LOCATE {{{1 # TODO no double heading with bat -alias fselect='fzf -0 -1 --reverse --height=30% | while read f; do test -d "$f" && cd "$f" || { highlight "$f" && print -s "b \"$f\"" && b "$f"; }; done'; +alias fselect='fzf -0 -1 --reverse --height=40% | while read f; do test -d "$f" && cd "$f" || { highlight "$f" && print -s "b \"$f\"" && b "$f"; }; done'; loci() { locate --all --ignore-case --basename --existing "$@" | command grep --extended-regexp --ignore-case --color=always $(echo "$|${@:$#}" | sed 's/ /|/g') | @@ -94,7 +94,7 @@ d() { # If not select with fzf, using locate to find extra options target="$(if test -n "$query" && expr "$(echo "$query" | sed 's| \+\([^ ]\+\).*|\1|;q')" \> 20 \& \ - $(echo "$query" | sed 'N;s|/.* \([0-9]\)|> 10 * \1|;q' | sed 's| */.*||') >/dev/null #2>&1 + $(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"; locate-zox "$@" fi | zoxide-fzf)" diff --git a/.config/topgrade.toml b/.config/topgrade.toml index 62813e3..88a0427 100644 --- a/.config/topgrade.toml +++ b/.config/topgrade.toml @@ -2,7 +2,7 @@ #assume_yes = true # Disable specific steps - same options as the command line flag -disable = ["node", "nix", "emacs"] #, "pnpm", "config-update"] +disable = ["node", "nix", "emacs", "config_update"] # Ignore failures for these steps #ignore_failures = ["powershell"] @@ -17,7 +17,7 @@ no_retry = true #run_in_tmux = true # List of remote machines with Topgrade installed on them -#remote_topgrades = ["tiger"] +remote_topgrades = ["tiger"] # Arguments to pass SSH when upgrading remote systems #ssh_arguments = "-o ConnectTimeout=2" @@ -64,7 +64,7 @@ arguments = "--rebase --autostash" [linux] # Arguments to pass yay when updating packages -yay_arguments = "--nodiffmenu --ignore android-studio --ignore clion --ignore intellij-idea-ultimate-edition --ignore intellij-idea-ultimate-edition-jre --ignore webstorm" +yay_arguments = "--nodiffmenu --ignore android-studio --ignore clion --ignore intellij-idea-ultimate-edition --ignore intellij-idea-ultimate-edition-jre --ignore webstorm --ignore brave-bin" #trizen_arguments = "--devel" #enable_tlmgr = true #emerge_sync_flags = "-q" diff --git a/.local/bin/scripts/b b/.local/bin/scripts/b index b78926b..09d224d 100755 --- a/.local/bin/scripts/b +++ b/.local/bin/scripts/b @@ -183,7 +183,7 @@ if test "$ls" -o $# -le $(echo "$flags" | wc -w); then { timeout .6s sh -c " if which exa 2>/dev/null >&2 - then exa --color=always --long --group --classify --all --all --sort=changed --reverse $flags $(printf "'%s' " "${ls[@]:-.}") + then $elevate exa --color=always --long --group --classify --all --all --sort=changed --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[@]:-.}" diff --git a/.local/bin/scripts/edconf b/.local/bin/scripts/edconf index e187558..4464e58 100755 --- a/.local/bin/scripts/edconf +++ b/.local/bin/scripts/edconf @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -e # Find config files with fzf, preview and edit them # Common config files are automatically checked/reloaded alias dedup='awk '"'"'!a[$0]++'"'" @@ -32,6 +32,6 @@ case "$sel" in (/etc/caddy/*) sudoedit "$sel" && caddy validate --config /etc/caddy/Caddyfile && sudo systemctl reload-or-restart caddy;; (/etc/ssh/*) sudoedit "$sel" && sudo systemctl reload-or-restart sshd;; (/etc/network/interfaces*) sudoedit "$sel" && sudo service networking reload;; - (*) $(test -w "$sel" || echo sudo --preserve-env=ALTERNATE_EDITOR) $EDITOR "$sel";; + (*) $(test -w "$sel" || echo "sudo -E") edit "$sel";; esac echo "$sel" | cat - "$conf_cache" | head -20 >"$conf_tmp" && mv "$conf_tmp" "$conf_cache" diff --git a/.local/bin/scripts/ex b/.local/bin/scripts/ex index ed7a4b2..c646dc2 100755 --- a/.local/bin/scripts/ex +++ b/.local/bin/scripts/ex @@ -3,7 +3,7 @@ # adapted and improved from the commonly circulating version # detects whether unpacking into a subfolder is sensible # and shows progress indications for some operations -# optdepends: rewrite(part of my dotfiles) +# optdepends: rewrite(part of my dotfiles, for unzip line rewriting) for arg do case $arg in (-d) del=$(expr ${del:-0} + 1);; @@ -14,6 +14,7 @@ case $arg in name="$(basename "${fullpath%.*}")" namepart="$name.part" ( + # Create temporary subfolder if current folder contains stuff if test "$(ls -U | wc -l)" -gt 2; then mkdir -p "$namepart" cd "$namepart" @@ -39,9 +40,9 @@ case $arg in # If we created a temporary subfolder, check if it can be eliminated if test "$(basename "$PWD")" = "$namepart" then if test $# -lt 2 -a "$(ls -U | wc -l)" -lt 3 - then test "$(ls)" && mv -v * .. + then test "$(ls)" && mv -iv * .. cd .. && rm -d "$namepart" - else cd .. && mv -v "$namepart" "$name" + else cd .. && mv -iv "$namepart" "$name" fi fi case $del in diff --git a/.local/bin/scripts/ffmeta b/.local/bin/scripts/ffmeta index c6d5da5..673606c 100755 --- a/.local/bin/scripts/ffmeta +++ b/.local/bin/scripts/ffmeta @@ -7,5 +7,5 @@ then cat else printf '%s\n' "$@" fi | while read f; do highlight "$f" - find "$f" -type f -exec ffprobe -loglevel warning -print_format default=noprint_wrappers=1 -show_format -pretty {} \; + find "$f" -type f -exec ffprobe -loglevel 20 -print_format default=noprint_wrappers=1 -show_format -pretty {} \; done | less diff --git a/.local/bin/scripts/fmpc b/.local/bin/scripts/fmpc index 105f6f7..9ee6fcf 100755 --- a/.local/bin/scripts/fmpc +++ b/.local/bin/scripts/fmpc @@ -1,6 +1,8 @@ -#!/bin/sh +#!/bin/sh -e # Select a song in the mpd queue using fzf and mpc -song_position=$(mpc -f "%position%) %artist% - %title%" playlist | \ - fzf-tmux --query="$1" --reverse --select-1 --exit-0 | \ - sed -n 's/^\([0-9]\+\)).*/\1/p') || return 1 +# depends: fzy/fzf-tmux mpc +song_position=$(mpc -f "%position%) %artist% - %title%" playlist | + #fzy --query="$1" | + fzf-tmux --query="$1" --reverse --select-1 --exit-0 | + sed -n 's/^\([0-9]\+\)).*/\1/p') test -n "$song_position" && mpc play $song_position diff --git a/.local/bin/scripts/freq b/.local/bin/scripts/freq index 03b2d94..540c70d 100755 --- a/.local/bin/scripts/freq +++ b/.local/bin/scripts/freq @@ -15,7 +15,7 @@ case $1 in $0 "$diff" ;; (*) - out="${2:-/tmp/freq-$(basename "$1").png}" + out="${2:-/tmp/freq-$(basename "$1")}.png" mkdir -p "$(dirname "$out")" sox "$1" -n spectrogram -o "$out" timg --title "$out" diff --git a/.local/bin/scripts/xdg-mime-file b/.local/bin/scripts/xdg-mime-file index d9f2235..0803505 100755 --- a/.local/bin/scripts/xdg-mime-file +++ b/.local/bin/scripts/xdg-mime-file @@ -1,9 +1,10 @@ #!/bin/sh -e # Use xdg-mime with a file's mime type xdg-mime query default "$(xdg-mime query filetype "$1")" -test $# -gt 1 && +if test $# -gt 1; then desktop="$(find /usr/share/applications -name "*$2*" | fzf -0 -1)" && xdg-mime default "$desktop" "$(xdg-mime query filetype "$1")" && echo -n "Updated to: " && xdg-mime query default "$(xdg-mime query filetype "$1")" +fi # || echo "Cannot find application $2 in /usr/share/applications!" diff --git a/README.org b/README.org index 9dcf569..e74d08e 100644 --- a/README.org +++ b/README.org @@ -67,7 +67,7 @@ makepkg -si - video :: [[https://github.com/phw/peek][peek]] vlc obs-studio kdenlive - music management :: puddletag beets picard ffmpegthumbnailer sox : sudo npm install -g bpm -- music production :: lilypond lilypond-docs timidity++ chordpro-git musescore mixxx-beta-git +- music production :: lilypond lilypond-docs timidity++ chordpro-git musescore mixxx-beta-git soundfont-fluid - communication :: zulip-desktop-bin ferdi-bin - hacking :: etcher-bin - health :: stretchly-xeruf-git redshift acpilight light