1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 15:18:01 +00:00

Add Add To The Path Via Path Array as a Zsh TIL

This commit is contained in:
jbranchaud
2024-10-07 18:37:23 -05:00
parent 569220e734
commit 0ecc41bd29
2 changed files with 31 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
_1453 TILs and counting..._
_1454 TILs and counting..._
---
@@ -80,6 +80,7 @@ _1453 TILs and counting..._
* [XState](#xstate)
* [YAML](#yaml)
* [Zod](#zod)
* [Zsh](#zsh)
---
@@ -1726,6 +1727,10 @@ _1453 TILs and counting..._
- [Incorporate Existing Type Into Zod Schema](zod/incorporate-existing-type-into-zod-schema.md)
- [Set Custom Error Message For Nonempty Array](zod/set-custom-error-message-for-nonempty-array.md)
### Zsh
- [Add To The Path Via Path Array](zsh/add-to-the-path-via-path-array.md)
## Usage
The `.vimrc` file for this project contains a function `CountTILs` that can

View File

@@ -0,0 +1,25 @@
# Add To Path Via Path Array
Typically when managing what is on your path in a Unix shell environment, you
override the `PATH` environment variable with `export`. This is usually an
append or prepend to bring along the existing path entries.
```bash
$ export PATH="$PATH:/Users/me/.local/bin"
```
The `zsh` shell environment exposes another way of adding to your path. They
have a `path` array which can be a little easier to work with since you can use
an array operation instead of string interpolation.
Here is how we'd do the same as above:
```bash
$ path+=/Users/me/.local/bin
```
This works because there is an automatic linking in zsh between arrays and
colon-separated strings (_scalars_).
[source](https://www.zsh.org/mla/users//2005/msg01132.html)
[source](https://superuser.com/a/1447959)