diff --git a/user/config/bash/custom b/user/config/bash/custom index 9da3f0c..bb30329 100644 --- a/user/config/bash/custom +++ b/user/config/bash/custom @@ -24,7 +24,7 @@ _load history _load aliases # set xdg env vars to keep home directory clean _load xdg -_load show +_load func if _exists fzf; then export FZF_DEFAULT_OPTS="--bind=ctrl-u:page-up,ctrl-d:page-down" diff --git a/user/config/bash/show b/user/config/bash/func similarity index 71% rename from user/config/bash/show rename to user/config/bash/func index c0f4f76..0deac83 100644 --- a/user/config/bash/show +++ b/user/config/bash/func @@ -40,3 +40,21 @@ function rl() { done [[ -e "$l" ]] && echo "$l" || echo "~nonexistent~" } +function tmpedit() { + if [[ "$#" -ne 1 ]]; then + echo "usage: tmpedit " >&2 + return 1 + fi + local real="$(realpath "$1")" + if [[ ! -f "$real" ]]; then + echo "not found" + return 2 + fi + if [[ ! "$real" =~ /nix/store/* ]]; then + echo "not nix" + return 3 + fi + cp --remove-destination "$real" "$1" + chmod +w "$1" + $EDITOR "$1" +}