From a83f726779ba7115f6cae2f3c857cfcc22a60ba9 Mon Sep 17 00:00:00 2001 From: caandt Date: Wed, 25 Dec 2024 14:31:37 -0500 Subject: [PATCH] tmpedit --- user/config/bash/custom | 2 +- user/config/bash/{show => func} | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) rename user/config/bash/{show => func} (71%) 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" +}