Skip to content

Commit 0ecc41b

Browse files
committed
Add Add To The Path Via Path Array as a Zsh TIL
1 parent 569220e commit 0ecc41b

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010

1111
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
1212

13-
_1453 TILs and counting..._
13+
_1454 TILs and counting..._
1414

1515
---
1616

@@ -80,6 +80,7 @@ _1453 TILs and counting..._
8080
* [XState](#xstate)
8181
* [YAML](#yaml)
8282
* [Zod](#zod)
83+
* [Zsh](#zsh)
8384

8485
---
8586

@@ -1726,6 +1727,10 @@ _1453 TILs and counting..._
17261727
- [Incorporate Existing Type Into Zod Schema](zod/incorporate-existing-type-into-zod-schema.md)
17271728
- [Set Custom Error Message For Nonempty Array](zod/set-custom-error-message-for-nonempty-array.md)
17281729

1730+
### Zsh
1731+
1732+
- [Add To The Path Via Path Array](zsh/add-to-the-path-via-path-array.md)
1733+
17291734
## Usage
17301735

17311736
The `.vimrc` file for this project contains a function `CountTILs` that can

zsh/add-to-the-path-via-path-array.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Add To Path Via Path Array
2+
3+
Typically when managing what is on your path in a Unix shell environment, you
4+
override the `PATH` environment variable with `export`. This is usually an
5+
append or prepend to bring along the existing path entries.
6+
7+
```bash
8+
$ export PATH="$PATH:/Users/me/.local/bin"
9+
```
10+
11+
The `zsh` shell environment exposes another way of adding to your path. They
12+
have a `path` array which can be a little easier to work with since you can use
13+
an array operation instead of string interpolation.
14+
15+
Here is how we'd do the same as above:
16+
17+
```bash
18+
$ path+=/Users/me/.local/bin
19+
```
20+
21+
This works because there is an automatic linking in zsh between arrays and
22+
colon-separated strings (_scalars_).
23+
[source](https://www.zsh.org/mla/users//2005/msg01132.html)
24+
25+
[source](https://superuser.com/a/1447959)

0 commit comments

Comments
 (0)