diff --git a/share/functions/funced.fish b/share/functions/funced.fish index 6439e53fa..8f62e96bc 100644 --- a/share/functions/funced.fish +++ b/share/functions/funced.fish @@ -87,7 +87,11 @@ function funced --description 'Edit function definition' return 0 end - set tmpname (mktemp -t fish_funced.XXXXXXXXXX.fish) + # OSX mktemp is rather restricted - no suffix, no way to automatically use TMPDIR + # Create a directory so we can use a ".fish" suffix for the file - makes editors pick up that it's a fish file + set -q TMPDIR; or set -l TMPDIR /tmp + set -l tmpdir (mktemp -d $TMPDIR/fish.XXXXXX) + set -l tmpname $tmpdir/$funcname.fish if functions -q -- $funcname functions -- $funcname > $tmpname @@ -120,6 +124,6 @@ function funced --description 'Edit function definition' break end set -l stat $status - rm -f $tmpname >/dev/null + rm -rf $tmpdir >/dev/null return $stat end