Skip to content

Commit 6e9f66f

Browse files
authored
Merge pull request #221 from moviuro/cdt_fbsd
zshrc: add special code for cdt() for FreeBSD
2 parents 6e56156 + 845158d commit 6e9f66f

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
@@ -3201,10 +3201,18 @@ function mkcd () {
32013201

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

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

0 commit comments

Comments
 (0)