Skip to content

Instantly share code, notes, and snippets.

@mattmc3
mattmc3 / split.zsh.md
Last active April 29, 2025 23:00
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!?)

The PATH is an important concept when working on the command line. It's a list of directories that tell your operating system where to look for programs, so that you can just write script instead of /home/me/bin/script or C:\Users\Me\bin\script. But different operating systems have different ways to add a new directory to it:

Windows

  1. The first step depends which version of Windows you're using:
  • If you're using Windows 8 or 10, press the Windows key, then search for and
@awesomebytes
awesomebytes / ipython_to_file.md
Created March 16, 2016 10:38
Save iPython session to a python file as code

Save an iPython session commands/code to a file

You must use the magic method %save:

In [1]: %save?
Type:       Magic function
String Form:<bound method CodeMagics.save of <IPython.core.magics.code.CodeMagics object at 0x7fb5d25bb1d0>>
Namespace:  IPython internal
File: /usr/lib/python2.7/dist-packages/IPython/core/magics/code.py
@aromig
aromig / dsquery_all_attr.cmd
Last active December 3, 2019 11:36
dsquery - list all attributes for a user
dsquery * "OU=User Accounts,DC=your,DC=domain,DC=com" -filter "(samaccountname=USER)" -attr *