diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2025-12-26 11:55:21 -0500 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2025-12-26 11:55:21 -0500 |
| commit | e223ea0a045f1e086e0780f7c1778a94bce92ad6 (patch) | |
| tree | 39983b748e0c98e7a4c137ffffedea9c5df779d7 | |
| parent | 9cd1e4f16131c41f2b16637ced9fd184573a7102 (diff) | |
| download | dotfiles-e223ea0a045f1e086e0780f7c1778a94bce92ad6.tar.gz dotfiles-e223ea0a045f1e086e0780f7c1778a94bce92ad6.tar.xz | |
Some tweaks and updates to dotfiles
| -rw-r--r-- | ai/whisper.sh | 83 | ||||
| -rwxr-xr-x | compile/nvim.sh | 2 | ||||
| -rwxr-xr-x | distro/_ubuntu_arm64_box86.sh | 2 | ||||
| -rwxr-xr-x | distro/netbsd.sh | 5 | ||||
| -rwxr-xr-x | distro/ubuntu.sh | 2 | ||||
| -rw-r--r-- | dotfiles/tmx.sh | 55 | ||||
| -rwxr-xr-x | install.sh | 14 | ||||
| -rw-r--r-- | kshrc | 69 | ||||
| -rw-r--r-- | readme.md | 20 |
9 files changed, 82 insertions, 170 deletions
diff --git a/ai/whisper.sh b/ai/whisper.sh deleted file mode 100644 index 9c469c7..0000000 --- a/ai/whisper.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh -# Install whisper on Fedora targeting ROCm devices under its own user account. -set -e -un=whisper - -printR() { - printf '\033[1;31m%s\033[0m\n' "$@" -} - -setupNote() { - printR "The user $un was created for whisper" - printR "To switch to that user and run whsiper commands run:" - printR "sudo su - $un" -} - -if [ "$(id -un)" != "$un" ] ; then - if [ "$(id -un)" != "root" ] ; then - echo "Re run this as root/with sudo to create the user" - exit 1 - fi - - set -x - if ! grep '^'"$un" /etc/passwd ; then - sudo adduser "$un" - fi - for group in video render ; do - sudo gpasswd -a "$un" "$group" - done - set +x - - cp "$0" /home/"$un"/whisper.sh - su - "$un" /home/"$un"/whisper.sh - - trap setupNote EXIT - - exit 0; -fi - -set -ex -miniconda=1 -miniconda_sha256='b978856ec3c826eb495b60e3fffe621f670c101150ebcbdeede4f961f22dc438' -rocm_version="5.7" # rpm -qa | grep -i rocm # or so - -if [ -d ~/miniconda3 ] ; then miniconda=0 ; fi - -if [ $miniconda -eq 1 ] ; then -miniconda_out=/tmp/miniconda3.sh -trap "rm -f \"$miniconda_out\"" EXIT INT - -wget -O "$miniconda_out" \ - https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh - -if ! sha256sum "$miniconda_out" | grep -q "$miniconda_sha256" ; then - echo "Bad checksum for miniconda installer, perhaps a network issue or out of date checksum?" - exit 1 -fi - -bash "$miniconda_out" -b -u -p ~/miniconda3 -~/miniconda3/bin/conda init bash -fi - -set +ex -. ~/.bashrc -set -ex - -if ! conda env list | grep -q '^whisper' ; then - conda create -y --name whisper python=3.9 -fi - -conda activate whisper -# https://rocm.docs.amd.com/projects/install-on-linux/en/latest/how-to/3rd-party/pytorch-install.html -conda install -y pytorch==2.0.0 torchaudio==2.0.0 -c pytorch -pip install -U openai-whisper -pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm${rocm_version}/ -pip install --upgrade --no-deps --force-reinstall git+https://github.com/openai/whisper.git - -if ! grep '^conda activate whisper' ~/.bashrc ; then - echo conda activate whisper >> ~/.bashrc -fi - -if ! grep '^export HIP_VISIBLE_DEVICES=0' ~/.bashrc ; then - echo 'export HIP_VISIBLE_DEVICES=0' >> ~/.bashrc -fi diff --git a/compile/nvim.sh b/compile/nvim.sh index d5badf5..d24bac4 100755 --- a/compile/nvim.sh +++ b/compile/nvim.sh @@ -10,7 +10,7 @@ if ! [ -d "$nvimdir" ] ; then git clone https://github.com/neovim/neovim "$nvimdir" fi cd "$nvimdir" -# git clean -fdx . +git clean -fdx . rm -rf build || echo "" make CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=$HOME/.local" -j"$(nproc)" make install diff --git a/distro/_ubuntu_arm64_box86.sh b/distro/_ubuntu_arm64_box86.sh index 85f9bfa..d7633f9 100755 --- a/distro/_ubuntu_arm64_box86.sh +++ b/distro/_ubuntu_arm64_box86.sh @@ -3,7 +3,7 @@ set -ex # Automatically install box86/box64 on ARM64 SBCs # Largely based on: # https://github.com/ptitSeb/box86/blob/master/docs/COMPILE.md -codedir="$HOME/scm/pub" +codedir="${CODEDIR:-$HOME/scm/pub}" box86dir="$codedir/box86" box64dir="$codedir/box64" winedir="$HOME/wine" diff --git a/distro/netbsd.sh b/distro/netbsd.sh index 8abc573..31db68b 100755 --- a/distro/netbsd.sh +++ b/distro/netbsd.sh @@ -1,5 +1,6 @@ #!/bin/sh set -ex +codedir="${CODEDIR:-$HOME/scm}" if [ "$(id -u)" -eq 0 ] ; then @@ -46,8 +47,8 @@ cd "$HOME" for pkg in dwm st dmenu ; do - mkdir -p scm/x/$pkg - cd scm/x/$pkg + mkdir -p "$codedir"/$pkg + cd "$codedir"/$pkg ! [ -d .git ] && git clone -b netbsd https://git.riedstra.dev/x/$pkg . make diff --git a/distro/ubuntu.sh b/distro/ubuntu.sh index a5c3fdd..04910ca 100755 --- a/distro/ubuntu.sh +++ b/distro/ubuntu.sh @@ -4,7 +4,7 @@ if [ "$(id -u)" -eq 0 ] ; then exit 1 fi set -ex -codedir="$HOME/scm/pub" +codedir="${CODEDIR:-HOME/scm/pub}" nvimdir="${codedir}/neovim-nvim" okshdir="${codedir}/ibara-oksh" NVIM="${NVIM:-yes}" diff --git a/dotfiles/tmx.sh b/dotfiles/tmx.sh deleted file mode 100644 index 0d66c27..0000000 --- a/dotfiles/tmx.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh - -# Modified further by Mitchell Riedstra to be compatible with /bin/sh - -# -# Modified TMUX start script from: -# http://forums.gentoo.org/viewtopic-t-836006-start-0.html -# -# Store it to `~/bin/tmx` and issue `chmod +x`. -# - -# Works because bash automatically trims by assigning to variables and by -# passing arguments -trim() { echo $1; } - -if [ -z "$1" ]; then - echo "Specify session name as the first argument" - exit -fi - -# Only because I often issue `ls` to this script by accident -if [ "$1" == "ls" ]; then - tmux ls - exit -fi - -base_session="$1" -# This actually works without the trim() on all systems except OSX -tmux_nb=$(trim `tmux ls | grep "^$base_session" | wc -l`) -if [ "$tmux_nb" == "0" ]; then - echo "Launching tmux base session $base_session ..." - tmux new-session -s $base_session -else - # Make sure we are not already in a tmux session - if [ -z "$TMUX" ]; then - # Kill defunct sessions first - old_sessions=$(tmux ls 2>/dev/null | egrep "^[0-9]{14}.*[0-9]+\)$" | cut -f 1 -d:) - for old_session_id in $old_sessions; do - tmux kill-session -t $old_session_id - done - - echo "Launching copy of base session $base_session ..." - # Session is is date and time to prevent conflict - session_id=`date +%Y%m%d%H%M%S` - # Create a new session (without attaching it) and link to base session - # to share windows - tmux new-session -d -t $base_session -s $session_id - # Create a new window in that session - #tmux new-window - # Attach to the new session - tmux attach-session -t $session_id - # When we detach from it, kill the session - tmux kill-session -t $session_id - fi -fi @@ -1,5 +1,8 @@ #!/bin/sh set -e +confdir="${XDG_CONFIG_HOME:-$HOME/.config}" +bindir="${BINDIR:-$HOME/bin}" +USE_X_SCRIPTS="${USE_X_SCRIPTS:-NO}" setLink() { src="" @@ -33,28 +36,29 @@ for _f in dotfiles/* ; do setLink -s "$src" -d "$dest" done -_nvimdir="$HOME/.config/nvim" +_nvimdir="${confdir}/nvim" if ! [ -d "$_nvimdir" ] ; then mkdir "$_nvimdir" fi setLink -s "$(pwd)/dotfiles/nvim/init.lua" -d "$_nvimdir/init.lua" -_ghosttydir="$HOME/.config/ghostty" +_ghosttydir="${confdir}/ghostty" if ! [ -d "$_ghosttydir" ] ; then mkdir "$_ghosttydir" fi setLink -s "$(pwd)/dotfiles/ghostty/config" -d "$_ghosttydir/config" -if ! [ -d "$HOME/bin" ] ; then mkdir "$HOME/bin" ; fi +if ! [ -d "$bindir" ] ; then mkdir "$bindir" ; fi for _f in bin/* ; do src="$(pwd)/$_f" - dest="$HOME/bin/$(basename "$_f")" + dest="${bindir}/$(basename "$_f")" setLink -s "$src" -d "$dest" done if [ "$(uname)" != "Darwin" ] \ - && [ -n "$DISPLAY" ] && [ "$XDG_SESSION_TYPE" != "wayland" ] ; then + && [ -n "$DISPLAY" ] && [ "$XDG_SESSION_TYPE" != "wayland" ] \ + && [ "$USE_X_SCRIPTS" = "YES" ] ; then if ! [ -d "$HOME/x" ] ; then mkdir "$HOME/x" ; fi for _f in x/* ; do @@ -27,10 +27,6 @@ alias setxkbmap-list="man xkeyboard-config" #shellcheck disable=SC2139 [ -x "$(command -v python3)" ] && alias python="$(command -v python3) -q" -if [ "$(uname)" = "OpenBSD" ] ; then - ! [ -x "$(which seq 2>/dev/null)" ] && alias seq="echo \"use jot(1)\"" -fi - if [ "$(uname)" = "Linux" ] ; then alias bc='bc -q' fi @@ -77,6 +73,7 @@ xbps-remove pkg_add pkg_delete pkg +pkgin tlp tlp-stat zfs @@ -165,6 +162,10 @@ set_ksh_competion() { set -A complete_passenv -- \ $(showPasswordStore ~/.password-store) + #shellcheck disable=SC2046 + set -A complete_dpwenv -- \ + $(showPasswordStore ~/.password-store) + fi #shellcheck disable=SC2046 @@ -314,6 +315,10 @@ sshSetAskpass() { export SSH_ASKPASS_REQUIRE=force } +# checkSSHAgentForward is useful for if we're an active SSH connection and setup +# the `agent_conf` for it. this can be dropped into your ~/.kshrc.local on a +# remote server to allow your remote sessions to pick up on forwarded keys, +# useful for jump boxes, remote development and similar. checkSSHAgentForward() { if ! [ -d "$HOME"/.ssh ] ; then mkdir -p "$HOME"/.ssh @@ -331,15 +336,20 @@ checkSSHAgentForward() { fi } +# checkSSHAgent is my go-to agent setup, it's aggressive, non-standard and a +# little hacky, but way more reliable at setting up a persistent ssh-agent than +# doing something at login and hoping everything else inherits it +# usage is fairly straightforward, drop it into your `~/.kshrc.local` and +# let it do it's thing. #shellcheck disable=SC2120 checkSSHAgent() { if [ "$1" = "-k" ] ; then pkill -9 ssh-agent fi - # So OpenSSH 10.1 steps on my configuration, rather than passing in - # -T which doesn't exist on older SSH, simply move my configuration - # out of the way. + # So OpenSSH 10.1 steps on my old configuration, rather than passing in -T + # which doesn't exist on older SSH, simply move my configuration out of the + # way. if [ -f "$HOME/.ssh/agent" ] ; then rm "$HOME/.ssh/agent" fi @@ -360,11 +370,13 @@ checkSSHAgent() { fi } +# checkSSHAgentGPG sets up SSH to talk to GPG for its keys instead checkSSHAgentGPG() { #shellcheck disable=SC2155 export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" } +# calls pass and dumps the contents of the password into your environment passenv() { _f="$(mktemp)" pass "$@" > "$_f" @@ -373,6 +385,16 @@ passenv() { rm -f "$_f" } +# calls dpw ( https://git.riedstra.dev/mitch/dpw ) and dumps the contents of the +# password into your environment +dpwenv() { + _f="$(mktemp)" + dpw "$@" > "$_f" + #shellcheck disable=SC1090 + . "$_f" + rm -f "$_f" +} + # gensubids is useful for generating /etc/subuid and /etc/subgid # if you have say a 3rd user you want to add gensubids() { @@ -402,20 +424,31 @@ gensubids() { echo "$_un:$(( (_n*_step) + 1 )):$(( (_n*_step) + _step ))" } +# scangit is useful for checking which repositories you've modified scangit() { + verbose=false ref="origin/master" while [ $# -gt 0 ] ; do case $1 in + -v) verbose=true ; shift ;; -r) ref="$2"; shift ; shift ;; --) break ;; - *) echo "bad option '$1' usage: scangit [-r <ref>] -- <paths>" ; return ;; + *) echo "bad option '$1' usage: scangit [-v] [-r <ref>] -- <paths>" ; return ;; esac ; done find "$@" -iname '.git' -type d 2>/dev/null \ - | while read -r d ; do - cd "$(dirname "$d")" - git diff-index --quiet "$ref" 2>/dev/null \ - || echo "$(dirname "$d")" + | while read -r _d ; do + $verbose && echo "Checking... $(dirname "$_d") against ref \"$ref\"" + cd "$(dirname "$_d")" + if $verbose ; then + git diff-index --quiet "$ref" 2>/dev/null \ + || echo "Has changes" + else + git diff-index --quiet "$ref" 2>/dev/null \ + || echo "$(dirname "$_d")" + fi + cd - >/dev/null done } + gitdate() { date="" while [ $# -gt 0 ] ; do case $1 in @@ -455,17 +488,11 @@ gpgTmpDir() { setcolorterminal() { case $TERM in - xterm-kitty) - # Prevent xterm-kitty from being turned into xterm-256color - return; - ;; xterm*) export TERM=xterm-256color - # printf $'\033]0;'"$(hostname)"$'\007'; ;; screen*) export TERM=screen-256color - # printf $'\033k'"$(whoami)"$'\033\\'; ;; esac } @@ -509,8 +536,6 @@ path_preappend "$HOME/bin" PRELOAD="$HOME/${SHELL_CONFIG}.pre" LOCAL="$HOME/${SHELL_CONFIG}.local" -export PASSWORD_STORE_ENABLE_EXTENSIONS=true - # Don't put any variables below this, as they can't be overridden before the # functions if you do that @@ -566,12 +591,12 @@ elif [ -n "$BASH" ] ; then fi fi -if [ $COLOR -eq 1 ] ; then +setcolor() { colormanpages setcolorterminal setcoloraliases setlscolors -fi +} [ -d "$HOME/.local/bin" ] && path_preappend "$HOME/.local/bin" @@ -4,10 +4,30 @@ `./install.sh` For the basics. +Environment variables to change how `./install.sh` works: + + * `CODEDIR` defaults to `$HOME/scm` + * `BINDIR` defaults to `$HOME/bin` + +I may change them to match the XDG specs in the future. Annoyingly +there appears to be no official `XDG_BIN_DIR` or similar. + +### Compile scripts + +Inside of `./compile`, mostly for nvim and my shell (oksh, of which kshrc is +meant for, but it works fine on bash too). + ### Key remappings ( Linux specific ) `./remap/at-kbd.sh` +### Linux specific bin + +Some need to be compiled, do this by hand with the included `Makefile` if you'd +like. Useful utilities include `zzz`, `backlight`, and `blu` On Ubuntu and +Debian variants you may need to specify `WHEEL=root`. They're setuid, so they go +into `/sbin` without much option for you to change it. + ### Distro specific `sudo sh ./distro/<distro>.sh` |
