Skip to content

zshrc: add special code for cdt() for FreeBSD #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions etc/zsh/zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down