From 845158d4a96f9561f408d8d0f293879ef1428c5c Mon Sep 17 00:00:00 2001 From: Moviuro Date: Thu, 3 Jul 2025 11:36:10 +0200 Subject: [PATCH] zshrc: add special code for cdt() for FreeBSD While there, fix whitespace --- etc/zsh/zshrc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index ada2a3c..9667e72 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -3200,10 +3200,18 @@ function mkcd () { #f5# Create temporary directory and \kbd{cd} to it function cdt () { - local -a cdttemplate - [ "$#" -eq 1 ] && cdttemplate=(-t "$1".XXXXXXX) - builtin cd "$(mktemp -d ${cdttemplate[@]})" - builtin pwd + local -a cdttemplate + if [ "$#" -eq 1 ]; then + if isfreebsd; then + # mktemp(1) on FreeBSD doesn't behave the same, cf. + # https://man.freebsd.org/cgi/man.cgi?query=mktemp#OPTIONS + cdttemplate=(-t "$1") + else + cdttemplate=(-t "$1".XXXXXXX) + fi + fi + builtin cd "$(mktemp -d ${cdttemplate[@]})" + builtin pwd } #f5# List files which have been accessed within the last {\it n} days, {\it n} defaults to 1