Remove old scripts and add some git config options

This commit is contained in:
Thorsten Schubert 2024-02-24 11:51:11 +01:00
parent 67887a9ff9
commit 0950beacac
Signed by untrusted user: Thorsten Schubert
GPG key ID: F74F74BB63C458FD
11 changed files with 48 additions and 306 deletions
assorted/nixos/nix-install
core
git/.config/git
zsh/.config/zsh
.zshrc
functions
scripts/bin
assburn
build-tmux-static
radeon-profile
remote-open
screen-ocr
transfer
trash-put

View file

@ -7,6 +7,7 @@
b = branch -vv --sort=-committerdate
c = commit
ca = commit --amend --no-edit
cc = "!git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format='%(refname:short)' | fzf --multi | xargs -I{} git branch -D {}"
ch = cherry-pick
cin = commit -e -F -
cm = commit --amend -o
@ -36,6 +37,7 @@
mend = commit --all --amend --no-edit
out = log --oneline --decorate @{upstream}..
p = push
pr = fetch origin '+refs/pull/*/head:refs/remotes/origin/pr/*'
re = rebase
rebu = rebase -Xours
rec = rebase --continue
@ -106,6 +108,9 @@
[feature]
manyFiles = true
[fetch]
prune = true
[merge]
conflictStyle = zdiff3
defaultToUpstream = true

View file

@ -365,9 +365,7 @@ alias chown='command chown -c --preserve-root'
alias info='info --vi-keys'
alias l.='command ls -d .* --color=auto' 2>/dev/null
alias ll='command ls -l --color=auto' 2>/dev/null
alias ls='command ls --color=auto --show-control-chars --group-directories-first -AlhXF'
alias ls='command ls --color=auto --show-control-chars --group-directories-first --almost-all --human-readable --classify --dereference-command-line -lX'
alias sl='ls'
alias cp='command cp -a'
@ -382,6 +380,7 @@ alias iface="ip route get 8.8.8.8 | sed -n '1 s/.* dev \([^ ]*\).*/\1/p'"
alias ip='ip -color=auto'
alias kc='koji-check'
alias kdl='koji-arch'
alias kernel-trace='print l | sudo tee /proc/sysrq-trigger; journalctl -k -n100'
alias lg='lazygit'
alias ln='command ln -vi'
alias lsfonts="fc-list --format='%{family}\n' | sed 's/,.*//' | sort -u"

View file

