add cdpath

This commit is contained in:
2026-04-19 23:48:30 +02:00
parent 8fcc8c67bf
commit c95176c7a9

21
system/cdpath.md Normal file
View File

@@ -0,0 +1,21 @@
---
title: "Instantly cd anywhere in bash"
tags: [ "system", "bash" ]
---
Change locations quickly with the `bash` built-in variable: `$CDPATH`.
```bash
CDPATH=~
```
Now if you want to enter `~/docs/` you can type `cd docs`, even if you're not in your home directory.
Add multiple locations with a colon between them.
```bash
CDPATH=~/archives/$(date +%Y/%m/):~:~/projects/:/mnt/share/
```
The first one will let you enter any directory inside '2028/01/', or whatever the current date is.