diff --git a/system/mnt.nix b/system/mnt.nix index a9eac32..5bcbf19 100644 --- a/system/mnt.nix +++ b/system/mnt.nix @@ -22,6 +22,10 @@ lib.mkIf (config.networking.hostName != "komikan") { user = "1000"; mode = "0755"; }; + "/mnt/tmp".d = { + user = "1000"; + mode = "0755"; + }; }; fileSystems."/mnt/pool" = { device = "//komikan/pool"; diff --git a/user/bin/default.nix b/user/bin/default.nix index 6011f2c..90196ed 100644 --- a/user/bin/default.nix +++ b/user/bin/default.nix @@ -11,6 +11,7 @@ in { edit = []; auto-tmux = [tmux]; sm = []; + rem = [fzf]; } // lib.optionalAttrs config.u.has.graphical { bell = [pipewire libnotify]; diff --git a/user/bin/rem b/user/bin/rem new file mode 100755 index 0000000..991d8b1 --- /dev/null +++ b/user/bin/rem @@ -0,0 +1,35 @@ +#!/bin/sh +# things you should remember but dont + +REM="${XDG_DATA_HOME:=$HOME/.local/share}/rem.cmd" + +if ! [ -f "$REM" ]; then + echo "missing $REM" + exit 1 +fi + +cmd="$(cat $REM | fzf -e -q "$1" -1 -d "^" --with-nth="{1}" --accept-nth="{2..}")" +rest="$cmd" +final="" + +prompt() { + if [ -z "$2" ]; then + while [ -z "$output" ]; do + read -E -p "$1: " output + done + else + read -E -p "$1 ($2): " output + fi + printf "%s" "${output:-$2}" +} + +while case "$rest" in *\{\{*\}\}*) true;; *) false;; esac; do + prefix="${rest%%\{\{*}" + temp="${rest#*\{\{}" + cmd="${temp%%\}\}*}" + rest="${temp#*\}\}}" + final="$(printf "%s%s%s" "$final" "$prefix" "$(eval "$cmd")")" +done +final="$(printf "%s%s" "$final" "$rest")" + +printf "%s" "$final" diff --git a/user/config/bash/custom b/user/config/bash/custom index e348ba5..c36986e 100644 --- a/user/config/bash/custom +++ b/user/config/bash/custom @@ -51,7 +51,7 @@ if [[ "$TERM" != "linux" ]]; then # check if still in .bashrc if declare -F _bashrc_main > /dev/null; then return - elif [[ "$@" != @("starship_precmd"|""|"__fzf_history__"|"fzf-file-widget"|"history -a"|"__zoxide_hook") ]]; then + elif [[ "$@" != @("starship_precmd"|""|"__fzf_history__"|"fzf-file-widget"|"history -a"|"__zoxide_hook") && ! "$@" =~ _comp.* ]]; then printf "\e]0;%s | %s | %s\a" "$(dirs +0)$_set_title_suffix" "$@" "$(date +"%H:%M:%S")" fi } diff --git a/user/config/bash/func b/user/config/bash/func index 5b5e677..cff5a43 100644 --- a/user/config/bash/func +++ b/user/config/bash/func @@ -80,3 +80,18 @@ function venv() { done echo "not found" } + +function _comp_rem_binding() { + local tty="$(stty -g)" + stty sane + READLINE_LINE="$(rem "$_comp_rem_arg")" + READLINE_POINT=${#READLINE_LINE} + stty "$tty" +} +function _comp_rem() { + COMPREPLY="" + _comp_rem_arg="${COMP_WORDS[@]:1}" + bind -x '"\e[0n": _comp_rem_binding' + printf '\e[5n' > /dev/tty +} +complete -F _comp_rem rem diff --git a/user/share/default.nix b/user/share/default.nix index 262f4af..5ac413c 100644 --- a/user/share/default.nix +++ b/user/share/default.nix @@ -1,4 +1,4 @@ -{...}: { +{config, ...}: { imports = [ ./nsxiv-rifle.nix ]; @@ -14,4 +14,5 @@ force = true; }; xdg.dataFile."kwalletd".source = ./kwalletd; + xdg.dataFile."rem.cmd".source = config.u.lib.lnn "user/share/rem.cmd"; } diff --git a/user/share/rem.cmd b/user/share/rem.cmd new file mode 100644 index 0000000..bad5d43 --- /dev/null +++ b/user/share/rem.cmd @@ -0,0 +1,11 @@ +YUBIKEY: get ssh key from yubikey^ssh-keygen -K +YUBIKEY: enable pam u2f^mkdir -p ~/.config/Yubico && pamu2fcfg >> ~/.config/Yubico/u2f_keys +NIXOS: update nixos system^nixos-rebuild switch --flake ~/.local/nixos --show-trace --sudo +NIXOS: update home manager^home-manager switch --flake ~/.local/nixos --show-trace +NIXOS: list generations^nix-env --list-generations +NIXOS: delete old generations^nix-env --delete-generations +{{prompt "keep last n" "5"}} +SSH: access remote port at local port^ssh -L {{prompt "remote port"}}:localhost:{{prompt "local port"}} -T -N {{prompt "remote"}} +SSH: socks proxy^ssh -D {{prompt "port to use" "5555"}} -q -C -N -f {{prompt "remote"}} +SSH: mount with sshfs^sshfs {{prompt "remote host:/dir"}} {{prompt "target" "/mnt/tmp"}} -o uid={{id -u}} -o gid={{id -g}} +TOOL: ocr^maim -su | tesseract - - +MONITOR: disable auto sleep^xset s off -dpms