Skip to content

Instantly share code, notes, and snippets.

@mattmc3
mattmc3 / split.zsh.md
Last active May 15, 2025 09:44
ZSH - split string into array

There are a ton of different ways to split up a string in Zsh. This gist attempts to show them with examples to help you build your own. I write Zsh scripts all the time, and still reference back to this gist, so there you go.

From the Zsh docs on Parameter Expansion Flags (yeah - I know... how would anyone ever find that if they didn't know where to look!?)

j:string: Join the words of arrays together using string as a separator.
s:string: Force field splitting at the separator string.

You can also read more by running man zshexpn. (Again, I know, right!? How would anyone know to look there!?)

@alyssais
alyssais / vpn
Created May 8, 2018 17:12
A tiny command line interface to Viscosity
#!/usr/bin/env bash
run_list() {
osascript <<OSA
tell application "Viscosity"
repeat with theConnection in connections
set theName to name of theConnection
set theState to state of theConnection
log theName & ": " & theState
end repeat