--- /dev/null
+DESTDIR=${HOME}/.zfunc
+
+.PHONY: all
+all:
+
+.PHONY: install
+install:
+ for f in pcd psd _pcd; do \
+ install -m 644 "$${f}" "${DESTDIR}/"; \
+ done
--- /dev/null
+#compdef pcd psd
+
+local pkgsrcdir
+if [[ -n "${PKGSRCDIR}" ]]; then
+ pkgsrcdir="${PKGSRCDIR}"
+else
+ local -a candidates=(
+ "/usr/pkgsrc"
+ "/opt/pkgsrc"
+ )
+
+ local dir
+ for dir in "${candidates[@]}"; do
+ if [[ -d "$dir" ]]; then
+ pkgsrcdir="$dir"
+ break
+ fi
+ done
+
+ if [[ -z "$pkgsrcdir" ]]; then
+ echo >&2 "PKGSRCDIR not detected"
+ return 1
+ fi
+fi
+
+_arguments '1:directory:_files -/ -W '"$pkgsrcdir"
+
+# Local Variables:
+# mode: sh
+# sh-shell: zsh
+# End:
--- /dev/null
+local pkgpath
+if (( $# == 1 )); then
+ pkgpath="$1"
+else
+ echo >&2 "Usage: $0 PATH"
+ echo >&2
+ echo >&2 "pcd stands for \"pkgsrc cd\", alias to cd \${PKGSRCDIR}/\${PATH}"
+ return 1
+fi
+
+local pkgsrcdir
+if [[ -n "${PKGSRCDIR}" ]]; then
+ pkgsrcdir="${PKGSRCDIR}"
+else
+ local -a candidates=(
+ "/usr/pkgsrc"
+ "/opt/pkgsrc"
+ )
+
+ local dir
+ for dir in "${candidates[@]}"; do
+ if [[ -d "$dir" ]]; then
+ pkgsrcdir="$dir"
+ break
+ fi
+ done
+
+ if [[ -z "$pkgsrcdir" ]]; then
+ echo >&2 "PKGSRCDIR not detected"
+ return 1
+ fi
+fi
+
+cd "${pkgsrcdir}/${pkgpath}"
+
+# Local Variables:
+# mode: sh
+# sh-shell: zsh
+# End:
--- /dev/null
+local pkgpath
+if (( $# == 1 )); then
+ pkgpath="$1"
+else
+ echo >&2 "Usage: $0 PATH"
+ echo >&2
+ echo >&2 "psd stands for \"pkgsrc pushd\", alias to pushd \${PKGSRCDIR}/\${PATH}"
+ return 1
+fi
+
+local pkgsrcdir
+if [[ -n "${PKGSRCDIR}" ]]; then
+ pkgsrcdir="${PKGSRCDIR}"
+else
+ local -a candidates=(
+ "/usr/pkgsrc"
+ "/opt/pkgsrc"
+ )
+
+ local dir
+ for dir in "${candidates[@]}"; do
+ if [[ -d "$dir" ]]; then
+ pkgsrcdir="$dir"
+ break
+ fi
+ done
+
+ if [[ -z "$pkgsrcdir" ]]; then
+ echo >&2 "PKGSRCDIR not detected"
+ return 1
+ fi
+fi
+
+pushd "${pkgsrcdir}/${pkgpath}"
+
+# Local Variables:
+# mode: sh
+# sh-shell: zsh
+# End: