mirror of
https://github.com/jbranchaud/til
synced 2026-01-20 07:28:02 +00:00
Compare commits
1 Commits
b23ace0933
...
af2bf37528
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af2bf37528 |
@@ -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).
|
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||||
|
|
||||||
_1455 TILs and counting..._
|
_1453 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -80,7 +80,6 @@ _1455 TILs and counting..._
|
|||||||
* [XState](#xstate)
|
* [XState](#xstate)
|
||||||
* [YAML](#yaml)
|
* [YAML](#yaml)
|
||||||
* [Zod](#zod)
|
* [Zod](#zod)
|
||||||
* [Zsh](#zsh)
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -1727,11 +1726,6 @@ _1455 TILs and counting..._
|
|||||||
- [Incorporate Existing Type Into Zod Schema](zod/incorporate-existing-type-into-zod-schema.md)
|
- [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)
|
- [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)
|
|
||||||
- [Link A Scalar To An Array](zsh/link-a-scalar-to-an-array.md)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
The `.vimrc` file for this project contains a function `CountTILs` that can
|
The `.vimrc` file for this project contains a function `CountTILs` that can
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
# 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)
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
# Link A Scalar To An Array
|
|
||||||
|
|
||||||
`Zsh` has a builtin command `typeset` that does a variety of things. When given
|
|
||||||
the `-T` flag and the names of a scalar and an array, it will link them
|
|
||||||
together so that a change to one is reflected in the other.
|
|
||||||
|
|
||||||
The scalar is a string of values delimited by a colon (`:`). The array is an
|
|
||||||
array that can be interacted with using array operations like append (`+=`).
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ typeset -T FOO foo
|
|
||||||
|
|
||||||
$ echo $FOO
|
|
||||||
|
|
||||||
|
|
||||||
$ export FOO="one:two"
|
|
||||||
|
|
||||||
$ echo $foo
|
|
||||||
one two
|
|
||||||
|
|
||||||
$ foo+=three
|
|
||||||
|
|
||||||
$ echo $FOO
|
|
||||||
one:two:three
|
|
||||||
```
|
|
||||||
|
|
||||||
Notice `FOO` is initially empty. I then `export` it to overwrite it with two
|
|
||||||
values delimited by a colon. Since `foo` is automatically kept in sync, I can
|
|
||||||
`echo $foo` and see those values displayed as an array. I can then append a
|
|
||||||
third value using an array operation on `foo`. The update will be automatically
|
|
||||||
reflected in `FOO`.
|
|
||||||
|
|
||||||
`Zsh` does this under the hood for `PATH` and `path` which is why you can [add
|
|
||||||
to the path via the path array](add-to-the-path-via-path-array.md).
|
|
||||||
|
|
||||||
See `man zshbuiltins` for more details.
|
|
||||||
|
|
||||||
[source](http://devlib.symbian.slions.net/s3/GUID-D87C96CE-3F23-552D-927C-B6A1D61691BF.html)
|
|
||||||
Reference in New Issue
Block a user