Skip to content

Commit 845158d

Browse files
committed
zshrc: add special code for cdt() for FreeBSD
While there, fix whitespace
1 parent 1fea642 commit 845158d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

etc/zsh/zshrc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3200,10 +3200,18 @@ function mkcd () {
32003200

32013201
#f5# Create temporary directory and \kbd{cd} to it
32023202
function cdt () {
3203-
local -a cdttemplate
3204-
[ "$#" -eq 1 ] && cdttemplate=(-t "$1".XXXXXXX)
3205-
builtin cd "$(mktemp -d ${cdttemplate[@]})"
3206-
builtin pwd
3203+
local -a cdttemplate
3204+
if [ "$#" -eq 1 ]; then
3205+
if isfreebsd; then
3206+
# mktemp(1) on FreeBSD doesn't behave the same, cf.
3207+
# https://man.freebsd.org/cgi/man.cgi?query=mktemp#OPTIONS
3208+
cdttemplate=(-t "$1")
3209+
else
3210+
cdttemplate=(-t "$1".XXXXXXX)
3211+
fi
3212+
fi
3213+
builtin cd "$(mktemp -d ${cdttemplate[@]})"
3214+
builtin pwd
32073215
}
32083216

32093217
#f5# List files which have been accessed within the last {\it n} days, {\it n} defaults to 1

0 commit comments

Comments
 (0)