@ -1,7 +1,7 @@
# vi: set ft=zsh ts=4 sw=4 sts=-1 sr noet si tw=0 fdm=manual:
local sess=main;
local sess=primary;
if (($# > 0)); then
sess=$1;
fi;
tmux new-session -A -s "${sess}"
tmux new-session -A -s "${sess}"

View file

@ -1,67 +0,0 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# shellcheck disable=2155,1090
# burn in English subtitle track and transcode to constant quality 8bit h264 yuv420p, Japanese audio
# shellcheck source=../../lib/common.sh
source "${0%/*}/../share/dotfiles/lib/common.sh" || exit 1
if ! _has_emit HandBrakeCLI; then
exit 1
fi
if (($# < 1)); then
set -- "$PWD"
fi
declare -a args=("$@")
declare workdir
if [[ -d ${args[-1]} ]]; then
workdir=$(readlink -f -- "${args[-1]}")
unset 'args[-1]'
else
_die "Not a valid directory: ${args[-1]}"
fi
numfiles() {
find "$1" -maxdepth 1 -type f -iname "*.mkv" -printf . | wc -c
}
assburn() {
local dir=$1
shift
# shellcheck disable=SC1004
find "$dir" -maxdepth 1 -type f -iname "*.mkv" \( -exec bash -c ' \
src="$1"; shift; args=("$@"); base="$(dirname "$src")/$(basename "$src" .mkv)"
systemd-run --quiet --user --collect --pty --nice=19 --property=CPUSchedulingPolicy=idle --property=IOSchedulingClass=idle \
taskset -c 1-$(($(nproc)-1)) \
HandBrakeCLI --input "$src" --encoder x264 --encoder-preset faster --encoder-tune animation \
--encoder-profile high --encoder-level 5.2 --quality 18 -vfr --turbo --optimize \
--audio-lang-list jpn --first-audio --aencoder copy --audio-copy-mask aac,ac3,eac3,truehd,dts,dtshd,mp3 \
--audio-fallback av_aac --ab 192 --normalize-mix --arate auto --native-language eng \
--subtitle-lang-list eng,und --first-subtitle --subtitle-burned \
--maxHeight 1080 --maxWidth 1920 \
"${args[@]}" \
--output "${base}.new.mp4" && command mv -vuf "${base}.new.mp4" "${base}.mp4"' \
shell {} "$@" \; -o -quit \) || exit 1
command ls --color=auto --show-control-chars --group-directories-first -AlhXF "$dir"
}
if (($(numfiles "$workdir") < 1)); then
_die "No files to process found."
fi
declare -a aopts
if [[ -v CH5 ]]; then
aopts=(--aencoder ac3 --mixdown 5point1 --ab 640)
else
aopts=(--mixdown stereo)
fi
assburn "$workdir" "${aopts[@]}" "${args[@]}"
# vi: set ft=sh ts=4 sw=0 sts=-1 sr noet nosi tw=0 fdm=manual:

View file

@ -1,114 +0,0 @@
#!/usr/bin/env bash
# shellcheck shell=bash
set -o errexit
MUSL_VERSION=1.2.3
LIBEVENT_VERSION=2.1.12
NCURSES_VERSION=6.4
TMUX_VERSION=3.3a
TARGETDIR=$1
if [[ ${TARGETDIR} == "" ]]; then
TARGETDIR="${PWD}/out"
fi
mkdir -p "${TARGETDIR}"
TASKS=$(($(nproc) + 1))
CC=("${TARGETDIR}/bin/musl-gcc" -static)
_CFLAGS=(-Os -ffunction-sections -fdata-sections)
if "${REALGCC:-gcc}" -v 2>&1 | grep -q -- --enable-default-pie; then
_CFLAGS+=(-no-pie)
fi
_LDFLAGS=("-Wl,--gc-sections" -flto)
_musl() {
if [[ ! -e musl-${MUSL_VERSION}.tar.gz ]]; then
curl -LO https://www.musl-libc.org/releases/musl-${MUSL_VERSION}.tar.gz
fi
tar zxf musl-${MUSL_VERSION}.tar.gz --skip-old-files
pushd .
cd musl-${MUSL_VERSION}
CFLAGS="${_CFLAGS[*]}" LDFLAGS="${_LDFLAGS[*]}" ./configure --prefix="${TARGETDIR}" --disable-shared
make -j $TASKS
make install
make clean
popd
}
_libevent() {
if [[ ! -e libevent-${LIBEVENT_VERSION}-stable.tar.gz ]]; then
curl -LO https://github.com/libevent/libevent/releases/download/release-${LIBEVENT_VERSION}-stable/libevent-${LIBEVENT_VERSION}-stable.tar.gz
fi
tar zxf libevent-${LIBEVENT_VERSION}-stable.tar.gz --skip-old-files
pushd .
cd libevent-${LIBEVENT_VERSION}-stable
_cflags=("${_CFLAGS[@]}" -flto)
CC="${CC[*]}" CFLAGS="${_cflags[*]}" LDFLAGS="${_LDFLAGS[*]}" ./configure --prefix="${TARGETDIR}" --disable-shared --disable-openssl
make -j $TASKS
make install
make clean
popd
}
_ncurses() {
if [[ ! -e ncurses-${NCURSES_VERSION}.tar.gz ]]; then
curl -LO https://ftp.gnu.org/pub/gnu/ncurses/ncurses-${NCURSES_VERSION}.tar.gz
fi
tar zxvf ncurses-${NCURSES_VERSION}.tar.gz --skip-old-files
pushd .
cd ncurses-${NCURSES_VERSION}
_cflags=("${_CFLAGS[@]}" -flto)
CC="${CC[*]}" CFLAGS="${_cflags[*]}" LDFLAGS="${_LDFLAGS[*]}" ./configure --prefix "$TARGETDIR" \
--with-default-terminfo-dir=/usr/share/terminfo \
--with-terminfo-dirs="/etc/terminfo:/lib/terminfo:/usr/share/terminfo" \
--enable-pc-files \
--with-pkg-config-libdir="${TARGETDIR}/lib/pkgconfig" \
--without-ada \
--without-debug \
--with-termlib \
--without-cxx \
--without-progs \
--without-manpages \
--disable-db-install \
--without-tests
make -j $TASKS
make install
make clean
popd
}
_tmux() {
if [[ ! -e tmux-${TMUX_VERSION}.tar.gz ]]; then
curl -LO https://github.com/tmux/tmux/releases/download/${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz
fi
tar zxf tmux-${TMUX_VERSION}.tar.gz --skip-old-files
pushd .
cd tmux-${TMUX_VERSION}
_cflags=("${_CFLAGS[@]}" -flto "-I${TARGETDIR}/include/ncurses/")
CC="${CC[*]}" CFLAGS="${_cflags[*]}" LDFLAGS="${_LDFLAGS[*]}" PKG_CONFIG_PATH="${TARGETDIR}/lib/pkgconfig" ./configure --enable-static --prefix="${TARGETDIR}"
make -j $TASKS
make install
make clean
popd
cp "${TARGETDIR}/bin/tmux" .
strip --strip-all ./tmux
if command -v upx &>/dev/null; then
upx -k --best ./tmux
fi
}
rm -rf "${TARGETDIR}/out"
if [[ ! -x "${TARGETDIR}/bin/musl-gcc" ]]; then
_musl
fi
_libevent
_ncurses
_tmux
# vi: set ft=sh ts=4 sw=0 sts=-1 sr noet nosi tw=80 fdm=manual:

View file

@ -1,36 +0,0 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# shellcheck disable=2155,1090
set_profile() {
local -r fpl=/sys/class/drm/card0/device/power_dpm_force_performance_level
local -r ppm=/sys/class/drm/card0/device/pp_power_profile_mode
if [[ ! -f $fpl ]]; then
return 1
fi
local -r pp=$(
tail -n +2 <$ppm \
| fzf \
--no-sort \
--cycle \
--height=10 \
--layout=reverse-list \
--border=rounded \
--prompt='mode# ' \
--info=inline \
| awk '{print $1}'
)
if [[ -z $pp ]]; then
return 1
fi
if ((UID != 0)); then
local -r priv=1
fi
echo "manual" | ${priv:+sudo} tee "$fpl" >/dev/null
echo "$pp" | ${priv:+sudo} tee "$ppm" >/dev/null
grep -E "^[[:space:]]*${pp}" "$ppm"
}
set_profile
# vi: set ft=sh ts=4 sw=0 sts=-1 sr noet nosi tw=80 fdm=manual:

View file

@ -1,18 +0,0 @@
#!/bin/dash
read -r type target
if [ -z "${type}" ] || [ -z "${target}" ]; then
exit 1
fi
case "${type}" in
URL) xdg-open "${target}" ;;
VIDEO) setsid -f mpv --quiet --msg-level=ffmpeg=fatal --ytdl-format='bestvideo[fps<=60][height<=1080][vcodec=avc1]/mp4' "${target}" 1>/dev/null 2>&1 0</dev/null ;;
AUDIO) setsid -f mpv --quiet --msg-level=ffmpeg=fatal --profile=low-latency --no-video --cache=auto --demuxer-max-back-bytes=2097152 --demuxer-max-bytes=2097152 --ytdl-format='bestaudio[ext=webm]/bestaudio[ext=m4a]/bestaudio' "${target}" 1>/dev/null 2>&1 0</dev/null ;;
*)
printf '%s\n' 'Unsupported format.'
exit 2
;;
esac
# vi: set ft=sh ts=4 sw=0 sts=-1 sr noet nosi tw=80 fdm=manual:

View file

@ -0,0 +1,39 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# Dependencies: tesseract-ocr imagemagick
# on gnome: gnome-screenshot
# on kde: spectacle
# on x11: xsel
# on wayland: wl-clipboard
die() {
notify-send "$1"
exit 1
}
cleanup() {
[[ -n $1 ]] && command rm -r "$1"
}
scr_img=$(mktemp -d) || die "failed to take screenshot"
# shellcheck disable=SC2064
trap "cleanup '$scr_img'" EXIT
if command -v spectacle &>/dev/null; then
spectacle -b -r -o "$scr_img/scr.png" || die "failed to take screenshot"
else
gnome-screenshot -a -f "$scr_img/scr.png" || die "failed to take screenshot"
fi
# increase image quality with option -q from default 75 to 100
# which should increase detection rate
mogrify -modulate 100,0 -resize 400% "$scr_img/scr.png" || die "failed to convert image"
tesseract "$scr_img/scr.png" "$scr_img/scr" &>/dev/null || die "failed to extract text"
if [[ $XDG_SESSION_TYPE == wayland ]]; then
wl-copy <"$scr_img/scr.txt" || die "failed to copy text to clipboard"
else
xsel -b -i <"$scr_img/scr.txt" || die "failed to copy text to clipboard"
fi
notify-send "Text extracted"

View file

@ -1,51 +0,0 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# shellcheck source=../../lib/common.sh
source "${0%/*}/../share/dotfiles/lib/common.sh" || exit 1
urlencode() {
if _has jq; then
printf '%s' "$(jq -sRr @uri < <(printf "%s" "$1"))"
else
local length=${#1}
for ((i = 0; i < length; i++)); do
local c=${1:i:1}
case $c in
[a-zA-Z0-9.~_-]) printf '%s' "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
fi
}
transfer() {
if (($# < 1)); then
_die 'No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>\n'
fi
local fname
if tty -s; then
file=$1
fname=$(urlencode "$(basename "$file")")
if [[ ! -e $file ]]; then
_die "${file}: No such file or directory"
fi
if [[ -d $file ]]; then
fname=${fname}.zip
(cd "$file" && zip -r -q - .) | curl --include --progress-bar --upload-file "-" "https://file.unsha.re/${fname}"
else
curl --include --progress-bar --upload-file "-" "https://file.unsha.re/${fname}" <"$file"
fi
else
fname=$(urlencode "$1")
curl --include --progress-bar --upload-file "-" "https://file.unsha.re/${fname}"
fi
_msg ''
}
transfer "$@"
# vi: set ft=sh ts=4 sw=0 sts=-1 sr noet nosi tw=80 fdm=manual:

View file

@ -1,15 +0,0 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# shellcheck source=../../lib/common.sh
source "${0%/*}/../share/dotfiles/lib/common.sh" || exit 1
if (($# < 1)); then
_die "Need a path"
fi
if ! [[ -e $1 ]]; then
_die "Not a valid path"
fi
command gio trash -- "$1" || command rm -rf "$1"