Example splitting string on slash character in ZSH.
$ str=part1/part2/part3
$ parts=(${(@s:/:)str})
$ echo $parts
part1 part2 part3
$ echo ${#parts[@]}
3
# A minimal .zshrc that uses a .zshrc.d for its content | |
# load zprof first if we need to profile | |
[[ ${ZSH_PROFILE_RC:-0} -eq 0 ]] || zmodload zsh/zprof | |
# helpful profiling aliases | |
alias zprofrc="ZSH_PROFILE_RC=1 zsh" | |
alias zbench='for i in $(seq 1 10); do; /usr/bin/time zsh -i -c exit; done' | |
# source all scripts in a config dir |
Example splitting string on slash character in ZSH.
$ str=part1/part2/part3
$ parts=(${(@s:/:)str})
$ echo $parts
part1 part2 part3
$ echo ${#parts[@]}
3
brew_export() { | |
# brew bundle is a pain... it dumps to a forced Brewfile, and is not | |
# consistently sorted, making version controling your Brewfile in a dotfile | |
# repo tricky. #FixedIt | |
# makes a Brewfile | |
brew bundle dump --force | |
# add custom sort column | |
awkcmd=' |
// ==UserScript== | |
// @name stackoverflow tampering | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description StackOverflow - hide #hot-network-questions and deleted stuff. | |
// @author mattmc3 | |
// @grant none | |
// @require http://code.jquery.com/jquery-latest.js | |
// @match https://*.stackoverflow.com | |
// @match https://*.stackexchange.com |
# http://zsh.sourceforge.net/Doc/Release/Parameters.html#Subscript-Flags | |
# https://unix.stackexchange.com/questions/411304/how-do-i-check-whether-a-zsh-array-contains-a-given-value/411306 | |
array=(foo bar baz foo) | |
# 'I' is the subscript flag for index | |
pattern=f* | |
if (($array[(I)$pattern])); then | |
echo array contains at least one value that matches the pattern | |
fi |
# assumes github and slash separated plugin names | |
github_plugins=( | |
zsh-users/zsh-autosuggestions | |
zsh-users/zsh-completions | |
zsh-users/zsh-history-substring-search | |
rupa/z | |
# theme | |
miekg/lean | |
# must be last | |
zdharma/fast-syntax-highlighting |
ISA*01*0000000000*01*0000000000*ZZ*ABCDEFGHIJKLMNO*ZZ*123456789012345*101127*1719*U*00400*000003438*0*P*> | |
GS*PO*4405197800*999999999*20101127*1719*1421*X*004010VICS | |
ST*834*0179 | |
BGN*00*1*20050315*110650****4 | |
REF*38*SAMPLE_POLICY_NUMBER | |
DTP*303*D8*20080321 | |
N1*P5*COMPAN_NAME*FI*000000000 | |
INS*Y*18*030*20*A | |
REF*0F*SUBSCRIBER_NUMBER | |
NM1*IL*1*JOHN DOE*R***34*1*0000000 |
## ZSH Options | |
# http://zsh.sourceforge.net/Doc/Release/Options.html | |
# Changing Directories | |
# http://zsh.sourceforge.net/Doc/Release/Options.html#Changing-Directories | |
setopt auto_cd # if a command isn't valid, but is a directory, cd to that dir | |
setopt auto_pushd # make cd push the old directory onto the directory stack | |
setopt pushd_ignore_dups # don’t push multiple copies of the same directory onto the directory stack | |
setopt pushd_minus # exchanges the meanings of ‘+’ and ‘-’ when specifying a directory in the stack |