Fish has a utility for [string maniplulation][string].
This is how you can do the same things with Zsh builtins.
References:
- [Zsh regex][3]
- [String modifiers][1]
- [String expansion][2]
| // XORCipher - Super simple encryption using XOR and Base64 | |
| // | |
| // Depends on [Underscore](http://underscorejs.org/). | |
| // | |
| // As a warning, this is **not** a secure encryption algorythm. It uses a very | |
| // simplistic keystore and will be easy to crack. | |
| // | |
| // The Base64 algorythm is a modification of the one used in phpjs.org | |
| // * http://phpjs.org/functions/base64_encode/ | |
| // * http://phpjs.org/functions/base64_decode/ |
This is a cheat sheet for how to perform various actions to ZSH, which can be tricky to find on the web as the syntax is not intuitive and it is generally not very well-documented.
| Description | Syntax |
|---|---|
| Get the length of a string | ${#VARNAME} |
| Get a single character | ${VARNAME[index]} |
| #!/bin/sh | |
| sudo tee -a /etc/hosts << EOF | |
| # Block Google Chrome auto-update | |
| 0.0.0.0 update.googleapis.com | |
| EOF |
| #### | |
| # ZSH function to auto-switch to correct Node version | |
| # https://gist.github.com/callumlocke/30990e247e52ab6ac1aa98e5f0e5bbf5 | |
| # | |
| # - Searches up your directory tree for the closest .nvmrc, just like `nvm use` does. | |
| # | |
| # - If you are already on the right Node version, IT DOES NOTHING, AND PRINTS NOTHING. | |
| # | |
| # - Works correctly if your .nvmrc file contains something relaxed/generic, | |
| # like "4" or "v12.0" or "stable". |
| spamhaus_drop:1.10.16.0-1.10.31.255 | |
| spamhaus_drop:1.19.0.0-1.19.255.255 | |
| spamhaus_drop:1.32.128.0-1.32.191.255 | |
| spamhaus_drop:2.56.192.0-2.56.195.255 | |
| spamhaus_drop:2.57.232.0-2.57.233.255 | |
| spamhaus_drop:2.57.234.0-2.57.235.255 | |
| spamhaus_drop:2.59.200.0-2.59.203.255 | |
| spamhaus_drop:5.42.199.0-5.42.199.255 | |
| spamhaus_drop:5.134.128.0-5.134.159.255 | |
| spamhaus_drop:5.180.4.0-5.180.7.255 |
| #!/usr/bin/env zsh | |
| ffmpeg -i my-video.mov -vcodec h264 -acodec mp2 my-video.mp4 |