tmpedit
This commit is contained in:
parent
28633e37bd
commit
a83f726779
|
|
@ -24,7 +24,7 @@ _load history
|
||||||
_load aliases
|
_load aliases
|
||||||
# set xdg env vars to keep home directory clean
|
# set xdg env vars to keep home directory clean
|
||||||
_load xdg
|
_load xdg
|
||||||
_load show
|
_load func
|
||||||
|
|
||||||
if _exists fzf; then
|
if _exists fzf; then
|
||||||
export FZF_DEFAULT_OPTS="--bind=ctrl-u:page-up,ctrl-d:page-down"
|
export FZF_DEFAULT_OPTS="--bind=ctrl-u:page-up,ctrl-d:page-down"
|
||||||
|
|
|
||||||
|
|
@ -40,3 +40,21 @@ function rl() {
|
||||||
done
|
done
|
||||||
[[ -e "$l" ]] && echo "$l" || echo "~nonexistent~"
|
[[ -e "$l" ]] && echo "$l" || echo "~nonexistent~"
|
||||||
}
|
}
|
||||||
|
function tmpedit() {
|
||||||
|
if [[ "$#" -ne 1 ]]; then
|
||||||
|
echo "usage: tmpedit <file>" >&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"
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue