Skip to content

Commit 9f0abe4

Browse files
committed
[zsh] add cdn for cding into recent directory
1 parent bb7621f commit 9f0abe4

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

zsh/.config/zsh/functions

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,14 @@ dc() {
259259
cd "${PWD%/$1/*}/$1/" 2>/dev/null || echo "Directory not found: $1"
260260
}
261261

262+
# cd into the latest directory in the current dir
263+
cdn() {
264+
dir="$(fd --type d --max-depth 1 --exec stat -c '%Y %n' {} |
265+
sort -n | tail -1 | cut -d' ' -f2)"
266+
echo "$dir"
267+
cd "$dir" || return 1
268+
}
269+
262270
# Create a tmp dir, unzip file into it, cd into it
263271
showme() {
264272
[ -z "$1" ] && echo "Pass file to show" && return 1
@@ -278,14 +286,14 @@ showme() {
278286
}
279287

280288
# Need to be a function to capture exit code
281-
boop () {
282-
local last="$?"
283-
if [[ "$last" == '0' ]]; then
284-
,make-noise notify
285-
else
286-
,make-noise error
287-
fi
288-
$(exit "$last")
289+
boop() {
290+
local last="$?"
291+
if [[ "$last" == '0' ]]; then
292+
,make-noise notify
293+
else
294+
,make-noise error
295+
fi
296+
$(exit "$last")
289297
}
290298

291299
# Small functions (these are ideally aliases, but need args)
@@ -296,4 +304,4 @@ eout() {
296304

297305
eoh() {
298306
esa --show-output "${1:-1}" | ,markdown-to-html
299-
}
307+
}

0 commit comments

Comments
 (0)