Skip to content

Commit

Permalink
Improve tmp dir function for zsh
Browse files Browse the repository at this point in the history
  • Loading branch information
mjsteinbaugh committed Sep 4, 2019
1 parent 5f7c632 commit 6c5d007
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions system/include/functions/t.sh
Expand Up @@ -4,22 +4,26 @@


# Create temporary directory.
# # Note: macOS requires `env LC_CTYPE=C`.
#
# Note: macOS requires `env LC_CTYPE=C`.
# Otherwise, you'll see this error: `tr: Illegal byte sequence`.
# This doesn't seem to work reliably, so using timestamp instead.
# # See also:
#
# See also:
# - https://gist.github.com/earthgecko/3089509
# # Updated 2019-06-27.
#
# Updated 2019-09-04.
_koopa_tmp_dir() {
local unique
local dir

unique="$(date "+%Y%m%d-%H%M%S")"
dir="/tmp/koopa-$(id -u)-${unique}"

mkdir -p "$dir"
chown "$USER" "$dir"
chmod 0775 "$dir"
# This doesn't work well with zsh.
# > mkdir -p "$dir"
# > chown "$USER" "$dir"
# > chmod 0775 "$dir"

echo "$dir"
}

0 comments on commit 6c5d007

Please sign in to comment.