shopt -u autocd&>/dev/null; shopt -u cdable_vars&>/dev/null; shopt -u cdspell&>/dev/null; shopt -u checkhash&>/dev/null; shopt -u checkjobs&>/dev/null; shopt -u checkwinsize&>/dev/null; shopt -s cmdhist&>/dev/null; shopt -u compat31&>/dev/null; shopt -u compat32&>/dev/null; shopt -u compat40&>/dev/null; shopt -u compat41&>/dev/null; shopt -u compat42&>/dev/null; shopt -u compat43&>/dev/null; shopt -s complete_fullquote&>/dev/null; shopt -u direxpand&>/dev/null; shopt -u dirspell&>/dev/null; shopt -u dotglob&>/dev/null; shopt -u execfail&>/dev/null; shopt -s expand_aliases&>/dev/null; shopt -s extdebug&>/dev/null; shopt -u extglob&>/dev/null; shopt -s extquote&>/dev/null; shopt -u failglob&>/dev/null; shopt -s force_fignore&>/dev/null; shopt -u globasciiranges&>/dev/null; shopt -u globstar&>/dev/null; shopt -u gnu_errfmt&>/dev/null; shopt -u histappend&>/dev/null; shopt -u histreedit&>/dev/null; shopt -u histverify&>/dev/null; shopt -s hostcomplete&>/dev/null; shopt -u huponexit&>/dev/null; shopt -u inherit_errexit&>/dev/null; shopt -s interactive_comments&>/dev/null; shopt -u lastpipe&>/dev/null; shopt -u lithist&>/dev/null; shopt -u login_shell&>/dev/null; shopt -u mailwarn&>/dev/null; shopt -s no_empty_cmd_completion&>/dev/null; shopt -s nocaseglob&>/dev/null; shopt -u nocasematch&>/dev/null; shopt -u nullglob&>/dev/null; shopt -s progcomp&>/dev/null; shopt -s promptvars&>/dev/null; shopt -u restricted_shell&>/dev/null; shopt -u shift_verbose&>/dev/null; shopt -s sourcepath&>/dev/null; shopt -u xpg_echo&>/dev/null; shopt -s expand_aliases &>/dev/null alias ash='(f=$(ps -o comm= $$); [[ $f =~ ^- ]] && echo $SHELL || which "$f")' alias bi='bundleid' alias bv='echo $BASH_VERSION' alias cdb='cd "$OLDPWD"' alias cpg='"$HOME/Desktop/pg"/cpg' alias dec='de "$@"' alias dn='/dev/null' alias dpg='"$HOME/Desktop/pg"/dpg' alias dt='cat -et' alias e='/Users/jdoe/MkUtil/editf' alias ecc='editf $MK_UTIL_FOLDER/sourced.d/bash_completion.d/custom-completions' alias ecpg='editf "$HOME/Desktop/pg"/cpg' alias edpg='editf "$HOME/Desktop/pg"/dpg' alias eh='enc --html' alias ei='editf ~/.bashrc' alias ejaypg='editf "$HOME/Desktop/pg"/jaypg' alias ekpg='editf "$HOME/Desktop/pg"/kpg' alias enp='editf ~/.nesh_profile.coffee' alias enpg='editf "$HOME/Desktop/pg"/npg' alias ep='editf ~/.bash_profile' alias epg='editf "$HOME/Desktop/pg"/pg' alias epg.cpp='editf "$HOME/Desktop/pg"/pg.cpp' alias epg.cs='editf "$HOME/Desktop/pg"/pg.cs' alias epg.html='editf "$HOME/Desktop/pg"/pg.html' alias epg.md='editf "$HOME/Desktop/pg"/pg.md' alias epg.ts='editf "$HOME/Desktop/pg"/pg.ts' alias epg2='editf "$HOME/Desktop/pg"/pg2' alias epg4='editf "$HOME/Desktop/pg"/pg4' alias epgjxa.scpt='editf "$HOME/Desktop/pg"/pgjxa.scpt' alias ephpg='editf "$HOME/Desktop/pg"/phpg' alias epi='editf ~/.perli_rc' alias eplpg='editf "$HOME/Desktop/pg"/plpg' alias epy3pg='editf "$HOME/Desktop/pg"/py3pg' alias epypg='editf "$HOME/Desktop/pg"/pypg' alias eqcd='editf $MK_UTIL_FOLDER/sourced.d/quickCdDefs' alias erpg='editf "$HOME/Desktop/pg"/rpg' alias es='edits' alias eshallpg='editf "$HOME/Desktop/pg"/shallpg' alias eshpg='editf "$HOME/Desktop/pg"/shpg' alias etclpg='editf "$HOME/Desktop/pg"/tclpg' alias eu='enc --uri' alias ex='enc --xml' alias exppg='editf "$HOME/Desktop/pg"/xppg' alias ezpg='editf "$HOME/Desktop/pg"/zpg' alias fhx='od -t x1' alias fp='fullpath' alias fq='findq' alias fx='findexes' alias gc='git checkout' alias gcb='pbpaste' alias gcm='typex' alias gfs='getFinderSel' alias gl='git log --pretty=oneline' alias gs='git status -b --short' alias gt='git describe --abbrev=0 --tags' alias gvr='git remote -v | awk '\''{ print $2; exit }'\'' | xargs open' alias hd='hexdump' alias hg='echo "(Using MacHg binary via an alias.)"; "/Applications/MacHg.app/Contents/Resources/localhg"' alias imgcat='/Users/jdoe/.iterm2/imgcat' alias imgls='/Users/jdoe/.iterm2/imgls' alias it2attention='/Users/jdoe/.iterm2/it2attention' alias it2check='/Users/jdoe/.iterm2/it2check' alias it2copy='/Users/jdoe/.iterm2/it2copy' alias it2dl='/Users/jdoe/.iterm2/it2dl' alias it2getvar='/Users/jdoe/.iterm2/it2getvar' alias it2setcolor='/Users/jdoe/.iterm2/it2setcolor' alias it2setkeylabel='/Users/jdoe/.iterm2/it2setkeylabel' alias it2ul='/Users/jdoe/.iterm2/it2ul' alias it2universion='/Users/jdoe/.iterm2/it2universion' alias jaypg='"$HOME/Desktop/pg"/jaypg' alias josa='osascript -l JavaScript' alias kbs='keyboardspec' alias kpg='"$HOME/Desktop/pg"/kpg' alias lf='declare -F | awk '\''{ print $3 }'\''' alias lfe='declare -Fx | awk -F'\''[ =]'\'' '\''{ print $3 }'\''' alias lsregister='/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister' alias lsx='fls -FAhl' alias lv='(shopt -so posix; declare | awk -F= '\''{ print $1 }'\'')' alias lve='export -p | awk -F'\''[ =]'\'' '\''{ print $3 }'\''' alias lx='PATH=".:$PATH"' alias m='manx' alias md='mkdir' alias mdp='markdown.pl' alias mg='manxg' alias mmdp='multimarkdown' alias mo='manopt' alias mu='markup-js' alias mw='manw' alias ne='node -e' alias np='node -p' alias npg='"$HOME/Desktop/pg"/npg' alias npmenv='echo "ENTERING CHILD SHELL with npm ENVIRONMENT for $PWD..." && npm run env -- $SHELL || echo "ERROR: You must call this function from an npm package directory; child shell NOT entered." >&2' alias npmh='npm home' alias nr='npm run' alias ns='newscript' alias nsh='nesh -e <(coffee -bp ~/.nesh_profile.coffee)' alias nshc='nesh -c -e ~/.nesh_profile.coffee' alias nt='newtab' alias nw='newwin' alias nx='npm run-script env --' alias o='open' alias oa='open -a' alias oda='od -a' alias odx='od -t x1' alias omd='open -a '\''Marked 2'\''' alias osa='osascript' alias ou='openurl' alias oud='openurl -d' alias p='printf "%s\n"' alias p1='ping -c 1 -t 1' alias pd='perldoc' alias pf='declare -f' alias pg='"$HOME/Desktop/pg"/pg' alias pg.cpp='g++ -o "$HOME/Desktop/pg"/pgb "$HOME/Desktop/pg"/pg.cpp && "$HOME/Desktop/pg"/pgb' alias pg.cs='pushd "$HOME/Desktop/pg"/pg.cs >/dev/null && echo === NOTE: cwd is temporarily ./pg.cs === && dotnet run; popd >/dev/null' alias pg.html='"$HOME/Desktop/pg"/pg.html' alias pg.md='open -a Marked.app -- "$HOME/Desktop/pg"/pg.md' alias pg.ts='printf "Compiling to "$HOME/Desktop/pg"/pg.js (tsc) and invoking (node)..." && tsc "$HOME/Desktop/pg"/pg.ts && printf "\r%*s\r" 79 && node "$HOME/Desktop/pg"/pg.js' alias pg2='"$HOME/Desktop/pg"/pg2' alias pg4='"$HOME/Desktop/pg"/pg4' alias pgjxa.scpt='osascript -l JavaScript "$HOME/Desktop/pg"/pgjxa.scpt' alias phpg='"$HOME/Desktop/pg"/phpg' alias plb='/usr/libexec/PlistBuddy' alias plpg='"$HOME/Desktop/pg"/plpg' alias posh='powershell' alias ptc='pathToClipboard' alias py='python' alias py2='python' alias py3='python3' alias py3pg='"$HOME/Desktop/pg"/py3pg' alias pypg='"$HOME/Desktop/pg"/pypg' alias q='quote' alias rbn='shutdownnow -r' alias ri='{ echo "Reloading the initialization file (~/.bashrc)..."; . ~/.bashrc; }' alias rp='{ echo "Reloading the profile file (~/.bash_profile)..."; . ~/.bash_profile; }' alias rpg='"$HOME/Desktop/pg"/rpg' alias rsi='resizeimages' alias scb='tc' alias sdn='shutdownnow' alias shallpg='"$HOME/Desktop/pg"/shallpg' alias sho='vo' alias shpg='"$HOME/Desktop/pg"/shpg' alias sln='shutdownnow -s' alias st='steroids' alias tcl='rlwrap tclsh' alias tclpg='"$HOME/Desktop/pg"/tclpg' alias tkc='(tkcon &) && osascript <<<$'\''repeat while true\n delay 0.1\n if application "Wish" is running then\n try\n activate application "Wish"\n return\n end try\n end if\nend repeat'\''' alias toascii='iconv -f utf8 -t ascii -c' alias topc='top -l 2 -n 10 -o cpu -stats cpu,command | fgrep -v " top" | tail -n 10' alias tp='typex' alias ts='timestamps' alias ueh='enc -u --html' alias ueu='enc -u --uri' alias uex='enc -u --xml' alias uti='mdls -name kMDItemContentType' alias utis='mdls -name kMDItemContentTypeTree' alias vman='marked-man | cat >/tmp/vman$$ && man /tmp/vman$$' alias vmd='cat >/tmp/vmd$$ && open -a "Marked 2" /tmp/vmd$$' alias wh='which' alias wha='whichapp' alias xppg='"$HOME/Desktop/pg"/xppg' alias zpg='"$HOME/Desktop/pg"/zpg' declare -x Apple_PubSub_Socket_Render="/private/tmp/com.apple.launchd.ZSsLeK3KyX/Render" declare -- BASH="/usr/local/bin/bash4" declare -x CLICOLOR="" declare -x COLORFGBG="0;15" declare -x COLORTERM="truecolor" declare -- COLUMNS="220" declare -x COMP_WORDBREAKS="@ \"'><;|&(:" declare -x DISPLAY="/private/tmp/com.apple.launchd.WdrYFjwfT0/org.macosforge.xquartz:0" declare -x EDITOR="sublwait" declare -x FCEDIT="sublwait" declare -x GEM_HOME="/Users/jdoe/.rvm/gems/ruby-2.4.0" declare -x GEM_PATH="/Users/jdoe/.rvm/gems/ruby-2.4.0:/Users/jdoe/.rvm/gems/ruby-2.4.0@global" declare -i HISTCMD="1" declare -- HISTCONTROL="ignoredups" declare -- HISTFILE="/Users/jdoe/.bash_history" declare -- HISTFILESIZE="500" declare -- HISTSIZE="500" declare -x HOME="/Users/jdoe" declare -- HOSTNAME="MkiMac.home" declare -- HOSTTYPE="x86_64" declare -- IFS=" " declare -x IRBRC="/Users/jdoe/.rvm/rubies/ruby-2.4.0/.irbrc" declare -x ITERM_ORIG_PS1="\$( [ \"\$USER\" = 'root' ] && printf %s \\u:\\w || # sudo { { [ \"\$0\" = 'bash' ] || [ \"\$0\" = '/bin/bash' ] || [ \"\$0\" = '-bash' ]; } && { # bash _PS1 30 # cwd-shortening function if [[ -d .git ]]; then # git repos: show the branch name and, if there are uncommitted changes, append an asterisk printf ' [%s%s]' \"\$(git symbolic-ref --short HEAD 2>/dev/null || echo '(NO HEAD)')\" \"\$([[ -n \$(git status --porcelain) ]] && printf '\\[\\e[0;31m\\]*\\[\\e[0m\\]')\" fi } || printf \"[\$0] \$PWD\" # other shells; note that we can't use coloring in a cross-shell-compatible fashion } printf '\$ ' )" declare -- ITERM_PREEXEC_INTERACTIVE_MODE="" declare -x ITERM_PREV_PS1="\\[133;D;\$?1337;RemoteHost=jdoe@MkiMac.home1337;CurrentDir=/Users/jdoe/Desktop/pg133;A\\]\$( [ \"\$USER\" = 'root' ] && printf %s \\u:\\w || # sudo { { [ \"\$0\" = 'bash' ] || [ \"\$0\" = '/bin/bash' ] || [ \"\$0\" = '-bash' ]; } && { # bash _PS1 30 # cwd-shortening function if [[ -d .git ]]; then # git repos: show the branch name and, if there are uncommitted changes, append an asterisk printf ' [%s%s]' \"\$(git symbolic-ref --short HEAD 2>/dev/null || echo '(NO HEAD)')\" \"\$([[ -n \$(git status --porcelain) ]] && printf '\\[\\e[0;31m\\]*\\[\\e[0m\\]')\" fi } || printf \"[\$0] \$PWD\" # other shells; note that we can't use coloring in a cross-shell-compatible fashion } printf '\$ ' )\\[133;B\\]" declare -x ITERM_PROFILE="Default" declare -x ITERM_SESSION_ID="w0t0p0:F3C22F95-3FCF-4888-A3A1-D57093BD9C50" declare -- ITERM_SHELL_INTEGRATION_INSTALLED="Yes" declare -x LANG="en_US.UTF-8" declare -i LINENO="70" declare -- LINES="75" declare -x LOGNAME="jdoe" declare -- MACHTYPE="x86_64-apple-darwin16.3.0" declare -i MAILCHECK="60" declare -x MK_PLAYGROUND_FOLDER="/Users/jdoe/Desktop/pg" declare -x MK_UTIL_FOLDER="/Users/jdoe/MkUtil" declare -x MK_UTIL_FOLDER_PERSONAL="/Users/jdoe/MkUtil.Win/Users/jdoe" declare -x MY_RUBY_HOME="/Users/jdoe/.rvm/rubies/ruby-2.4.0" declare -x N_PREFIX="/Users/jdoe/n" declare -x OLDPWD="/Users/jdoe" declare -- OPTERR="1" declare -i OPTIND="1" declare -- OSTYPE="darwin16.3.0" declare -x PATH="/Users/jdoe/.rvm/gems/ruby-2.4.0/bin:/Users/jdoe/.rvm/gems/ruby-2.4.0@global/bin:/Users/jdoe/.rvm/rubies/ruby-2.4.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/jdoe/bin:/Users/jdoe/MkUtil:/Users/jdoe/.dotnet:/Users/jdoe/n/bin:/Users/jdoe/.rvm/bin" declare -- PROMPT_COMMAND="iterm2_preexec_invoke_cmd" declare -x PS1="\$( [ \"\$USER\" = 'root' ] && printf %s \\u:\\w || # sudo { { [ \"\$0\" = 'bash' ] || [ \"\$0\" = '/bin/bash' ] || [ \"\$0\" = '-bash' ]; } && { # bash _PS1 30 # cwd-shortening function if [[ -d .git ]]; then # git repos: show the branch name and, if there are uncommitted changes, append an asterisk printf ' [%s%s]' \"\$(git symbolic-ref --short HEAD 2>/dev/null || echo '(NO HEAD)')\" \"\$([[ -n \$(git status --porcelain) ]] && printf '\\[\\e[0;31m\\]*\\[\\e[0m\\]')\" fi } || printf \"[\$0] \$PWD\" # other shells; note that we can't use coloring in a cross-shell-compatible fashion } printf '\$ ' )" declare -- PS2="> " declare -- PS4="+ " declare -x PWD="/Users/jdoe/Desktop/pg" declare -i RANDOM="13804" declare -x RUBY_VERSION="ruby-2.4.0" declare -i SECONDS="91" declare -x SECURITYSESSIONID="186a7" declare -x SHELL="/bin/bash" declare -x SHLVL="2" declare -x SSH_AUTH_SOCK="/private/tmp/com.apple.launchd.QpR2TVefkw/Listeners" declare -x TERM="xterm" declare -x TERM_PROGRAM="iTerm.app" declare -x TERM_PROGRAM_VERSION="3.1.beta.3" declare -x TERM_SESSION_ID="w0t0p0:F3C22F95-3FCF-4888-A3A1-D57093BD9C50" declare -x TMPDIR="/var/folders/19/0lxcl7hd63d6fqd813glqppc0000gn/T/" declare -x USER="jdoe" declare -x XPC_FLAGS="0x0" declare -x XPC_SERVICE_NAME="0" declare -x __CF_USER_TEXT_ENCODING="0x1F5:0x0:0x0" declare -- __git_all_commands="" declare -- __git_diff_algorithms="myers minimal patience histogram" declare -- __git_diff_common_options="--stat --numstat --shortstat --summary --patch-with-stat --name-only --name-status --color --no-color --color-words --no-renames --check --full-index --binary --abbrev --diff-filter= --find-copies-harder --text --ignore-space-at-eol --ignore-space-change --ignore-all-space --ignore-blank-lines --exit-code --quiet --ext-diff --no-ext-diff --no-prefix --src-prefix= --dst-prefix= --inter-hunk-context= --patience --histogram --minimal --raw --word-diff --dirstat --dirstat= --dirstat-by-file --dirstat-by-file= --cumulative --diff-algorithm= " declare -- __git_fetch_options=" --quiet --verbose --append --upload-pack --force --keep --depth= --tags --no-tags --all --prune --dry-run --recurse-submodules= " declare -- __git_fetch_recurse_submodules="yes on-demand no" declare -- __git_flow_config_file_options=" --local --global --system --file= " declare -- __git_format_patch_options=" --stdout --attach --no-attach --thread --thread= --no-thread --numbered --start-number --numbered-files --keep-subject --signoff --signature --no-signature --in-reply-to= --cc= --full-index --binary --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix= --inline --suffix= --ignore-if-in-upstream --subject-prefix= --output-directory --reroll-count --to= --quiet --notes " declare -- __git_log_common_options=" --not --all --branches --tags --remotes --first-parent --merges --no-merges --max-count= --max-age= --since= --after= --min-age= --until= --before= --min-parents= --max-parents= --no-min-parents --no-max-parents " declare -- __git_log_date_formats="relative iso8601 rfc2822 short local default raw" declare -- __git_log_gitk_options=" --dense --sparse --full-history --simplify-merges --simplify-by-decoration --left-right --notes --no-notes " declare -- __git_log_pretty_formats="oneline short medium full fuller email raw format:" declare -- __git_log_shortlog_options=" --author= --committer= --grep= --all-match " declare -- __git_merge_options=" --no-commit --no-stat --log --no-log --squash --strategy --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit --verify-signatures --no-verify-signatures --gpg-sign --quiet --verbose --progress --no-progress " declare -- __git_merge_strategies="" declare -- __git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare " declare -- __git_porcelain_commands="" declare -- __git_push_recurse_submodules="check on-demand" declare -- __git_send_email_confirm_options="always never auto cc compose" declare -- __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all" declare -- __git_whitespacelist="nowarn warn error error-all fix" declare -- __typex_scriptpath="/Users/jdoe/n/bin/typex" declare -- _grep_REGEXP="(.*)" declare -- _ignore_UNDERSCORE="" declare -- _list_alias_BODIES="alias ash bi bv cdb cpg dec dn dpg dt e ecc ecpg edpg eh ei ejaypg ekpg enp enpg ep epg epg.cpp epg.cs epg.html epg.md epg.ts epg2 epg4 epgjxa.scpt ephpg epi eplpg epy3pg epypg eqcd erpg es eshallpg eshpg etclpg eu ex exppg ezpg fhx fp fq fx gc gcb gcm gfs gl gs gt gvr hd hg imgcat imgls it2attention it2check it2copy it2dl it2getvar it2setcolor it2setkeylabel it2ul it2universion jaypg josa kbs kpg lf lfe lsregister lsx lv lve lx m md mdp mg mmdp mo mu mw ne np npg npmenv npmh nr ns nsh nshc nt nw nx o oa oda odx omd osa ou oud p p1 pd pf pg pg.cpp pg.cs pg.html pg.md pg.ts pg2 pg4 pgjxa.scpt phpg plb plpg posh ptc py py2 py3 py3pg pypg q rbn ri rp rpg rsi scb sdn shallpg sho shpg sln st tcl tclpg tkc toascii topc tp ts ueh ueu uex uti utis vman vmd wh wha xppg zpg" declare -- _list_function_BODIES="typeset -f = =awk =gawk =mawk =perl _PS1 __git_aliased_command __git_aliases __git_commands __git_complete __git_complete_file __git_complete_force_with_lease __git_complete_index_file __git_complete_remote_or_refspec __git_complete_revlist __git_complete_revlist_file __git_complete_strategy __git_compute_all_commands __git_compute_merge_strategies __git_compute_porcelain_commands __git_config_get_set_variables __git_count_arguments __git_find_on_cmdline __git_flow_config __git_flow_feature __git_flow_hotfix __git_flow_init __git_flow_list_branches __git_flow_list_local_branches __git_flow_list_remote_branches __git_flow_prefix __git_flow_release __git_flow_support __git_func_wrap __git_has_doubledash __git_heads __git_index_files __git_list_all_commands __git_list_merge_strategies __git_list_porcelain_commands __git_ls_files_helper __git_main __git_match_ctag __git_pretty_aliases __git_reassemble_comp_words_by_ref __git_refs __git_refs2 __git_refs_remotes __git_remotes __git_tags __git_wrap__git_main __git_wrap__gitk_main __gitcomp __gitcomp_file __gitcomp_nl __gitcomp_nl_append __gitcompadd __gitcompappend __gitdir __gitk_main __typex_isParentSupportedShell __typex_isSupportedShell _complete_edits _complete_lx _complete_make _complete_pf _complete_pv _complete_unset _complete_up _get_comp_words_by_ref _git _git_add _git_am _git_apply _git_archive _git_bisect _git_branch _git_bundle _git_checkout _git_cherry _git_cherry_pick _git_clean _git_clone _git_commit _git_config _git_describe _git_diff _git_difftool _git_fetch _git_flow _git_format_patch _git_fsck _git_gc _git_gitk _git_grep _git_help _git_init _git_log _git_ls_files _git_ls_remote _git_ls_tree _git_merge _git_merge_base _git_mergetool _git_mv _git_name_rev _git_notes _git_pull _git_push _git_rebase _git_reflog _git_remote _git_replace _git_reset _git_revert _git_rm _git_send_email _git_shortlog _git_show _git_show_branch _git_stage _git_stash _git_submodule _git_svn _git_tag _git_whatchanged _gitk _npm_completion _tobase af brm calc cdp de dfs difs doIt docker-start docker-stop dsh ec env_parallel f fa fag fas fasu fau fawf fawfc fawfd fawfp fcfg fcu fd fdb fdbp fdl fdla fdt feb febi febo ff fh fhomer fic fif findexes findq fkkac fkkai fl fla flau flsys flu fngb fngm fobt foldIndent foss fpg fpgw fph fppg fpr fpref fprefu fql fqlu fs fsba fsd fsl fslu fsn fsph fss fstp fstpu fsu fsv fsvms ft ftr ftu fu fub fuc fulb fullpath fus fuw fvms fwac getip getips installnode iterm2_begin_osc iterm2_end_osc iterm2_preexec_install iterm2_preexec_invoke_cmd iterm2_preexec_invoke_exec iterm2_print_state_data iterm2_print_user_vars iterm2_print_version_number iterm2_prompt_mark iterm2_prompt_prefix iterm2_prompt_suffix iterm2_set_user_var kill-script list-available-locales lock lsp mang manx manxg mkcd mktempfile npmf npml pathToClipboard pbpaste_html pbpaste_rtf pifs precmd preexec pushdX pv ql resetcolors resume-script sl stripColors stripFormatting suspend-script tc tobin todec tohex tooct trim typex up vmrun vo" declare -x _system_arch="x86_64" declare -x _system_name="OSX" declare -x _system_type="Darwin" declare -x _system_version="10.12" declare -- hist_ent=" 502 . pg; doIt() { echo \"\$\$: [\$*]\"; }; { echo hi; echo there; echo you; echo too; } | env_parallel -n 1 -j 12 doIt {} 2>&1 | vo" declare -- iterm2_hostname="MkiMac.home" declare -- iterm2_ran_preexec="yes" declare -- last_hist_ent=" 502 . pg; doIt() { echo \"\$\$: [\$*]\"; }; { echo hi; echo there; echo you; echo too; } | env_parallel -n 1 -j 12 doIt {} 2>&1 | vo" declare -x rvm_bin_path="/Users/jdoe/.rvm/bin" declare -x rvm_path="/Users/jdoe/.rvm" declare -x rvm_prefix="/Users/jdoe" declare -x rvm_version="1.29.1 (latest)" = () { =perl "$@" } =awk () { local awkBin=${FUNCNAME[1]}; awkBin=${awkBin:-$FUNCNAME}; awkBin=${awkBin#=}; $awkBin "BEGIN { print $* }" } =gawk () { =awk "$@" } =mawk () { =awk "$@" } =perl () { [[ $1 == '-h' || $1 == '--help' ]] && { echo 'Simple command-line calcuations using Perl - the expression specfied is passed as-is to Perl'\''s `print`. Examples: =perl 0x41 =perl 2**10'; return 0 }; perl -le "print $*" } _PS1 () { local pre= name="$PWD" length="$1"; if (( length > 0 )); then [[ "$name" != "${name#$HOME/}" || -z "${name#$HOME}" ]] && pre+='~' name="${name#$HOME}" length=$[length-1]; ((${#name}>$length)) && name="/...${name:$[${#name}-length+4]}"; fi; printf '%s' "$pre$name" } __git_aliased_command () { local word cmdline=$(git --git-dir="$(__gitdir)" config --get "alias.$1"); for word in $cmdline; do case "$word" in \!gitk | gitk) echo "gitk"; return ;; \!*) : shell command alias ;; -*) : option ;; *=*) : setting env ;; git) : git itself ;; \(\)) : skip parens of shell function definition ;; {) : skip start of shell helper function ;; :) : skip null command ;; \'*) : skip opening quote after sh -c ;; *) echo "$word"; return ;; esac; done } __git_aliases () { local i IFS=' '; for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do case "$i" in alias.*) i="${i#alias.}"; echo "${i/ */}" ;; esac; done } __git_commands () { if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}"; then printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"; else git help -a | egrep '^ [a-zA-Z0-9]'; fi } __git_complete () { local wrapper="__git_wrap${2}"; eval "$wrapper () { __git_func_wrap $2 ; }"; complete -o bashdefault -o default -o nospace -F $wrapper $1 2> /dev/null || complete -o default -o nospace -F $wrapper $1 } __git_complete_file () { __git_complete_revlist_file } __git_complete_force_with_lease () { local cur_=$1; case "$cur_" in --*=) ;; *:*) __gitcomp_nl "$(__git_refs)" "" "${cur_#*:}" ;; *) __gitcomp_nl "$(__git_refs)" "" "$cur_" ;; esac } __git_complete_index_file () { local pfx="" cur_="$cur"; case "$cur_" in ?*/*) pfx="${cur_%/*}"; cur_="${cur_##*/}"; pfx="${pfx}/" ;; esac; __gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_" } __git_complete_remote_or_refspec () { local cur_="$cur" cmd="${words[1]}"; local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0; if [ "$cmd" = "remote" ]; then ((c++)); fi; while [ $c -lt $cword ]; do i="${words[c]}"; case "$i" in --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;; --all) case "$cmd" in push) no_complete_refspec=1 ;; fetch) return ;; *) ;; esac ;; -*) ;; *) remote="$i"; break ;; esac; ((c++)); done; if [ -z "$remote" ]; then __gitcomp_nl "$(__git_remotes)"; return; fi; if [ $no_complete_refspec = 1 ]; then return; fi; [ "$remote" = "." ] && remote=; case "$cur_" in *:*) case "$COMP_WORDBREAKS" in *:*) : great ;; *) pfx="${cur_%%:*}:" ;; esac; cur_="${cur_#*:}"; lhs=0 ;; +*) pfx="+"; cur_="${cur_#+}" ;; esac; case "$cmd" in fetch) if [ $lhs = 1 ]; then __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"; else __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"; fi ;; pull | remote) if [ $lhs = 1 ]; then __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"; else __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"; fi ;; push) if [ $lhs = 1 ]; then __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"; else __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"; fi ;; esac } __git_complete_revlist () { __git_complete_revlist_file } __git_complete_revlist_file () { local pfx ls ref cur_="$cur"; case "$cur_" in *..?*:*) return ;; ?*:*) ref="${cur_%%:*}"; cur_="${cur_#*:}"; case "$cur_" in ?*/*) pfx="${cur_%/*}"; cur_="${cur_##*/}"; ls="$ref:$pfx"; pfx="$pfx/" ;; *) ls="$ref" ;; esac; case "$COMP_WORDBREAKS" in *:*) : great ;; *) pfx="$ref:$pfx" ;; esac; __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" 2>/dev/null | sed '/^100... blob /{ s,^.* ,, s,$, , } /^120000 blob /{ s,^.* ,, s,$, , } /^040000 tree /{ s,^.* ,, s,$,/, } s/^.* //')" "$pfx" "$cur_" "" ;; *...*) pfx="${cur_%...*}..."; cur_="${cur_#*...}"; __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" ;; *..*) pfx="${cur_%..*}.."; cur_="${cur_#*..}"; __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" ;; *) __gitcomp_nl "$(__git_refs)" ;; esac } __git_complete_strategy () { __git_compute_merge_strategies; case "$prev" in -s | --strategy) __gitcomp "$__git_merge_strategies"; return 0 ;; esac; case "$cur" in --strategy=*) __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"; return 0 ;; esac; return 1 } __git_compute_all_commands () { test -n "$__git_all_commands" || __git_all_commands=$(__git_list_all_commands) } __git_compute_merge_strategies () { test -n "$__git_merge_strategies" || __git_merge_strategies=$(__git_list_merge_strategies) } __git_compute_porcelain_commands () { __git_compute_all_commands; test -n "$__git_porcelain_commands" || __git_porcelain_commands=$(__git_list_porcelain_commands) } __git_config_get_set_variables () { local prevword word config_file= c=$cword; while [ $c -gt 1 ]; do word="${words[c]}"; case "$word" in --system | --global | --local | --file=*) config_file="$word"; break ;; -f | --file) config_file="$word $prevword"; break ;; esac; prevword=$word; c=$((--c)); done; git --git-dir="$(__gitdir)" config $config_file --list 2> /dev/null | while read -r line; do case "$line" in *.*=*) echo "${line/=*/}" ;; esac; done } __git_count_arguments () { local word i c=0; for ((i=1; i < ${#words[@]}; i++)) do word="${words[i]}"; case "$word" in --) ((c = 0)) ;; "$1") ((c = 0)) ;; ?*) ((c++)) ;; esac; done; printf "%d" $c } __git_find_on_cmdline () { local word subcommand c=1; while [ $c -lt $cword ]; do word="${words[c]}"; for subcommand in $1; do if [ "$subcommand" = "$word" ]; then echo "$subcommand"; return; fi; done; ((c++)); done } __git_flow_config () { local subcommands="list set base"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in set) case "$cur" in --*) __gitcomp " $__git_flow_config_file_options "; return ;; esac; __gitcomp " master develop feature hotfix release support versiontagprefix "; return ;; base) case "$cur" in --*) __gitcomp " set get "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches)"; return ;; *) COMPREPLY=() ;; esac } __git_flow_feature () { local subcommands="list start finish publish track diff rebase checkout pull help delete"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in pull) __gitcomp_nl "$(__git_remotes)"; return ;; checkout) __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; delete) case "$cur" in --*) __gitcomp " --noforce --force --noremote --remote "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; finish) case "$cur" in --*) __gitcomp " --nofetch --fetch --norebase --rebase --nopreserve-merges --preserve-merges --nokeep --keep --keepremote --keeplocal --noforce_delete --force_delete --nosquash --squash --no-ff "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; diff) __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; publish) __gitcomp_nl "$(__git_flow_list_branches 'feature')"; return ;; track) __gitcomp_nl "$(__git_flow_list_branches 'feature')"; return ;; *) COMPREPLY=() ;; esac } __git_flow_hotfix () { local subcommands="list start finish track publish help delete"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in finish) case "$cur" in --*) __gitcomp " --nofetch --fetch --sign --signingkey --message --nomessagefile --messagefile= --nopush --push --nokeep --keep --keepremote --keeplocal --noforce_delete --force_delete --notag --tag --nonobackmerge --nobackmerge "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"; return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"; return ;; delete) case "$cur" in --*) __gitcomp " --noforce --force --noremote --remote "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"; return ;; publish) __gitcomp_nl "$(__git_flow_list_branches 'hotfix')"; return ;; track) __gitcomp_nl "$(__git_flow_list_branches 'hotfix')"; return ;; start) case "$cur" in --*) __gitcomp " --nofetch --fetch "; return ;; esac; return ;; *) COMPREPLY=() ;; esac } __git_flow_init () { local subcommands="help"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; fi; case "$cur" in --*) __gitcomp " --nodefaults --defaults --noforce --force $__git_flow_config_file_options "; return ;; esac } __git_flow_list_branches () { local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"; if [ -n "$1" ]; then local prefix="$(__git_flow_prefix $1)"; git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix | while read -r entry; do eval "$entry"; ref="${ref##$prefix}"; echo "$ref"; done | sort; else git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort; fi } __git_flow_list_local_branches () { if [ -n "$1" ]; then local prefix="$(__git_flow_prefix $1)"; git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix | while read -r entry; do eval "$entry"; ref="${ref#$prefix}"; echo "$ref"; done | sort; else git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort; fi } __git_flow_list_remote_branches () { local prefix="$(__git_flow_prefix $1)"; local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"; git for-each-ref --shell --format='%(refname:short)' refs/remotes/$origin/$prefix | while read -r entry; do eval "$entry"; ref="${ref##$prefix}"; echo "$ref"; done | sort } __git_flow_prefix () { case "$1" in feature | release | hotfix | support) git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/"; return ;; esac } __git_flow_release () { local subcommands="list start finish track publish help delete"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in finish) case "$cur" in --*) __gitcomp " --nofetch --fetch --sign --signingkey --message --nomessagefile --messagefile= --nopush --push --nokeep --keep --keepremote --keeplocal --noforce_delete --force_delete --notag --tag --nonobackmerge --nobackmerge --nosquash --squash "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'release')"; return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'release')"; return ;; delete) case "$cur" in --*) __gitcomp " --noforce --force --noremote --remote "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'release')"; return ;; publish) __gitcomp_nl "$(__git_flow_list_branches 'release')"; return ;; track) __gitcomp_nl "$(__git_flow_list_branches 'release')"; return ;; start) case "$cur" in --*) __gitcomp " --nofetch --fetch "; return ;; esac; return ;; *) COMPREPLY=() ;; esac } __git_flow_support () { local subcommands="list start help"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in start) case "$cur" in --*) __gitcomp " --nofetch --fetch "; return ;; esac; return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'support')"; return ;; *) COMPREPLY=() ;; esac } __git_func_wrap () { local cur words cword prev; _get_comp_words_by_ref -n =: cur words cword prev; $1 } __git_has_doubledash () { local c=1; while [ $c -lt $cword ]; do if [ "--" = "${words[c]}" ]; then return 0; fi; ((c++)); done; return 1 } __git_heads () { local dir="$(__gitdir)"; if [ -d "$dir" ]; then git --git-dir="$dir" for-each-ref --format='%(refname:short)' refs/heads; return; fi } __git_index_files () { local dir="$(__gitdir)" root="${2-.}" file; if [ -d "$dir" ]; then __git_ls_files_helper "$root" "$1" | while read -r file; do case "$file" in ?*/*) echo "${file%%/*}" ;; *) echo "$file" ;; esac; done | sort | uniq; fi } __git_list_all_commands () { local i IFS=" "' '; for i in $(__git_commands); do case $i in *--*) : helper pattern ;; *) echo $i ;; esac; done } __git_list_merge_strategies () { git merge -s help 2>&1 | sed -n -e '/[Aa]vailable strategies are: /,/^$/{ s/\.$// s/.*:// s/^[ ]*// s/[ ]*$// p }' } __git_list_porcelain_commands () { local i IFS=" "' '; __git_compute_all_commands; for i in $__git_all_commands; do case $i in *--*) : helper pattern ;; applymbox) : ask gittus ;; applypatch) : ask gittus ;; archimport) : import ;; cat-file) : plumbing ;; check-attr) : plumbing ;; check-ignore) : plumbing ;; check-mailmap) : plumbing ;; check-ref-format) : plumbing ;; checkout-index) : plumbing ;; commit-tree) : plumbing ;; count-objects) : infrequent ;; credential-cache) : credentials helper ;; credential-store) : credentials helper ;; cvsexportcommit) : export ;; cvsimport) : import ;; cvsserver) : daemon ;; daemon) : daemon ;; diff-files) : plumbing ;; diff-index) : plumbing ;; diff-tree) : plumbing ;; fast-import) : import ;; fast-export) : export ;; fsck-objects) : plumbing ;; fetch-pack) : plumbing ;; fmt-merge-msg) : plumbing ;; for-each-ref) : plumbing ;; hash-object) : plumbing ;; http-*) : transport ;; index-pack) : plumbing ;; init-db) : deprecated ;; local-fetch) : plumbing ;; ls-files) : plumbing ;; ls-remote) : plumbing ;; ls-tree) : plumbing ;; mailinfo) : plumbing ;; mailsplit) : plumbing ;; merge-*) : plumbing ;; mktree) : plumbing ;; mktag) : plumbing ;; pack-objects) : plumbing ;; pack-redundant) : plumbing ;; pack-refs) : plumbing ;; parse-remote) : plumbing ;; patch-id) : plumbing ;; prune) : plumbing ;; prune-packed) : plumbing ;; quiltimport) : import ;; read-tree) : plumbing ;; receive-pack) : plumbing ;; remote-*) : transport ;; rerere) : plumbing ;; rev-list) : plumbing ;; rev-parse) : plumbing ;; runstatus) : plumbing ;; sh-setup) : internal ;; shell) : daemon ;; show-ref) : plumbing ;; send-pack) : plumbing ;; show-index) : plumbing ;; ssh-*) : transport ;; stripspace) : plumbing ;; symbolic-ref) : plumbing ;; unpack-file) : plumbing ;; unpack-objects) : plumbing ;; update-index) : plumbing ;; update-ref) : plumbing ;; update-server-info) : daemon ;; upload-archive) : plumbing ;; upload-pack) : plumbing ;; write-tree) : plumbing ;; var) : infrequent ;; verify-pack) : infrequent ;; verify-tag) : plumbing ;; *) echo $i ;; esac; done } __git_ls_files_helper () { ( test -n "${CDPATH+set}" && unset CDPATH; cd "$1"; if [ "$2" == "--committable" ]; then git diff-index --name-only --relative HEAD; else git ls-files --exclude-standard $2; fi ) 2> /dev/null } __git_main () { local i c=1 command __git_dir; while [ $c -lt $cword ]; do i="${words[c]}"; case "$i" in --git-dir=*) __git_dir="${i#--git-dir=}" ;; --git-dir) ((c++)); __git_dir="${words[c]}" ;; --bare) __git_dir="." ;; --help) command="help"; break ;; -c | --work-tree | --namespace) ((c++)) ;; -*) ;; *) command="$i"; break ;; esac; ((c++)); done; if [ -z "$command" ]; then case "$cur" in --*) __gitcomp " --paginate --no-pager --git-dir= --bare --version --exec-path --exec-path= --html-path --man-path --info-path --work-tree= --namespace= --no-replace-objects --help " ;; *) __git_compute_porcelain_commands; __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;; esac; return; fi; local completion_func="_git_${command//-/_}"; declare -f $completion_func > /dev/null && $completion_func && return; local expansion=$(__git_aliased_command "$command"); if [ -n "$expansion" ]; then words[1]=$expansion; completion_func="_git_${expansion//-/_}"; declare -f $completion_func > /dev/null && $completion_func; fi } __git_match_ctag () { awk "/^${1////\\/}/ { print \$1 }" "$2" } __git_pretty_aliases () { local i IFS=' '; for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do case "$i" in pretty.*) i="${i#pretty.}"; echo "${i/ */}" ;; esac; done } __git_reassemble_comp_words_by_ref () { local exclude i j first; exclude="${1//[^$COMP_WORDBREAKS]}"; cword_=$COMP_CWORD; if [ -z "$exclude" ]; then words_=("${COMP_WORDS[@]}"); return; fi; for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)) do first=t; while [ $i -gt 0 ] && [ -n "${COMP_WORDS[$i]}" ] && [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]; do if [ $j -ge 2 ] && [ -n "$first" ]; then ((j--)); fi; first=; words_[$j]=${words_[j]}${COMP_WORDS[i]}; if [ $i = $COMP_CWORD ]; then cword_=$j; fi; if (($i < ${#COMP_WORDS[@]} - 1)); then ((i++)); else return; fi; done; words_[$j]=${words_[j]}${COMP_WORDS[i]}; if [ $i = $COMP_CWORD ]; then cword_=$j; fi; done } __git_refs () { local i hash dir="$(__gitdir "${1-}")" track="${2-}"; local format refs; if [ -d "$dir" ]; then case "$cur" in refs | refs/*) format="refname"; refs="${cur%/*}"; track="" ;; *) for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do if [ -e "$dir/$i" ]; then echo $i; fi; done; format="refname:short"; refs="refs/tags refs/heads refs/remotes" ;; esac; git --git-dir="$dir" for-each-ref --format="%($format)" $refs; if [ -n "$track" ]; then local ref entry; git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" "refs/remotes/" | while read -r entry; do eval "$entry"; ref="${ref#*/}"; if [[ "$ref" == "$cur"* ]]; then echo "$ref"; fi; done | sort | uniq -u; fi; return; fi; case "$cur" in refs | refs/*) git ls-remote "$dir" "$cur*" 2> /dev/null | while read -r hash i; do case "$i" in *^{}) ;; *) echo "$i" ;; esac; done ;; *) echo "HEAD"; git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##" ;; esac } __git_refs2 () { local i; for i in $(__git_refs "$1"); do echo "$i:$i"; done } __git_refs_remotes () { local i hash; git ls-remote "$1" 'refs/heads/*' 2> /dev/null | while read -r hash i; do echo "$i:refs/remotes/$1/${i#refs/heads/}"; done } __git_remotes () { local i IFS=' ' d="$(__gitdir)"; test -d "$d/remotes" && ls -1 "$d/remotes"; for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do i="${i#remote.}"; echo "${i/.url*/}"; done } __git_tags () { local dir="$(__gitdir)"; if [ -d "$dir" ]; then git --git-dir="$dir" for-each-ref --format='%(refname:short)' refs/tags; return; fi } __git_wrap__git_main () { __git_func_wrap __git_main } __git_wrap__gitk_main () { __git_func_wrap __gitk_main } __gitcomp () { local cur_="${3-$cur}"; case "$cur_" in --*=) ;; *) local c i=0 IFS=' '; for c in $1; do c="$c${4-}"; if [[ $c == "$cur_"* ]]; then case $c in --*=* | *.) ;; *) c="$c " ;; esac; COMPREPLY[i++]="${2-}$c"; fi; done ;; esac } __gitcomp_file () { local IFS=' '; __gitcompadd "$1" "${2-}" "${3-$cur}" ""; compopt -o filenames +o nospace 2> /dev/null || compgen -f /non-existing-dir/ > /dev/null } __gitcomp_nl () { COMPREPLY=(); __gitcomp_nl_append "$@" } __gitcomp_nl_append () { local IFS=' '; __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }" } __gitcompadd () { COMPREPLY=(); __gitcompappend "$@" } __gitcompappend () { local i=${#COMPREPLY[@]}; for x in $1; do if [[ "$x" == "$3"* ]]; then COMPREPLY[i++]="$2$x$4"; fi; done } __gitdir () { if [ -z "${1-}" ]; then if [ -n "${__git_dir-}" ]; then echo "$__git_dir"; else if [ -n "${GIT_DIR-}" ]; then test -d "${GIT_DIR-}" || return 1; echo "$GIT_DIR"; else if [ -d .git ]; then echo .git; else git rev-parse --git-dir 2> /dev/null; fi; fi; fi; else if [ -d "$1/.git" ]; then echo "$1/.git"; else echo "$1"; fi; fi } __gitk_main () { __git_has_doubledash && return; local g="$(__gitdir)"; local merge=""; if [ -f "$g/MERGE_HEAD" ]; then merge="--merge"; fi; case "$cur" in --*) __gitcomp " $__git_log_common_options $__git_log_gitk_options $merge "; return ;; esac; __git_complete_revlist } __typex_isParentSupportedShell () { case "$(command basename -- "$(command ps -o comm= $PPID | command sed 's/^-//')")" in bash | ksh | zsh) return 0 ;; esac; return 1 } __typex_isSupportedShell () { [ -n "$BASH_VERSION" ] && return 0; [ -n "$KSH_VERSION" ] && return 0; [ -n "$ZSH_VERSION" ] && return 0; return 1 } _complete_edits () { local util utils; local token=${COMP_WORDS[$COMP_CWORD]}; local tokenLen=${#token}; if [[ $(uname) == 'Darwin' ]]; then IFS=' ' read -d '' -ra utils < <(find "$MK_UTIL_FOLDER" "$MK_UTIL_FOLDER/sourced.d" -type f -perm -a=x -exec basename -a {} +); else IFS=' ' read -d '' -ra utils < <(find "$MK_UTIL_FOLDER" "$MK_UTIL_FOLDER/sourced.d" -type f -perm -a=x -printf '%f\n'); fi; local nocasematchWasOff=0; shopt nocasematch > /dev/null || nocasematchWasOff=1; (( nocasematchWasOff )) && shopt -s nocasematch; COMPREPLY=(); for util in "${utils[@]}"; do if [[ ${util:0:$(( tokenLen ))} == "$token" ]]; then COMPREPLY+=("$(printf '%q' "$util")"); fi; done; (( nocasematchWasOff )) && shopt -u nocasematch } _complete_lx () { local localExeDir='.'; local token=${COMP_WORDS[$COMP_CWORD]}; local tokenLen=${#token}; if [[ $(uname) == 'Darwin' ]]; then IFS=' ' read -d '' -ra localExes < <(find "$localExeDir" -maxdepth 1 -type f -perm -a=x -exec basename -a {} +); else IFS=' ' read -d '' -ra localExes < <(find "$localExeDir" -maxdepth 1 -type f -executable -printf '%f\n'); fi; local nocasematchWasOff=0; shopt nocasematch > /dev/null || nocasematchWasOff=1; (( nocasematchWasOff )) && shopt -s nocasematch; COMPREPLY=(); for localExe in "${localExes[@]}"; do if [[ ${localExe:0:$(( tokenLen ))} == "$token" ]]; then COMPREPLY+=("$(printf '%q' "$localExe")"); fi; done; (( nocasematchWasOff )) && shopt -u nocasematch } _complete_make () { local token=${COMP_WORDS[$COMP_CWORD]}; local targets=$(make -pRrq : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($1 !~ "^[#.]") {print $1}}' | egrep -v '^[^[:alnum:]]' | sort | xargs); COMPREPLY=($(compgen -W "$targets" -- "$token")) } _complete_pf () { COMPREPLY=($(compgen -A function -- "${COMP_WORDS[$COMP_CWORD]}")) } _complete_pv () { local varNames=$(compgen -v); local token=${COMP_WORDS[$COMP_CWORD]}; local mustReset=$(shopt -q nocasematch; echo $?); shopt -s nocasematch; [[ "${token:0:1}" == '$' ]] && token=${token:1}; local matches w; matches=(); if [[ -n $token ]]; then for w in $varNames; do if [[ "$w" == "$token"* ]]; then matches+=("$w"); fi; done; else matches=($varNames); fi; (( mustReset )) && shopt -u nocasematch; COMPREPLY=("${matches[@]}") } _complete_unset () { local token=${COMP_WORDS[$COMP_CWORD]}; local funcAndVarNames=$(compgen -A function; compgen -A variable); local mustReset=$(shopt -q nocasematch; echo $?); shopt -s nocasematch; [[ "${token:0:1}" == '$' ]] && token=${token:1}; local matches w; matches=(); if [[ -n $token ]]; then for w in $funcAndVarNames; do if [[ "$w" == "$token"* ]]; then matches+=("$w"); fi; done; else matches=($funcAndVarNames); fi; (( mustReset )) && shopt -u nocasematch; COMPREPLY=("${matches[@]}") } _complete_up () { COMPREPLY=(); local curToken=${COMP_WORDS[COMP_CWORD]}; curToken=${curToken//'\'}; if [[ $curToken =~ ^/ ]]; then local IFS=' '; COMPREPLY=($(compgen -o dirnames -- "$curToken")); else if [[ $curToken =~ ^[0-9]+/? ]]; then local strpath=$( printf "%${curToken%%/*}s" ); local upDirSpec=${strpath// /../}; local dir=$(cd "$upDirSpec"; echo -n "$PWD/"); if [[ "$dir" == '//' ]]; then dir='/'; fi; COMPREPLY=("$dir"); else local caseInsensitive=0; bind -v | egrep -i '\bcompletion-ignore-case[[:space:]]+on\b' &> /dev/null && caseInsensitive=1; local nocasematchWasOff=0; if (( caseInsensitive )); then nocasematchWasOff=1; shopt nocasematch > /dev/null && nocasematchWasOff=0; (( nocasematchWasOff )) && shopt -s nocasematch > /dev/null; fi; local pathSoFar=''; local matchingPath=''; local parentPath=${PWD%/*}; local IFS='/'; local name; for name in ${parentPath:1}; do pathSoFar+=/$name; if [[ "$name" == "$curToken"* ]]; then matchingPath="$pathSoFar/"; fi; done; (( caseInsensitive && nocasematchWasOff )) && shopt -u nocasematch > /dev/null; [[ -n "$matchingPath" ]] && COMPREPLY=("$matchingPath"); fi; fi } _get_comp_words_by_ref () { local exclude cur_ words_ cword_; if [ "$1" = "-n" ]; then exclude=$2; shift 2; fi; __git_reassemble_comp_words_by_ref "$exclude"; cur_=${words_[cword_]}; while [ $# -gt 0 ]; do case "$1" in cur) cur=$cur_ ;; prev) prev=${words_[$cword_-1]} ;; words) words=("${words_[@]}") ;; cword) cword=$cword_ ;; esac; shift; done } _git () { __git_wrap__git_main } _git_add () { case "$cur" in --*) __gitcomp " --interactive --refresh --patch --update --dry-run --ignore-errors --intent-to-add "; return ;; esac; __git_complete_index_file "--others --modified --directory --no-empty-directory" } _git_am () { local dir="$(__gitdir)"; if [ -d "$dir"/rebase-apply ]; then __gitcomp "--skip --continue --resolved --abort"; return; fi; case "$cur" in --whitespace=*) __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"; return ;; --*) __gitcomp " --3way --committer-date-is-author-date --ignore-date --ignore-whitespace --ignore-space-change --interactive --keep --no-utf8 --signoff --utf8 --whitespace= --scissors "; return ;; esac } _git_apply () { case "$cur" in --whitespace=*) __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"; return ;; --*) __gitcomp " --stat --numstat --summary --check --index --cached --index-info --reverse --reject --unidiff-zero --apply --no-add --exclude= --ignore-whitespace --ignore-space-change --whitespace= --inaccurate-eof --verbose "; return ;; esac } _git_archive () { case "$cur" in --format=*) __gitcomp "$(git archive --list)" "" "${cur##--format=}"; return ;; --remote=*) __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"; return ;; --*) __gitcomp " --format= --list --verbose --prefix= --remote= --exec= "; return ;; esac; __git_complete_file } _git_bisect () { __git_has_doubledash && return; local subcommands="start bad good skip reset visualize replay log run"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then if [ -f "$(__gitdir)"/BISECT_START ]; then __gitcomp "$subcommands"; else __gitcomp "replay start"; fi; return; fi; case "$subcommand" in bad | good | reset | skip | start) __gitcomp_nl "$(__git_refs)" ;; *) ;; esac } _git_branch () { local i c=1 only_local_ref="n" has_r="n"; while [ $c -lt $cword ]; do i="${words[c]}"; case "$i" in -d | -m) only_local_ref="y" ;; -r) has_r="y" ;; esac; ((c++)); done; case "$cur" in --set-upstream-to=*) __gitcomp "$(__git_refs)" "" "${cur##--set-upstream-to=}" ;; --*) __gitcomp " --color --no-color --verbose --abbrev= --no-abbrev --track --no-track --contains --merged --no-merged --set-upstream-to= --edit-description --list --unset-upstream " ;; *) if [ $only_local_ref = "y" -a $has_r = "n" ]; then __gitcomp_nl "$(__git_heads)"; else __gitcomp_nl "$(__git_refs)"; fi ;; esac } _git_bundle () { local cmd="${words[2]}"; case "$cword" in 2) __gitcomp "create list-heads verify unbundle" ;; 3) ;; *) case "$cmd" in create) __git_complete_revlist ;; esac ;; esac } _git_checkout () { __git_has_doubledash && return; case "$cur" in --conflict=*) __gitcomp "diff3 merge" "" "${cur##--conflict=}" ;; --*) __gitcomp " --quiet --ours --theirs --track --no-track --merge --conflict= --orphan --patch " ;; *) local flags="--track --no-track --no-guess" track=1; if [ -n "$(__git_find_on_cmdline "$flags")" ]; then track=''; fi; __gitcomp_nl "$(__git_refs '' $track)" ;; esac } _git_cherry () { __gitcomp "$(__git_refs)" } _git_cherry_pick () { local dir="$(__gitdir)"; if [ -f "$dir"/CHERRY_PICK_HEAD ]; then __gitcomp "--continue --quit --abort"; return; fi; case "$cur" in --*) __gitcomp "--edit --no-commit --signoff --strategy= --mainline" ;; *) __gitcomp_nl "$(__git_refs)" ;; esac } _git_clean () { case "$cur" in --*) __gitcomp "--dry-run --quiet"; return ;; esac; __git_complete_index_file "--others --directory" } _git_clone () { case "$cur" in --*) __gitcomp " --local --no-hardlinks --shared --reference --quiet --no-checkout --bare --mirror --origin --upload-pack --template= --depth --single-branch --branch "; return ;; esac } _git_commit () { case "$prev" in -c | -C) __gitcomp_nl "$(__git_refs)" "" "${cur}"; return ;; esac; case "$cur" in --cleanup=*) __gitcomp "default strip verbatim whitespace " "" "${cur##--cleanup=}"; return ;; --reuse-message=* | --reedit-message=* | --fixup=* | --squash=*) __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"; return ;; --untracked-files=*) __gitcomp "all no normal" "" "${cur##--untracked-files=}"; return ;; --*) __gitcomp " --all --author= --signoff --verify --no-verify --edit --no-edit --amend --include --only --interactive --dry-run --reuse-message= --reedit-message= --reset-author --file= --message= --template= --cleanup= --untracked-files --untracked-files= --verbose --quiet --fixup= --squash= "; return ;; esac; if git rev-parse --verify --quiet HEAD > /dev/null; then __git_complete_index_file "--committable"; else __git_complete_index_file "--cached"; fi } _git_config () { case "$prev" in branch.*.remote | branch.*.pushremote) __gitcomp_nl "$(__git_remotes)"; return ;; branch.*.merge) __gitcomp_nl "$(__git_refs)"; return ;; branch.*.rebase) __gitcomp "false true"; return ;; remote.pushdefault) __gitcomp_nl "$(__git_remotes)"; return ;; remote.*.fetch) local remote="${prev#remote.}"; remote="${remote%.fetch}"; if [ -z "$cur" ]; then __gitcomp_nl "refs/heads/" "" "" ""; return; fi; __gitcomp_nl "$(__git_refs_remotes "$remote")"; return ;; remote.*.push) local remote="${prev#remote.}"; remote="${remote%.push}"; __gitcomp_nl "$(git --git-dir="$(__gitdir)" for-each-ref --format='%(refname):%(refname)' refs/heads)"; return ;; pull.twohead | pull.octopus) __git_compute_merge_strategies; __gitcomp "$__git_merge_strategies"; return ;; color.branch | color.diff | color.interactive | color.showbranch | color.status | color.ui) __gitcomp "always never auto"; return ;; color.pager) __gitcomp "false true"; return ;; color.*.*) __gitcomp " normal black red green yellow blue magenta cyan white bold dim ul blink reverse "; return ;; diff.submodule) __gitcomp "log short"; return ;; help.format) __gitcomp "man info web html"; return ;; log.date) __gitcomp "$__git_log_date_formats"; return ;; sendemail.aliasesfiletype) __gitcomp "mutt mailrc pine elm gnus"; return ;; sendemail.confirm) __gitcomp "$__git_send_email_confirm_options"; return ;; sendemail.suppresscc) __gitcomp "$__git_send_email_suppresscc_options"; return ;; --get | --get-all | --unset | --unset-all) __gitcomp_nl "$(__git_config_get_set_variables)"; return ;; *.*) return ;; esac; case "$cur" in --*) __gitcomp " --system --global --local --file= --list --replace-all --get --get-all --get-regexp --add --unset --unset-all --remove-section --rename-section "; return ;; branch.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_"; return ;; branch.*) local pfx="${cur%.*}." cur_="${cur#*.}"; __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."; __gitcomp_nl_append 'autosetupmerge autosetuprebase ' "$pfx" "$cur_"; return ;; guitool.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp " argprompt cmd confirm needsfile noconsole norescan prompt revprompt revunmerged title " "$pfx" "$cur_"; return ;; difftool.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "cmd path" "$pfx" "$cur_"; return ;; man.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "cmd path" "$pfx" "$cur_"; return ;; mergetool.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"; return ;; pager.*) local pfx="${cur%.*}." cur_="${cur#*.}"; __git_compute_all_commands; __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"; return ;; remote.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp " url proxy fetch push mirror skipDefaultUpdate receivepack uploadpack tagopt pushurl " "$pfx" "$cur_"; return ;; remote.*) local pfx="${cur%.*}." cur_="${cur#*.}"; __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."; __gitcomp_nl_append "pushdefault" "$pfx" "$cur_"; return ;; url.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"; return ;; esac; __gitcomp " add.ignoreErrors advice.commitBeforeMerge advice.detachedHead advice.implicitIdentity advice.pushNonFastForward advice.resolveConflict advice.statusHints alias. am.keepcr apply.ignorewhitespace apply.whitespace branch.autosetupmerge branch.autosetuprebase browser. clean.requireForce color.branch color.branch.current color.branch.local color.branch.plain color.branch.remote color.decorate.HEAD color.decorate.branch color.decorate.remoteBranch color.decorate.stash color.decorate.tag color.diff color.diff.commit color.diff.frag color.diff.func color.diff.meta color.diff.new color.diff.old color.diff.plain color.diff.whitespace color.grep color.grep.context color.grep.filename color.grep.function color.grep.linenumber color.grep.match color.grep.selected color.grep.separator color.interactive color.interactive.error color.interactive.header color.interactive.help color.interactive.prompt color.pager color.showbranch color.status color.status.added color.status.changed color.status.header color.status.nobranch color.status.untracked color.status.updated color.ui commit.status commit.template core.abbrev core.askpass core.attributesfile core.autocrlf core.bare core.bigFileThreshold core.compression core.createObject core.deltaBaseCacheLimit core.editor core.eol core.excludesfile core.fileMode core.fsyncobjectfiles core.gitProxy core.ignoreStat core.ignorecase core.logAllRefUpdates core.loosecompression core.notesRef core.packedGitLimit core.packedGitWindowSize core.pager core.preferSymlinkRefs core.preloadindex core.quotepath core.repositoryFormatVersion core.safecrlf core.sharedRepository core.sparseCheckout core.symlinks core.trustctime core.warnAmbiguousRefs core.whitespace core.worktree diff.autorefreshindex diff.external diff.ignoreSubmodules diff.mnemonicprefix diff.noprefix diff.renameLimit diff.renames diff.statGraphWidth diff.submodule diff.suppressBlankEmpty diff.tool diff.wordRegex diff.algorithm difftool. difftool.prompt fetch.recurseSubmodules fetch.unpackLimit format.attach format.cc format.coverLetter format.headers format.numbered format.pretty format.signature format.signoff format.subjectprefix format.suffix format.thread format.to gc. gc.aggressiveWindow gc.auto gc.autopacklimit gc.packrefs gc.pruneexpire gc.reflogexpire gc.reflogexpireunreachable gc.rerereresolved gc.rerereunresolved gitcvs.allbinary gitcvs.commitmsgannotation gitcvs.dbTableNamePrefix gitcvs.dbdriver gitcvs.dbname gitcvs.dbpass gitcvs.dbuser gitcvs.enabled gitcvs.logfile gitcvs.usecrlfattr guitool. gui.blamehistoryctx gui.commitmsgwidth gui.copyblamethreshold gui.diffcontext gui.encoding gui.fastcopyblame gui.matchtrackingbranch gui.newbranchtemplate gui.pruneduringfetch gui.spellingdictionary gui.trustmtime help.autocorrect help.browser help.format http.lowSpeedLimit http.lowSpeedTime http.maxRequests http.minSessions http.noEPSV http.postBuffer http.proxy http.sslCAInfo http.sslCAPath http.sslCert http.sslCertPasswordProtected http.sslKey http.sslVerify http.useragent i18n.commitEncoding i18n.logOutputEncoding imap.authMethod imap.folder imap.host imap.pass imap.port imap.preformattedHTML imap.sslverify imap.tunnel imap.user init.templatedir instaweb.browser instaweb.httpd instaweb.local instaweb.modulepath instaweb.port interactive.singlekey log.date log.decorate log.showroot mailmap.file man. man.viewer merge. merge.conflictstyle merge.log merge.renameLimit merge.renormalize merge.stat merge.tool merge.verbosity mergetool. mergetool.keepBackup mergetool.keepTemporaries mergetool.prompt notes.displayRef notes.rewrite. notes.rewrite.amend notes.rewrite.rebase notes.rewriteMode notes.rewriteRef pack.compression pack.deltaCacheLimit pack.deltaCacheSize pack.depth pack.indexVersion pack.packSizeLimit pack.threads pack.window pack.windowMemory pager. pretty. pull.octopus pull.twohead push.default rebase.autosquash rebase.stat receive.autogc receive.denyCurrentBranch receive.denyDeleteCurrent receive.denyDeletes receive.denyNonFastForwards receive.fsckObjects receive.unpackLimit receive.updateserverinfo remote.pushdefault remotes. repack.usedeltabaseoffset rerere.autoupdate rerere.enabled sendemail. sendemail.aliasesfile sendemail.aliasfiletype sendemail.bcc sendemail.cc sendemail.cccmd sendemail.chainreplyto sendemail.confirm sendemail.envelopesender sendemail.from sendemail.identity sendemail.multiedit sendemail.signedoffbycc sendemail.smtpdomain sendemail.smtpencryption sendemail.smtppass sendemail.smtpserver sendemail.smtpserveroption sendemail.smtpserverport sendemail.smtpuser sendemail.suppresscc sendemail.suppressfrom sendemail.thread sendemail.to sendemail.validate showbranch.default status.relativePaths status.showUntrackedFiles status.submodulesummary submodule. tar.umask transfer.unpackLimit url. user.email user.name user.signingkey web.browser branch. remote. " } _git_describe () { case "$cur" in --*) __gitcomp " --all --tags --contains --abbrev= --candidates= --exact-match --debug --long --match --always "; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_diff () { __git_has_doubledash && return; case "$cur" in --diff-algorithm=*) __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"; return ;; --*) __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex --base --ours --theirs --no-index $__git_diff_common_options "; return ;; esac; __git_complete_revlist_file } _git_difftool () { __git_has_doubledash && return; case "$cur" in --tool=*) __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"; return ;; --*) __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex --base --ours --theirs --no-renames --diff-filter= --find-copies-harder --relative --ignore-submodules --tool="; return ;; esac; __git_complete_revlist_file } _git_fetch () { case "$cur" in --recurse-submodules=*) __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"; return ;; --*) __gitcomp "$__git_fetch_options"; return ;; esac; __git_complete_remote_or_refspec } _git_flow () { local subcommands="init feature release hotfix support help version config finish delete publish rebase"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in init) __git_flow_init; return ;; feature) __git_flow_feature; return ;; release) __git_flow_release; return ;; hotfix) __git_flow_hotfix; return ;; support) __git_flow_support; return ;; config) __git_flow_config; return ;; *) COMPREPLY=() ;; esac } _git_format_patch () { case "$cur" in --thread=*) __gitcomp " deep shallow " "" "${cur##--thread=}"; return ;; --*) __gitcomp "$__git_format_patch_options"; return ;; esac; __git_complete_revlist } _git_fsck () { case "$cur" in --*) __gitcomp " --tags --root --unreachable --cache --no-reflogs --full --strict --verbose --lost-found "; return ;; esac } _git_gc () { case "$cur" in --*) __gitcomp "--prune --aggressive"; return ;; esac } _git_gitk () { _gitk } _git_grep () { __git_has_doubledash && return; case "$cur" in --*) __gitcomp " --cached --text --ignore-case --word-regexp --invert-match --full-name --line-number --extended-regexp --basic-regexp --fixed-strings --perl-regexp --files-with-matches --name-only --files-without-match --max-depth --count --and --or --not --all-match "; return ;; esac; case "$cword,$prev" in 2,* | *,-*) if test -r tags; then __gitcomp_nl "$(__git_match_ctag "$cur" tags)"; return; fi ;; esac; __gitcomp_nl "$(__git_refs)" } _git_help () { case "$cur" in --*) __gitcomp "--all --info --man --web"; return ;; esac; __git_compute_all_commands; __gitcomp "$__git_all_commands $(__git_aliases) attributes cli core-tutorial cvs-migration diffcore gitk glossary hooks ignore modules namespaces repository-layout tutorial tutorial-2 workflows " } _git_init () { case "$cur" in --shared=*) __gitcomp " false true umask group all world everybody " "" "${cur##--shared=}"; return ;; --*) __gitcomp "--quiet --bare --template= --shared --shared="; return ;; esac } _git_log () { __git_has_doubledash && return; local g="$(git rev-parse --git-dir 2>/dev/null)"; local merge=""; if [ -f "$g/MERGE_HEAD" ]; then merge="--merge"; fi; case "$cur" in --pretty=* | --format=*) __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) " "" "${cur#*=}"; return ;; --date=*) __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"; return ;; --decorate=*) __gitcomp "long short" "" "${cur##--decorate=}"; return ;; --*) __gitcomp " $__git_log_common_options $__git_log_shortlog_options $__git_log_gitk_options --root --topo-order --date-order --reverse --follow --full-diff --abbrev-commit --abbrev= --relative-date --date= --pretty= --format= --oneline --cherry-pick --graph --decorate --decorate= --walk-reflogs --parents --children $merge $__git_diff_common_options --pickaxe-all --pickaxe-regex "; return ;; esac; __git_complete_revlist } _git_ls_files () { case "$cur" in --*) __gitcomp "--cached --deleted --modified --others --ignored --stage --directory --no-empty-directory --unmerged --killed --exclude= --exclude-from= --exclude-per-directory= --exclude-standard --error-unmatch --with-tree= --full-name --abbrev --ignored --exclude-per-directory "; return ;; esac; __git_complete_index_file "--cached" } _git_ls_remote () { __gitcomp_nl "$(__git_remotes)" } _git_ls_tree () { __git_complete_file } _git_merge () { __git_complete_strategy && return; case "$cur" in --*) __gitcomp "$__git_merge_options --rerere-autoupdate --no-rerere-autoupdate --abort"; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_merge_base () { case "$cur" in --*) __gitcomp "--octopus --independent --is-ancestor --fork-point"; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_mergetool () { case "$cur" in --tool=*) __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"; return ;; --*) __gitcomp "--tool="; return ;; esac } _git_mv () { case "$cur" in --*) __gitcomp "--dry-run"; return ;; esac; if [ $(__git_count_arguments "mv") -gt 0 ]; then __git_complete_index_file "--cached --others --directory"; else __git_complete_index_file "--cached"; fi } _git_name_rev () { __gitcomp "--tags --all --stdin" } _git_notes () { local subcommands='add append copy edit list prune remove show'; local subcommand="$(__git_find_on_cmdline "$subcommands")"; case "$subcommand,$cur" in ,--*) __gitcomp '--ref' ;; ,*) case "$prev" in --ref) __gitcomp_nl "$(__git_refs)" ;; *) __gitcomp "$subcommands --ref" ;; esac ;; add,--reuse-message=* | append,--reuse-message=* | add,--reedit-message=* | append,--reedit-message=*) __gitcomp_nl "$(__git_refs)" "" "${cur#*=}" ;; add,--* | append,--*) __gitcomp '--file= --message= --reedit-message= --reuse-message=' ;; copy,--*) __gitcomp '--stdin' ;; prune,--*) __gitcomp '--dry-run --verbose' ;; prune,*) ;; *) case "$prev" in -m | -F) ;; *) __gitcomp_nl "$(__git_refs)" ;; esac ;; esac } _git_pull () { __git_complete_strategy && return; case "$cur" in --recurse-submodules=*) __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"; return ;; --*) __gitcomp " --rebase --no-rebase $__git_merge_options $__git_fetch_options "; return ;; esac; __git_complete_remote_or_refspec } _git_push () { case "$prev" in --repo) __gitcomp_nl "$(__git_remotes)"; return ;; --recurse-submodules) __gitcomp "$__git_push_recurse_submodules"; return ;; esac; case "$cur" in --repo=*) __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"; return ;; --recurse-submodules=*) __gitcomp "$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}"; return ;; --force-with-lease=*) __git_complete_force_with_lease "${cur##--force-with-lease=}"; return ;; --*) __gitcomp " --all --mirror --tags --dry-run --force --verbose --quiet --prune --delete --follow-tags --receive-pack= --repo= --set-upstream --force-with-lease --force-with-lease= --recurse-submodules= "; return ;; esac; __git_complete_remote_or_refspec } _git_rebase () { local dir="$(__gitdir)"; if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then __gitcomp "--continue --skip --abort"; return; fi; __git_complete_strategy && return; case "$cur" in --whitespace=*) __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"; return ;; --*) __gitcomp " --onto --merge --strategy --interactive --preserve-merges --stat --no-stat --committer-date-is-author-date --ignore-date --ignore-whitespace --whitespace= --autosquash --fork-point --no-fork-point "; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_reflog () { local subcommands="show delete expire"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; else __gitcomp_nl "$(__git_refs)"; fi } _git_remote () { local subcommands="add rename remove set-head set-branches set-url show prune update"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in rename | remove | set-url | show | prune) __gitcomp_nl "$(__git_remotes)" ;; set-head | set-branches) __git_complete_remote_or_refspec ;; update) local i c='' IFS=' '; for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do i="${i#remotes.}"; c="$c ${i/ */}"; done; __gitcomp "$c" ;; *) ;; esac } _git_replace () { __gitcomp_nl "$(__git_refs)" } _git_reset () { __git_has_doubledash && return; case "$cur" in --*) __gitcomp "--merge --mixed --hard --soft --patch"; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_revert () { case "$cur" in --*) __gitcomp "--edit --mainline --no-edit --no-commit --signoff"; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_rm () { case "$cur" in --*) __gitcomp "--cached --dry-run --ignore-unmatch --quiet"; return ;; esac; __git_complete_index_file "--cached" } _git_send_email () { case "$cur" in --confirm=*) __gitcomp " $__git_send_email_confirm_options " "" "${cur##--confirm=}"; return ;; --suppress-cc=*) __gitcomp " $__git_send_email_suppresscc_options " "" "${cur##--suppress-cc=}"; return ;; --smtp-encryption=*) __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"; return ;; --thread=*) __gitcomp " deep shallow " "" "${cur##--thread=}"; return ;; --*) __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to --compose --confirm= --dry-run --envelope-sender --from --identity --in-reply-to --no-chain-reply-to --no-signed-off-by-cc --no-suppress-from --no-thread --quiet --signed-off-by-cc --smtp-pass --smtp-server --smtp-server-port --smtp-encryption= --smtp-user --subject --suppress-cc= --suppress-from --thread --to --validate --no-validate $__git_format_patch_options"; return ;; esac; __git_complete_revlist } _git_shortlog () { __git_has_doubledash && return; case "$cur" in --*) __gitcomp " $__git_log_common_options $__git_log_shortlog_options --numbered --summary "; return ;; esac; __git_complete_revlist } _git_show () { __git_has_doubledash && return; case "$cur" in --pretty=* | --format=*) __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) " "" "${cur#*=}"; return ;; --diff-algorithm=*) __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"; return ;; --*) __gitcomp "--pretty= --format= --abbrev-commit --oneline $__git_diff_common_options "; return ;; esac; __git_complete_revlist_file } _git_show_branch () { case "$cur" in --*) __gitcomp " --all --remotes --topo-order --current --more= --list --independent --merge-base --no-name --color --no-color --sha1-name --sparse --topics --reflog "; return ;; esac; __git_complete_revlist } _git_stage () { _git_add } _git_stash () { local save_opts='--keep-index --no-keep-index --quiet --patch'; local subcommands='save list show apply clear drop pop create branch'; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then case "$cur" in --*) __gitcomp "$save_opts" ;; *) if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then __gitcomp "$subcommands"; fi ;; esac; else case "$subcommand,$cur" in save,--*) __gitcomp "$save_opts" ;; apply,--* | pop,--*) __gitcomp "--index --quiet" ;; show,--* | drop,--* | branch,--*) ;; show,* | apply,* | drop,* | pop,* | branch,*) __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list | sed -n -e 's/:.*//p')" ;; *) ;; esac; fi } _git_submodule () { __git_has_doubledash && return; local subcommands="add status init deinit update summary foreach sync"; if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then case "$cur" in --*) __gitcomp "--quiet --cached" ;; *) __gitcomp "$subcommands" ;; esac; return; fi } _git_svn () { local subcommands=" init fetch clone rebase dcommit log find-rev set-tree commit-diff info create-ignore propget proplist show-ignore show-externals branch tag blame migrate mkdirs reset gc "; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; else local remote_opts="--username= --config-dir= --no-auth-cache"; local fc_opts=" --follow-parent --authors-file= --repack= --no-metadata --use-svm-props --use-svnsync-props --log-window-size= --no-checkout --quiet --repack-flags --use-log-author --localtime --ignore-paths= --include-paths= $remote_opts "; local init_opts=" --template= --shared= --trunk= --tags= --branches= --stdlayout --minimize-url --no-metadata --use-svm-props --use-svnsync-props --rewrite-root= --prefix= --use-log-author --add-author-from $remote_opts "; local cmt_opts=" --edit --rmdir --find-copies-harder --copy-similarity= "; case "$subcommand,$cur" in fetch,--*) __gitcomp "--revision= --fetch-all $fc_opts" ;; clone,--*) __gitcomp "--revision= $fc_opts $init_opts" ;; init,--*) __gitcomp "$init_opts" ;; dcommit,--*) __gitcomp " --merge --strategy= --verbose --dry-run --fetch-all --no-rebase --commit-url --revision --interactive $cmt_opts $fc_opts " ;; set-tree,--*) __gitcomp "--stdin $cmt_opts $fc_opts" ;; create-ignore,--* | propget,--* | proplist,--* | show-ignore,--* | show-externals,--* | mkdirs,--*) __gitcomp "--revision=" ;; log,--*) __gitcomp " --limit= --revision= --verbose --incremental --oneline --show-commit --non-recursive --authors-file= --color " ;; rebase,--*) __gitcomp " --merge --verbose --strategy= --local --fetch-all --dry-run $fc_opts " ;; commit-diff,--*) __gitcomp "--message= --file= --revision= $cmt_opts" ;; info,--*) __gitcomp "--url" ;; branch,--*) __gitcomp "--dry-run --message --tag" ;; tag,--*) __gitcomp "--dry-run --message" ;; blame,--*) __gitcomp "--git-format" ;; migrate,--*) __gitcomp " --config-dir= --ignore-paths= --minimize --no-auth-cache --username= " ;; reset,--*) __gitcomp "--revision= --parent" ;; *) ;; esac; fi } _git_tag () { local i c=1 f=0; while [ $c -lt $cword ]; do i="${words[c]}"; case "$i" in -d | -v) __gitcomp_nl "$(__git_tags)"; return ;; -f) f=1 ;; esac; ((c++)); done; case "$prev" in -m | -F) ;; -* | tag) if [ $f = 1 ]; then __gitcomp_nl "$(__git_tags)"; fi ;; *) __gitcomp_nl "$(__git_refs)" ;; esac } _git_whatchanged () { _git_log } _gitk () { __git_wrap__gitk_main } _npm_completion () { local si="$IFS"; IFS=' ' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" COMP_LINE="$COMP_LINE" COMP_POINT="$COMP_POINT" npm completion -- "${COMP_WORDS[@]}" 2>/dev/null)) || return $?; IFS="$si" } _tobase () { local _outputBaseSpecChar=${outputBaseSpecChar:-d}; local n; for n in "$@"; do printf "%#${_outputBaseSpecChar}\n" $(( n )); done } af () { f "$@" } brm () { [[ $1 == '-h' || $1 == '--help' ]] && { echo 'Prints the contents of ${BASH_REMATCH[@]} in diagnostic form.'; return 0 }; (( $# )) && { echo 'ERROR: Unexpected parameter(s) specified. Use -h for help.' 1>&2; return 2 }; local i m; for m in "${BASH_REMATCH[@]}"; do echo "[$((i++))] = [$m]"; done } calc () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "usage: $FUNCNAME expression\n Evaluates the specified arithmetic expression using (( )) and prints the result.\n Useful for simple calculations and converting hex or oct numbers to decimals." && return 0; echo $(( $@ )) } cdp () { local CDPATH=~:~/Documents/Projects:~/Documents/Projects/OSS:~/Documents/Projects/AlfredWorkflows; builtin cd "$@" } de () { local a i=0; for a in "$@"; do printf '%s\n' "\$$((i+=1))=[$a]"; done } dfs () { df -hl | grep 'disk0s2' | awk '{print $4"/"$2" free ("$5" used)"}' } difs () { echo -n "$IFS" | od -a } doIt () { echo "$$: [$*]" } docker-start () { typeset vm=${1:-default} sts; case $vm in -h | --help) echo 'usage: docker-start [] Ensures that the specified/default Docker VM is started and the environment is initialized.'; return 0 ;; esac; sts=$(docker-machine status "$vm") || return; [[ $sts == 'Running' ]] && echo "(Docker VM '$vm' is already running.)" || { echo "-- Starting Docker VM '$vm' (\`docker-machine start "$vm"\`; this will take a while)..."; docker-machine start "$vm" || return }; echo "-- Setting DOCKER_* environment variables (\`eval \"\$(docker-machine env "$vm")\"\`)..."; eval "$(docker-machine env "$vm")" || return; export | grep -o 'DOCKER_.*'; echo "-- Docker VM '$vm' is running." } docker-stop () { typeset vm=${1:-default} sts envVarNames fndx; case $vm in -h | --help) echo 'usage: docker-stop [] Ensures that the specified/default Docker VM is stopped and the environment is cleaned up.'; return 0 ;; esac; sts=$(docker-machine status "$vm") || return; [[ $sts == 'Running' ]] && { echo "-- Stopping Docker VM '$vm' (\`docker-machine stop "$vm"\`)..."; docker-machine stop "$vm" || return } || echo "(Docker VM '$vm' is not running.)"; [[ -n $BASH_VERSION ]] && fndx=3 || fndx=1; envVarNames=($(export | awk -v fndx="$fndx" '$fndx ~ /^DOCKER_/ { sub(/=.*/,"", $fndx); print $fndx }')); if [[ -n $envVarNames ]]; then echo "-- Unsetting DOCKER_* environment variables ($(echo "${envVarNames[@]}" | sed 's/ /, /g'))..."; unset "${envVarNames[@]}"; else echo "(No DOCKER_* environment variables to unset.)"; fi; echo "-- Docker VM '$vm' is stopped." } dsh () { function die () { echo "${FUNCNAME[1]}(): ERROR: ${1:-"ABORTING due to unexpected error."}" 1>&2; return ${2:-1} }; function dieSyntax () { echo "${FUNCNAME[1]}(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h or --h for help." 1>&2; return 2 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; return $ecode } env_parallel () { local _grep_REGEXP="$( perl -e ' for(@ARGV){ /^_$/ and $next_is_env = 0; $next_is_env and push @envvar, split/,/, $_; $next_is_env = /^--env$/; } $vars = join "|",map { quotemeta $_ } @envvar; print $vars ? "($vars)" : "(.*)"; ' -- "$@" )"; local _ignore_UNDERSCORE="$( perl -e ' for(@ARGV){ $next_is_env and push @envvar, split/,/, $_; $next_is_env=/^--env$/; } if(grep { /^_$/ } @envvar) { if(not open(IN, "<", "$ENV{HOME}/.parallel/ignored_vars")) { print STDERR "parallel: Error: ", "Run \"parallel --record-env\" in a clean environment first.\n"; } else { chomp(@ignored_vars = ); $vars = join "|",map { quotemeta $_ } "env_parallel", @ignored_vars; print $vars ? "($vars)" : "(,,nO,,VaRs,,)"; } } ' -- "$@" )"; if ! perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then ( compgen -a; compgen -A function; compgen -A variable ) | cat > $HOME/.parallel/ignored_vars; return 0; fi; local _alias_NAMES="$(compgen -a | grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ )"; local _list_alias_BODIES="alias $_alias_NAMES"; if [[ "$_alias_NAMES" = "" ]]; then _list_alias_BODIES="true"; fi; unset _alias_NAMES; local _function_NAMES="$(compgen -A function | grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ )"; local _list_function_BODIES="typeset -f $_function_NAMES"; if [[ "$_function_NAMES" = "" ]]; then _list_function_BODIES="true"; fi; unset _function_NAMES; local _variable_NAMES="$(compgen -A variable | grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ | grep -vFf <(readonly) | grep -Ev '^(BASHOPTS|BASHPID|EUID|GROUPS|FUNCNAME|DIRSTACK|_|PIPESTATUS|PPID|SHELLOPTS|UID|USERNAME|BASH_[A-Z_]+)$')"; local _list_variable_VALUES="typeset -p $_variable_NAMES"; if [[ "$_variable_NAMES" = "" ]]; then _list_variable_VALUES="true"; fi; unset _variable_NAMES; export PARALLEL_ENV="$( shopt 2>/dev/null | perl -pe 's:\s+off:;: and s/^/shopt -u /; s:\s+on:;: and s/^/shopt -s /; s:;$:&>/dev/null;:'; echo 'shopt -s expand_aliases &>/dev/null'; $_list_alias_BODIES; $_list_variable_VALUES; $_list_function_BODIES)"; unset _list_alias_BODIES; unset _list_variable_VALUES; unset _list_function_BODIES; `which parallel` "$@"; _parallel_exit_CODE=$?; unset PARALLEL_ENV; return $_parallel_exit_CODE } f () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <] Description: Opens the specified folder in Finder, or, if invoked as "af", in Alfred 2's file browser. By default, the current folder is targeted. You can also specify a file, in which case its containing folder is opened. can also be the name of a quick-cd function defined in the current shell. Quick-cd functions by conventions start with 'f', and, for convenience, you may specify the function name without the initial 'f'. Examples: $FUNCNAME /Library $FUNCNAME fh # 'fh' is quick-cd function for home folder; 'h' would work, too. EOF return 0; fi (( ${#@} >= 2 )) && echo -e "$FUNCNAME: PARAMETER ERROR: Unexpected parameter(s) specified. Use -h or --h to get help." 1>&2 && return 3; local haveFolder=$(( ${#1} ? 1 : 0 )); if (( haveFolder )); then if [[ -f "$1" ]]; then pushd "$(dirname "$1")" > /dev/null || return 2; else if [[ -d "$1" ]]; then pushd "$1" > /dev/null || return 2; else if [[ ${1/\/} != $1 ]]; then echo "ERROR: '$1', assumed to be a folder path, does not exist." 1>&2; return 1; else quickCdFunc="$1"; if [[ ! "$quickCdFunc" =~ ^[fF] ]]; then quickCdFunc="f$quickCdFunc"; fi; declare -f "$quickCdFunc" > /dev/null || { echo "ERROR: '$1' is neither an existing file or folder nor the name of a quick-cd function." 1>&2; return 1 }; $quickCdFunc > /dev/null || return 2; fi; fi; fi; fi; if [[ ${FUNCNAME[1]} == 'af' ]]; then osascript -e 'tell application "Alfred 2" to search "'"$PWD"'"'; else echo Opening Finder to \"$PWD\"...; open .; fi; if (( haveFolder )); then popd > /dev/null; fi } fa () { pushdX /Applications "$@" } fag () { pushdX "$HOME/Projects/CreativeSmarts/AppGyver" "$@" } fas () { pushdX /Library/Application\ Support "$@" } fasu () { pushdX ~/Library/Application\ Support "$@" } fau () { pushdX ~/Applications "$@" } fawf () { pushdX "$HOME/Dropbox/Alfred.alfredpreferences/workflows" "$@" } fawfc () { pushdX "$HOME/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data" "$@" } fawfd () { pushdX "$HOME/Library/Application Support/Alfred 2/Workflow Data" "$@" } fawfp () { pushdX "$HOME/Projects/AlfredWorkflows" "$@" } fcfg () { pushdX ~/Documents/Config "$@" } fcu () { pushdX ~/Library/Caches "$@" } fd () { pushdX ~/Documents "$@" } fdb () { pushdX ~/Dropbox "$@" } fdbp () { pushdX ~/Dropbox/Public "$@" } fdl () { pushdX ~/Downloads "$@" } fdla () { pushdX ~/Documents/DownloadArchive "$@" } fdt () { pushdX ~/Desktop "$@" } feb () { pushdX ~/Documents/eBooks "$@" } febi () { pushdX ~/Documents/eBooks/IT "$@" } febo () { pushdX ~/Calibre\ Library/ "$@" } ff () { local isFunc=1; [[ -z "$FUNCNAME" ]] && isFunc=0; local thisName=$FUNCNAME; (( isFunc )) || thisName=$(basename "$BASH_SOURCE"); if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2 && { (( isFunc )) && return 3 || exit 3 }; find . -iname "*$@*" } fh () { pushdX ~ "$@" } fhomer () { pushdX "/Volumes/jdoe" "$@" } fic () { pushdX "$HOME/Documents/Config/Icons" "$@" } fif () { local isFunc=1; [[ -z "$FUNCNAME" ]] && isFunc=0; local thisName=$FUNCNAME; (( isFunc )) || thisName=$(basename "$BASH_SOURCE"); if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2 && { (( isFunc )) && return 3 || exit 3 }; egrep -lr "$@" . } findexes () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "Synopsis:\n $FUNCNAME [dir]\n\nDescription:\n Finds all executable files in the specified subtree. Uses \`find\` with the \`-type\` and \`-perm\` primaries." && return 0; find "${1:-.}" -type f -perm "-u=x" } findq () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "Synopsis:\n $FUNCNAME {params for \`find\`}\n\nDescription:\n Same as \`find\` with the (implied) \`print\` primary (for listing matching paths),\n except that paths whose names contain reserved chars. are quoted (escaped);\n\n e.g.: 'a name with spaces' -> 'a\ name \ with\ spaces'\n\n Therefore it's safe to pass the output of this function to \`xargs\`.\n e.g.: \`$FUNCNAME . | xargs file\` lists the file type of every file in the current folder's subtree.\n\n CAVEAT: Do not specify a \`find\` primary - \`print\` is implied.\n" && return 0; find "$@" -print0 | while IFS='' read -r -d '' f; do printf '%q\n' "$f"; done } fkkac () { pushdX "$HOME/Projects/CreativeSmarts/AppGyver/Kakooma" "$@" } fkkai () { pushdX "$HOME/Projects/CreativeSmarts/Kakooma iOS Apps/src" "$@" } fl () { pushdX /Library "$@" } fla () { pushdX /Library/LaunchAgents "$@" } flau () { pushdX ~/Library/LaunchAgents "$@" } flsys () { pushdX /System/Library "$@" } flu () { pushdX ~/Library "$@" } fngb () { pushdX "$(npm bin -g)" "$@" } fngm () { pushdX "$(npm prefix -g)"/lib/node_modules "$@" } fobt () { pushdX "/Volumes/C/Users/jdoe/Documents/Projects/ta/onboarding-termination" "$@" } foldIndent () { local width=${1:-80} indent=${2- }; (( width-=${#indent} )); while IFS= read -r line; do fold -s -w $width <<< "$line" | awk 'NR>1 { print "'"$indent"'" $0; next } 1'; done } foss () { pushdX "$HOME/Projects/OSS" "$@" } fpg () { pushdX "$HOME/Desktop/pg" "$@" } fpgw () { pushdX "/Volumes/C/Users/jdoe/Desktop/pg" "$@" } fph () { pushdX ~/Pictures/ "$@" } fppg () { pushdX ~/Projects/pg "$@" } fpr () { pushdX ~/Projects "$@" } fpref () { pushdX /Library/Preferences "$@" } fprefu () { pushdX ~/Library/Preferences "$@" } fql () { pushdX /Library/QuickLook "$@" } fqlu () { pushdX ~/Library/QuickLook "$@" } fs () { pushdX /Library/Services "$@" } fsba () { pushdX ~/Library/Containers "$@" } fsd () { pushdX "/Volumes/data" "$@" } fsl () { pushdX /Library/'Script Libraries' "$@" } fslu () { pushdX ~/Library/'Script Libraries' "$@" } fsn () { pushdX "/Volumes/C/Users/jdoe/Documents/Projects/ta/sponsored-renewal/PsScripts" "$@" } fsph () { pushdX "/Volumes/media/Photos" "$@" } fss () { pushdX ~/Library/'Saved Searches' "$@" } fstp () { d=$([[ $(uname) == 'Darwin' ]] && printf "$HOME/Library/Application Support/Sublime Text 3/Packages" || printf "$HOME/.config/sublime-text-2/Packages"); pushdX "$d" "$@" } fstpu () { d=$([[ $(uname) == 'Darwin' ]] && printf "$HOME/Library/Application Support/Sublime Text 3/Packages/User" || printf "$HOME/.config/sublime-text-2/Packages/User"); pushdX "$d" "$@" } fsu () { pushdX ~/Library/Services "$@" } fsv () { pushdX "/Volumes/media/Videos" "$@" } fsvms () { pushdX '/Volumes/data/VMs/VMware Fusion/Virtual Machines' "$@" } ft () { pushdX '/tmp' "$@" } ftr () { pushdX "/Volumes/data/Transfer" "$@" } ftu () { pushdX "$TMPDIR" "$@" } fu () { pushdX "$MK_UTIL_FOLDER" "$@" } fub () { pushdX ~/bin "$@" } fuc () { pushdX "$MK_UTIL_FOLDER/sourced.d/bash_completion.d" "$@" } fulb () { pushdX '/usr/local/bin' "$@" } fullpath () { [[ "$1" == '--help' || "$1" == '-h' ]] && { echo -e "usage: $FUNCNAME [-ep] [path]\n Prints the absolute version of the specified path; defaults to \$PWD.\n The path is normalized, i.e, '.' and '..' components are resolved, if present.\n If only a filename is given and the file doesn't exist in the current folder, -p will search for it in the \$PATH, too.\n -e reports an error if the resulting path doesn't exist."; return 0 }; local params=() decompressed=0 argsReached=0 p=''; for p in "$@"; do if [[ $argsReached -eq 0 && $p == -[a-z,A-Z,0-9]?* ]]; then decompressed=1; params+=(${p:0:2}); for ((i = 2; i < ${#p}; i++ )) do params+=("-${p:$i:1}"); done; else [[ $p == '--' ]] && argsReached=1; params+=("$p"); fi; done; if (( decompressed )); then set -- "${params[@]}"; fi; unset params decompressed argsReached p; local fp searchInPath mustExist; while (( $# )); do case "$1" in -p) searchInPath=1 ;; -e) mustExist=1 ;; --) shift; break ;; -*) echo "PARAMETER ERROR: Unrecognized option: '$1'. To force interpretation as non-option, precede with '--'." 1>&2; return 2 ;; *) break ;; esac; shift; done; [[ -z $2 ]] || { echo "PARAMETER ERROR: Too many parameters specified. Use -h for help." 1>&2; return 2 }; if [[ -z $1 ]]; then fp=$PWD; else if [[ "${1:0:1}" == '/' ]]; then fp=$1; else fp="$PWD/$1"; if [[ -n $searchInPath && ! -e "$fp" && "${1/\//}" == "$1" ]]; then fp=$(which "$1" 2>/dev/null) || fp="$1"; fi; fi; fi; if [[ $fp =~ (/|^)(\.\.?)(/|$) && ( -e "$fp" || -d "$(dirname "$fp")" ) ]]; then local fld; [[ -d "$fp" ]] && fld=$fp || fld=$(dirname "$fp"); local fldResolved=$(cd "$fld"; pwd); [[ -d "$fp" ]] && fp=$fldResolved || fp=$fldResolved/$(basename "$fp"); fi; [[ -n $mustExist && ! -e "$fp" ]] && { echo "ERROR: Path '$fp' does not exist." 1>&2; return 1 }; echo "$fp" } fus () { pushdX "$MK_UTIL_FOLDER/sourced.d" "$@" } fuw () { pushdX "$MK_UTIL_FOLDER.Win" "$@" } fvms () { dirs=(~/'Documents/Virtual Machines.localized' ~/'Documents/Virtual Machines'); for dir in "${dirs[@]}"; do [[ -d "$dir" ]] && { pushdX "$dir" "$@"; return }; done } fwac () { pushdX "/Volumes/C/Users/jdoe/Documents/Projects/ta/workday-ad-consistency" "$@" } getip () { [[ "$1" == '--help' || "$1" == '-h' ]] && { echo -e "usage: $FUNCNAME\n Prints the IPv4 address of the first *bound* Ethernet interface (e.g., en0); cf. getips()."; return 0 }; if [[ $(uname) == 'Darwin' ]]; then for ifName in $(ifconfig -l | egrep -o "\ben[0-9]+"); do local protName='inet'; local addrFragment=$(ifconfig "$ifName" | egrep -o "\b$protName \S+"); if [[ -n $addrFragment ]]; then echo "$addrFragment" | egrep -o '[0-9].*'; return 0; fi; done; return 1; else local addr; addr=$(ip route get 10.0.0.1 | awk '{print $NF; exit}'); [[ -n $addr ]] || return 1; echo "$addr"; fi } getips () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "usage: $FUNCNAME [-b] [interface-type]\n Prints all this machine's IPv4 addresses of the specified interface *type* (Ethernet by default); cf. getip()\n Use \`ifconfig\` directly to get a specific interface's address.\n -b prints addresses only (suppresses the interface-name prefix) and skips interfaces without address." && return 0; local bare=0; [[ $1 == -b ]] && { bare=1; shift }; local ifType=${1:-en}; for ifName in $(ifconfig -l | egrep -o "\b${ifType}\d+"); do local protName='inet'; local addrFragment=$(ifconfig "$ifName" | egrep -o "\b$protName \S+"); local addr=${addrFragment#$protName }; if (( bare )); then [[ -n $addr ]] && echo "$addr"; else echo "$ifName: $addr"; fi; done; return 0 } installnode () { local THIS_NAME=$FUNCNAME; function _installnode_die () { echo "$THIS_NAME(): ERROR: ${1:-"ABORTING due to unexpected error."}" 1>&2; return ${2:-1} }; function _installnode_dieSyntax () { echo "$THIS_NAME(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h for help." 1>&2; return 2 }; function _installnode_indexOf () { local e ndx=-1; for e in "${@:2}"; do (( ++ndx )); [[ "$e" == "$1" ]] && echo $ndx && return 0; done; echo '-1'; return 1 }; function _installnode_isIn () { _installnode_indexOf "$@" > /dev/null }; function _installnode_pruneToMajorMinor () { printf '%s' | cut -d '.' -f 1-2 <<< "$1" }; function _installnode_resolveInstalledVersion () { local verSpec=$1 verInstalled; [[ ${verSpec:0:1} == 'v' ]] && verSpec=${verSpec:1}; read -r verInstalled <<< "$(nvm ls "$verSpec" | tail -1)"; [[ $verInstalled =~ \ *(v[[:digit:]]+[.[:digit:]]+) ]] && verInstalled=${BASH_REMATCH[1]} || verInstalled=''; printf '%s' "$verInstalled" }; function _installnode_resolveRemoteVersion () { local verSpec=$1; nvm ls-remote "$verSpec" | tail -1 | egrep -o 'v[[:digit:]]+[.[:digit:]]+' }; function _installnode_getLatestUnstableVersion () { _installnode_resolveRemoteVersion }; function _installnode_getLatestProductionVersion () { local latestOverall major minor; latestOverall=$(nvm ls-remote | tail -1 | egrep -o 'v[[:digit:]]+[.[:digit:]]+'); major=$(cut -d '.' -f 1 <<<"$latestOverall"); minor=$(cut -d '.' -f 2 <<<"$latestOverall"); minor=$(( minor - minor % 2 )); _installnode_resolveRemoteVersion "${major}.${minor}" }; function _installnode_isInstalled () { local verSpec=$1; [[ ${verSpec:0:1} == 'v' ]] || verSpec="v${verSpec}"; nvm ls | egrep -v '(:|->)' | egrep "$verSpec" > /dev/null; return $? }; function _installnode_getDefaultVerSpec () { nvm alias default | cut -d ' ' -f 3 }; function _installnode_getDefaultVer () { nvm alias default | awk -F '->' '{print $3}' | tr -d ' )' }; function _installnode_vercomp () { [[ $1 == $2 ]] && return 0; local i v1=$1 v2=$2; [[ ${v1:0:1} == 'v' ]] && v1=${v1:1}; [[ ${v2:0:1} == 'v' ]] && v2=${v2:1}; local IFS='.'; local i vna1=($v1) vna2=($v2); for ((i=${#vna1[@]}; i<${#vna2[@]}; i++)) do vna1[i]=0; done; for ((i=0; i<${#vna1[@]}; i++)) do [[ -z ${vna2[i]} ]] && vna2[i]=0; (( 10#${vna1[i]} > 10#${vna2[i]} )) && return 1; (( 10#${vna1[i]} < 10#${vna2[i]} )) && return 2; done; return 0 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat < /dev/null; then argsReached=1; fi; fi; params+=("$p"); fi; done; (( decompressed )) && set -- "${params[@]}"; unset params decompressed argsReached p; local showStatus=0 installFresh=0 upgrade=0 installAndCopy=0; local useUnstableVersion=0 skipPrompt=0 force=0; while (( $# )); do case "$1" in status) showStatus=1 ;; fresh) installFresh=1 ;; copy) installAndCopy=1 ;; upgrade) upgrade=1 ;; --) shift; break ;; -d | --unstable) useUnstableVersion=1 ;; -y | --yes) skipPrompt=1 ;; -f | --force) force=1 ;; -?) return $(_installnode_dieSyntax "Unrecognized option: '$1'. To force interpretation as non-option, precede with '--'.") ;; *) break ;; esac; shift; done; local newVerSpec oldVerSpec majorMinorSpec haveNewVerSpec haveOldVerSpec downgrading defaultVerHint defaultVerSpec suggestedNewDefaultVerSpec qualifier otherOptCount descr; newVerSpec=$1; shift; oldVerSpec=$1; shift; [[ -z $1 ]] || return $(_installnode_dieSyntax "Too many parameters specified."); local cmdCount=$(( showStatus + installFresh + installAndCopy + upgrade )); (( cmdCount <= 1 )) || return $(_installnode_dieSyntax "Only 1 command may be specified."); (( cmdCount == 1 )) || showStatus=1; if [[ -n $oldVerSpec ]]; then (( upgrade || installAndCopy )) || return $(_installnode_dieSyntax "An old version number can only be specified with the 'upgrade' and 'copy' commands."); fi; if [[ -n $newVerSpec ]]; then (( ! useUnstableVersion )) || return $(_installnode_dieSyntax "-d implies the latest unstable version, do not also supply an explicit version spec."); fi; haveNewVerSpec=0; if [[ -n $newVerSpec ]]; then haveNewVerSpec=1; [[ ${newVerSpec:0:1} == 'v' ]] || newVerSpec=v${newVerSpec}; fi; haveOldVerSpec=0; if [[ -n $oldVerSpec ]]; then haveOldVerSpec=1; [[ ${oldVerSpec:0:1} == 'v' ]] || oldVerSpec=v${oldVerSpec}; fi; [[ "$(type -t nvm)" != 'function' && -s ~/.nvm/nvm.sh ]] && . ~/.nvm/nvm.sh; [[ "$(type -t nvm)" == 'function' ]] || return $(_installnode_die "nvm (node.js version manager) not found."); if (( haveNewVerSpec )); then resolvedNewVersion=$(_installnode_resolveRemoteVersion "$newVerSpec") || return $(_installnode_die "No available version matching '$newVerSpec' found."); else if (( useUnstableVersion )); then resolvedNewVersion=$(_installnode_getLatestUnstableVersion); else resolvedNewVersion=$(_installnode_getLatestProductionVersion); fi; [[ -n $resolvedNewVersion ]] || return $(_installnode_die "Failed to determine latest available version."); fi; resolvedOldVersion=''; if (( haveOldVerSpec )); then resolvedOldVersion=$(_installnode_resolveInstalledVersion "$oldVerSpec"); [[ -n $resolvedOldVersion ]] || return $(_installnode_die "Old version spec. does not match any installed versions: '$oldVerSpec'"); else if (( haveNewVerSpec )); then majorMinorSpec=$(_installnode_pruneToMajorMinor "$newVerSpec"); else majorMinorSpec=$(_installnode_pruneToMajorMinor "$resolvedNewVersion"); fi; resolvedOldVersion=$(_installnode_resolveInstalledVersion "$majorMinorSpec"); fi; if (( showStatus )); then otherOptCount=$(( skipPrompt + force )); (( otherOptCount == 0 )) || return $(_installnode_dieSyntax "The 'status' command cannot be combined with these options."); descr=''; if (( haveNewVerSpec )); then descr="'$newVerSpec' version"; else if (( useUnstableVersion )); then descr="UNSTABLE version"; else descr="PRODUCTION version"; fi; fi; cat <&2 ;; esac; else if _installnode_isInstalled $resolvedNewVersion; then (( force )) || return $(_installnode_die "Version $resolvedNewVersion is already installed. To force reinstallation, use --force."); echo "WARNING: As requested, REINSTALLING $resolvedNewVersion." 1>&2; fi; fi; if (( installFresh )); then echo "Will INSTALL FRESH: $resolvedNewVersion"; else if (( installAndCopy )); then echo "Will INSTALL: $resolvedNewVersion"; echo "And COPY GLOBAL PACKAGES FROM: $resolvedOldVersion"; else if (( upgrade )); then echo "Will INSTALL: $resolvedNewVersion"; echo "And UPGRADE FROM (copy global packages, then DELETE): $resolvedOldVersion"; fi; fi; fi; while (( ! skipPrompt )); do read -p "CONTINUE? (y/N) " promptInput; [[ $promptInput =~ ^[yY]$ ]] && break; ( [[ $promptInput =~ ^[nN]$ || -z $promptInput ]] ) && { echo "Aborted." 1>&2; return 1 }; echo "Invalid input; please try again (^C to abort)." 1>&2; done; if (( force )) && _installnode_isInstalled "$resolvedNewVersion"; then echo "-- UNinstalling $resolvedOldVersion..."; nvm deactivate > /dev/null; nvm uninstall "$resolvedNewVersion" || return $(_installnode_die); fi; echo "-- INSTALLING $resolvedNewVersion..."; nvm install "$resolvedNewVersion" || return $(_installnode_die); if (( installAndCopy || upgrade )); then echo "-- COPYING global packages from $resolvedOldVersion..."; echo " Note: This CAN TAKE A WHILE, as packages are being rebuilt."; npm_config_loglevel='error' nvm copy-packages "$resolvedOldVersion" > /dev/null || return $(_installnode_die); fi; if (( upgrade )); then echo "-- DELETING old version $resolvedOldVersion..."; nvm uninstall "$resolvedOldVersion" || return $(_installnode_die); fi; if [[ "$resolvedNewVersion" != "$(_installnode_getDefaultVer)" ]]; then suggestedNewDefaultVerSpec=$(_installnode_pruneToMajorMinor "$resolvedNewVersion"); defaultVerSpec=$(_installnode_getDefaultVerSpec); qualifier="the latest $suggestedNewDefaultVerSpec.x version - and therefore now $resolvedNewVersion - "; if [[ "$suggestedNewDefaultVerSpec" == "$(_installnode_getDefaultVerSpec)" ]]; then qualifier="$resolvedNewVersion SPECIFICALLY"; suggestedNewDefaultVerSpec=$resolvedNewVersion; fi; defaultVerHint=" NOTE: The DEFAULT VERSION (spec.) is currently: $(_installnode_getDefaultVerSpec) To make $qualifier the NEW default version, run: nvm alias default $suggestedNewDefaultVerSpec "; fi; if (( SHLVL > 1 )); then echo " -- WARNING: $resolvedNewVersion was SUCCESSFULLY INSTALLED, *but* to MAKE IT TAKE EFFECT, do the following: - open a NEW Terminal tab or window. - and execute the following: nvm use $resolvedNewVersion In the future, consider loading this script - '$BASH_SOURCE' - from your shell profile to avoid having to do this. " 1>&2; else echo "-- Done. ACTIVE VERSION is now $resolvedNewVersion."; fi; if [[ -n $defaultVerHint ]]; then echo "$defaultVerHint"; else echo " $resolvedNewVersion is also the NEW DEFAULT."; fi } iterm2_begin_osc () { printf "\033]" } iterm2_end_osc () { printf "\007" } iterm2_preexec_install () { if ( [ x"${PROMPT_COMMAND:-}" = x ] ); then PROMPT_COMMAND="iterm2_preexec_invoke_cmd"; else PROMPT_COMMAND="$(echo -n $PROMPT_COMMAND | sed -e 's/; *$//'); iterm2_preexec_invoke_cmd"; fi; trap 'iterm2_preexec_invoke_exec "$_"' DEBUG } iterm2_preexec_invoke_cmd () { set -o functrace > /dev/null 2>&1; shopt -s extdebug > /dev/null 2>&1; \local s=$?; last_hist_ent="$(HISTTIMEFORMAT= builtin history 1)"; precmd; if [ -z "${ITERM_ORIG_PS1+xxx}" ]; then export ITERM_ORIG_PS1="$PS1"; fi; if [[ "$PS1" != "$ITERM_PREV_PS1" ]]; then export ITERM_ORIG_PS1="$PS1"; fi; \local iterm2_prompt_prefix_value="$(iterm2_prompt_prefix)"; if [[ $ITERM_ORIG_PS1 != *'$(iterm2_prompt_mark)'* ]]; then iterm2_prompt_prefix_value="$iterm2_prompt_prefix_value$(iterm2_prompt_mark)"; fi; sh -c "exit $s"; export PS1="\[$iterm2_prompt_prefix_value\]$ITERM_ORIG_PS1\[$(iterm2_prompt_suffix)\]"; export ITERM_PREV_PS1="$PS1"; sh -c "exit $s"; ITERM_PREEXEC_INTERACTIVE_MODE="yes" } iterm2_preexec_invoke_exec () { if [ ! -t 1 ]; then return; fi; if [[ -n "${COMP_LINE:-}" ]]; then return; fi; if [[ -z "$ITERM_PREEXEC_INTERACTIVE_MODE" ]]; then return; else if [[ 0 -eq "$BASH_SUBSHELL" ]]; then ITERM_PREEXEC_INTERACTIVE_MODE=""; fi; fi; if [[ "iterm2_preexec_invoke_cmd" == "$BASH_COMMAND" ]]; then ITERM_PREEXEC_INTERACTIVE_MODE=""; return; fi; hist_ent="$(HISTTIMEFORMAT= builtin history 1)"; \local prev_hist_ent="${last_hist_ent}"; last_hist_ent="${hist_ent}"; if [[ "${prev_hist_ent}" != "${hist_ent}" ]]; then \local this_command="$(echo "${hist_ent}" | sed -e "s/^[ ]*[0-9]*[ ]*//g")"; else \local this_command=""; fi; preexec "$this_command" } iterm2_print_state_data () { iterm2_begin_osc; printf "1337;RemoteHost=%s@%s" "$USER" "$iterm2_hostname"; iterm2_end_osc; iterm2_begin_osc; printf "1337;CurrentDir=%s" "$PWD"; iterm2_end_osc; iterm2_print_user_vars } iterm2_print_user_vars () { true } iterm2_print_version_number () { iterm2_begin_osc; printf "1337;ShellIntegrationVersion=4;shell=bash"; iterm2_end_osc } iterm2_prompt_mark () { iterm2_begin_osc; printf "133;A"; iterm2_end_osc } iterm2_prompt_prefix () { iterm2_begin_osc; printf "133;D;\$?"; iterm2_end_osc; iterm2_print_state_data } iterm2_prompt_suffix () { iterm2_begin_osc; printf "133;B"; iterm2_end_osc } iterm2_set_user_var () { iterm2_begin_osc; printf "1337;SetUserVar=%s=%s" "$1" $(printf "%s" "$2" | base64 | tr -d '\n'); iterm2_end_osc } kill-script () { [[ -z $1 || $1 == '-h' || $1 == '--help' ]] && { echo "Usage: $FUNCNAME scriptFileName ..."' '"Kills the specified bash/sh script(s)."; return $(( ${#1} == 0 )) }; local ec=0; for p in "$@"; do pkill -nf '/?(bash|sh)[ ]+(.*/)?'"$p"'( |$)' && echo "'$1' killed." || { ec=$?; echo "ERROR: bash/sh script process not found: '$p'" 1>&2 }; done; return $ec } list-available-locales () { case $(uname) in 'Darwin') locale -a ;; 'Linux') [[ -f /usr/share/i18n/SUPPORTED ]] && { cat /usr/share/i18n/SUPPORTED; return }; which localectl &> /dev/null && { localectl list-locales; return }; { echo "Don't know how to determine available locales for $(uname -a)." 1>&2; return 1 } ;; *) { echo "Don't know how to determine available locales for $(uname)." 1>&2; return 1 } ;; esac } lock () { '/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession' -suspend } lsp () { local isFunc=1; [[ -z "$FUNCNAME" ]] && isFunc=0; local thisName=$FUNCNAME; (( isFunc )) || thisName=$(basename "$BASH_SOURCE"); if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat < Save Project As... CAVEAT: As of ST2 v2.0.1, if a project file is opene and the project happens to be open in ST2 already, a new, *blank* window will open. EOF (( isFunc )) && return 0 || exit 0; fi local projSwitch='--project'; local projFile="$@"; if [[ -z $projFile ]]; then local EXT=.sublime-project; local projFiles=($(shopt -s nullglob; echo *$EXT)); projFile=${projFiles[0]}; if [[ -z $projFile ]]; then projSwitch=''; projFile='.'; echo "Opening folder '$PWD' as implicit, transient ST2 project..."; else echo "Opening project '$projFile'..."; fi; else ls "$projFile" > /dev/null 2>&1 || { echo "ERROR: ST2 project file(s) '$projFile' not found." 1>&2; return 1 }; echo "Opening project(s) '$projFile'..."; fi; subl $projSwitch "$projFile" } mang () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat </dev/null | cut -d= -f2 | xargs); [[ -n $expandedAlias ]] && name=$expandedAlias; if (( $# > 1 )); then man "$@"; else { help -s "$name" | grep -E "^$name:" } &> /dev/null && isBuiltIn=1; if [[ $isBuiltIn -ne 0 && $name != 'printf' ]]; then echo "(\"$name\" is a BUILTIN; using 'help'...)"; help "$name"; return $?; else man "$name" 2> /dev/null && return; fi; echo "(No 'man' page found, trying --help, then -h...)" 1>&2; [[ $(echo $name | tr [:upper:] [:lower:]) == 'setfile' ]] && { $name -h; return 0 }; [[ $(echo $name | tr [:upper:] [:lower:]) == 'plistbuddy' || $name == 'plb' ]] && { local exePath="/usr/libexec/PlistBuddy"; echo "IMPORTANT: 'PlistBuddy' is NOT in the PATH - lives at '$exePath'."' '; $exePath; $exePath -h; return 0 }; local ht=$($name --help 2> /dev/null || $name -h) || return; if [[ -z $ht ]]; then ht=$($name --help 2>&1) || ht=$($name -h 2>&1); fi; echo -E "$ht"; fi } manxg () { local targetCmd=${FUNCNAME%g}; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; return ${2:-1} }; function dieSyntax () { echo "${FUNCNAME[1]}(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h or --h for help." 1>&2; return 2 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; else [[ -n $firstDirCreated ]] || firstDirCreated="$dir"; argsForMkDir+=("$dir"); (( ++createCount )); fi; done; (( createCount )) && { mkdir "${argsForMkDir[@]}" || return $(die) }; cd "$firstDir" || return $(die); msgCreation=''; case $createCount in 0) msgCreation='C' ;; 1) if [[ $firstDirCreated == $firstDir ]]; then msgCreation='Created and c'; else msgCreation='1 dir. created; c'; fi ;; *) msgCreation="$createCount dirs. created; c" ;; esac; echo "${msgCreation}hanged to '$firstDir' [$PWD]." } mktempfile () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "usage: $FUNCNAME [ext]\n Creates a unique temporary file or folder and returns its full path.\n Acts as a simple wrapper around \`mktemp -t tmp\`; i.e., file is created in \$TMPDIR (or /tmp, in its absence);\n optionally specify additional \`mktemp\` options, such as -u to delete the file right away,\n or -d to create a directory instead.\n If you specify EXT, the temporary file is given the specified filename extension." && return 0; local ext; local isDir=0; local dontCreate=0; for p in "$@"; do if [[ "${p:0:1}" != "-" ]]; then [[ -n "$ext" ]] && { echo "$FUNCNAME: PARAMETER ERROR: You can only specify ONE filename extension." 1>&2; return 1 }; ext=$p; else if [[ "$p" == "-d" ]]; then isDir=1; else if [[ "$p" == "-u" ]]; then dontCreate=1; fi; fi; fi; done; [[ isDir -eq 1 && -n $ext ]] && { echo "$FUNCNAME: PARAMETER ERROR: You can only specify a filename extension when you create a file (not a directory)." 1>&2; return 1 }; local passThru=${@/$ext}; local outPath=$(mktemp $passThru -t 'tmp'); [[ -z "$outPath" ]] && return 1; if [[ -n "$ext" ]]; then local oldOutPath=$outPath; [[ "${ext:0:1}" != '.' ]] && ext=".$ext"; outPath+=$ext; if (( ! dontCreate )); then mv "$oldOutPath" "$outPath" || return 1; fi; fi; echo "$outPath" } npmf () { function die () { echo "${FUNCNAME[1]}(): ERROR: ${1:-"ABORTING due to unexpected error."}" 1>&2; return ${2:-1} }; function dieSyntax () { echo "${FUNCNAME[1]}(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h or --h for help." 1>&2; return 2 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat < /dev/null || return $(die) } npml () { function die () { echo "${FUNCNAME[1]}(): ERROR: ${1:-"ABORTING due to unexpected error."}" 1>&2; return ${2:-1} }; function dieSyntax () { echo "${FUNCNAME[1]}(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h for help." 1>&2; return 2 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat </dev/null | perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))'`; if [[ -z $data ]]; then echo ERROR: No HTML data found on clipboard. 1>&2; return 1; fi; echo "$data" } pbpaste_rtf () { local data; data=`osascript -e 'class RTF of (the clipboard as record)' 2>/dev/null | perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))'`; if [[ -z $data ]]; then echo ERROR: No RTF data found on clipboard. 1>&2; return 1; fi; echo "$data" } pifs () { set | egrep '^IFS=' } precmd () { if [[ -z "${iterm2_ran_preexec:-}" ]]; then preexec ""; fi; iterm2_ran_preexec="" } preexec () { iterm2_begin_osc; printf "133;C;"; iterm2_end_osc; if [ -n "${ITERM_ORIG_PS1+xxx}" -a "$PS1" = "$ITERM_PREV_PS1" ]; then export PS1="$ITERM_ORIG_PS1"; fi; iterm2_ran_preexec="yes" } pushdX () { pushd "$1" > /dev/null || return $?; [[ -t 1 ]] && echo "${PWD/#$HOME/~}" || echo "${PWD}"; shift; if (( $# )); then "$@"; fi } pv () { local pipeStatus=(${PIPESTATUS[@]}); local bashReMatch=("${BASH_REMATCH[@]}"); [[ "$1" == '-h' || "$1" == '--help' ]] && { cat < e.g., 'HOME="/Users/jdoe" # -x' $FUNCNAME 'histf*' # -> e.g., $'HISTFILE="/Users/jdoe/.bash_history"\nHISTFILESIZE="500"' EOF return 0 } function __pv_encodeCtrlChars () { local v=$1; v=${v//' '/\\t}; v=${v//' '/\\n}; '/\\r}; v=${v//''/\\v}; local/l=$(( ${#v} - 2 )); printf '%s' "\$'${v:1:$l}'" }; local vname vnamePattern vnames=("$@") allVnames=() matchPatterns=0 countOk=0 patternMatched=0 warnBashVars=0; for vname in "${vnames[@]}"; do if [[ $vname == *[][*?]* ]]; then matchPatterns=1; break; fi; done; if (( $# == 0 || matchPatterns )); then if [[ $BASH_VERSINFO -lt 4 ]]; then local allVnames=($(declare -p | LC_ALL=C sed -n -E -e '1,/^[^=]+\(\)/p' | LC_ALL=C sed -E -n -e '/^[[:alnum:]_]+=/p' | LC_ALL=C awk -F '=' '{ print $1 }')); else local allVnames=($(declare -p | LC_ALL=C egrep '^declare -' | cut -d ' ' -f 3- | cut -d '=' -f 1)); fi; allVnames+=('-'); if (( $# == 0 )); then vnames=("${allVnames[@]}"); else vnamesWithPatterns=("${vnames[@]}"); vnames=(); local mustReset=$(shopt -q nocasematch; echo $?); shopt -s nocasematch; for vnamePattern in "${vnamesWithPatterns[@]}"; do if [[ $vnamePattern == *[][*?]* ]]; then patternMatched=0; for vname in "${allVnames[@]}"; do [[ "$vname" == $vnamePattern ]] && { vnames+=("$vname"); patternMatched=1 }; done; (( patternMatched )) || { echo "WARNING: No variables match pattern: $vnamePattern" 1>&2 }; else vnames+=("$vnamePattern"); fi; done; (( mustReset )) && shopt -u nocasematch; fi; fi; for vname in "${vnames[@]}"; do if [[ $vname == '-' ]]; then echo "-=$- # -r"; else [[ $vname == 'BASH_'* && ! ( $vname == 'BASH_REMATCH' || $vname == 'BASH_VERSION' || $vname == 'BASH_VERSINFO' ) || $vname == '_' ]] && { warnBashVars=1; continue }; local vdef=$(declare -p "$vname" 2> /dev/null); if [[ -z $vdef ]]; then if (( $# )); then echo "WARNING: Variable '$vname' is not defined." 1>&2; fi; else local vdef=${vdef#declare }; local attrs vval; IFS=' =' read -d '' -r attrs vname vval <<< "$vdef"; if [[ $vname == 'PIPESTATUS' ]]; then vval=$(declare -p pipeStatus | cut -d= -f2-); else if [[ $vname == 'BASH_REMATCH' ]]; then vval=$(declare -p bashReMatch | cut -d= -f2-); else vval=$(printf '%s' "$vval"); fi; fi; [[ $vname == 'IFS' ]] && vval=$(__pv_encodeCtrlChars "$vval"); printf '%s' "$vname=$vval"; attrs=${attrs/a/}; [[ -n $attrs && $attrs != '--' && $attrs != '-' ]] && printf " # $attrs"; printf '\n'; (( ++countOk )); fi; fi; done; (( warnBashVars )) && echo "WARNING: Cannot report true value of \$_ and some \$BASH_* variables due to technical limitations."' '"Use \`echo \"\$BASH_...\"\` instead; e.g., \`echo \"\${BASH_SOURCE[@]}\"\`." 1>&2; return $(( countOk == 0 )) } ql () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat < /dev/null } resetcolors () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; return 2 }; printf '\e[0m' } resume-script () { [[ -z $1 || $1 == '-h' || $1 == '--help' ]] && { echo "Usage: $FUNCNAME scriptFileName ..."' '"Resumes the specified bash/sh script(s)."; return $(( ${#1} == 0 )) }; local ec=0; for p in "$@"; do pkill -CONT -nf '/?(bash|sh)[ ]+(.*/)?'"$p"'( |$)' && echo "'$1' resumed." || { ec=$?; echo "ERROR: bash/sh script process not found: '$p'" 1>&2 }; done; return $ec } sl () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2 && return 1 ;; *) break ;; esac; shift; done; [[ -z "$1" ]] && echo -e "$FUNCNAME: PARAMETER ERROR: Too few parameters specified. Use -h or --h to get help." 1>&2 && return 1; local allTokens; if (( !optNoTotal && ${#@} >=2 )); then local allTokens=$*; fi; local totalLen=0; local result=''; while (( ${#@} )); do local len=${#1}; (( totalLen+=len )); result="${result}'$1': $len"' '; shift; done; if [[ -n "$allTokens" ]]; then echo "Total: ${#allTokens}/$totalLen (with/without interior spaces)"; fi; echo -n "$result" } stripColors () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; return 2 }; LC_ALL=C sed -E 's/'''\[([0-9]{1,2})?(;[0-9]{1,2})*m//g' } stripFormatting () { if [[ $(uname) == 'Linux' ]]; then stripColors | col -b; else stripColors | LC_ALL=C col -b; fi } suspend-script () { [[ -z $1 || $1 == '-h' || $1 == '--help' ]] && { echo "Usage: $FUNCNAME scriptFileName ..."' '"Suspends the specified bash/sh script(s)."; return $(( ${#1} == 0 )) }; local ec=0; for p in "$@"; do pkill -STOP -nf '/?(bash|sh)[ ]+(.*/)?'"$p"'( |$)' && echo "'$1' suspended." || { ec=$?; echo "ERROR: bash/sh script process not found: '$p'" 1>&2 }; done; return $ec } tc () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&1 | $FUNCNAME' instead of just '| $FUNCNAME'. - With COMMAND specified, executes it, and copies its stdout output to the clipboard using 'pbcopy'. To capture commands involving pipes and stdout/err redirection, use the postpositional form instead. If COMMAND returns an error, it is reported, and nothing is copied to the clipboard. No stdout output is displayed by default. Pass -p (--passthru) as the 1st argument to also echo what was captured. A nonzero exitcode, possibly accompanied by an error message, indicates failure. Examples: ls | $FUNCNAME $FUNCNAME ls EOF return 0; fi [[ $1 == '-p' || $1 =~ ^--?[Pp][Aa][Ss][Ss][Tt][Hh][Rr][Uu]$ ]] && { local passThru=1; shift }; if (( $# )); then local ftemp=$(mktemp -t "$FUNCNAME"); ( eval "$@" > "$ftemp" ); local ec=$?; (( ec != 0 )) && rm "$ftemp" && echo '(Nothing was copied to clipboard.)' 1>&2 && return $ec; echo -En "$( < "$ftemp" )" | pbcopy; rm "$ftemp"; else pbcopy || return; fi; (( passThru )) && pbpaste } tobin () { local n; for n in "$@"; do bc <<< "obase=2;$(( n ))"; done } todec () { local outputBaseSpecChar='d'; _tobase "$@" } tohex () { local outputBaseSpecChar='x'; _tobase "$@" } tooct () { local outputBaseSpecChar='o'; _tobase "$@" } trim () { var=$1; var="${var#"${var%%[![:space:]]*}"}"; var="${var%"${var##*[![:space:]]}"}"; echo -n "$var" } typex () { case $1 in -h | --help | --version | --man | --man-source | --home) "$__typex_scriptpath" "$@"; return ;; esac; function __typex_rreadlinkchain () { ( command typeset target="$1" targetDir= targetName= CDPATH=; unalias cd pwd readlink dirname basename printf 2> /dev/null; unset -f cd pwd readlink dirname basename printf 2> /dev/null; while :; do [[ -L $target || -e $target ]] || { printf '%s\n' "typex: WARNING: '$target' does not exist." 1>&2; return 1 }; cd "$(dirname -- "$target")"; targetDir=$PWD; targetName=$(basename -- "$target"); [[ $targetName == '/' ]] && targetName=''; done=0; if [[ ! -L $targetName ]]; then targetDir=$(pwd -P); done=1; fi; printf '%s\n' "${targetDir%/}/$targetName"; (( done )) && break; target=$(readlink -- "$targetName"); done ) }; function __typex_getFileTimestamp () { command typeset file="$1" kind="${2:-m}" outFmt="$3" fmtOptChar= fmtChar= osNdx=; osNdx=0; [[ $(command uname) == 'Linux' ]] && osNdx=1; fmtOptChar='fc'; case "$kind" in m) fmtChar='mY' ;; a) fmtChar='aX' ;; b) fmtChar='BW' ;; c) fmtChar='cZ' ;; *) return 1 ;; esac; ts=$(command stat -${fmtOptChar:$osNdx:1} "%${fmtChar:$osNdx:1}" "$file") || return; if [[ -n $outFmt ]]; then case $osNdx in 0) command date -j -f '%s' "$ts" +"$outFmt" || return ;; 1) command date -d @"$ts" +"$outFmt" || return ;; esac; else command printf '%s\n' "$ts"; fi }; function __typex_reMatch () { command typeset ec= outVar="${3:-__typex_reMatch}"; unset -v "$outVar"; [[ $1 =~ $2 ]]; ec=$?; if [[ $ec -eq 0 ]]; then [[ -n $BASH_VERSION ]] && eval "$outVar"'=( "${BASH_REMATCH[@]}" )'; [[ -n $KSH_VERSION ]] && eval "$outVar"'=( "${.sh.match[@]}" )'; [[ -n $ZSH_VERSION ]] && eval "$outVar"'=( "$MATCH" "${match[@]}" )'; fi; return $ec }; function __typex_reQuote () { command sed 's/[^^]/[&]/g; s/\^/\\^/g' <<< "$*" }; function __typex_install () { command typeset targetShellFilename=$1 install=$2 runningStandalone=$3 scriptFileAbsPath=$4; command typeset verbose=1 scriptFileAbsPathQ= initFile= instLineRegEx= found=0 cmd= cmt= ec= newContents=; command typeset dir=${TYPEX_TEST_INITFILE_DIR:-~}; case "$targetShellFilename" in 'bash') [[ $(uname) == 'Darwin' ]] && initFile="$dir/.bash_profile" || initFile="$dir/.bashrc" ;; 'ksh') initFile="$dir/.kshrc" ;; 'zsh') initFile="$dir/.zshrc" ;; *) printf '%s\n' "ERROR: ${scriptFileAbsPath##*/} can only be sourced in bash, ksh, or zsh -- $targetShell is not supported." 1>&2; return 2 ;; esac; scriptFileAbsPathQ=$(command printf '%q' "$scriptFileAbsPath"); cmd="[[ -f $scriptFileAbsPathQ ]] && . $scriptFileAbsPathQ"; cmt="# Added by ${scriptFileAbsPath##*/} -i; ${scriptFileAbsPath##*/} -u to remove."; instLineRegEx='^[[:space:]]*'"$(__typex_reQuote "$cmd")"'([[:space:]]|$)'; [[ -f $initFile ]] && command grep -Eq "$instLineRegEx" "$initFile" && found=1; ec=0; if (( install )); then if (( found )); then (( verbose )) && command printf '%s\n' "(Sourcing command for '$scriptFileAbsPath' already present in '$initFile'; nothing to do.)"; else printf '\n%s %s\n' "$cmd" "$cmt" >> "$initFile"; ec=$?; fi; else if (( ! found )); then (( verbose )) && command printf '%s\n' "(Sourcing command for '$scriptFileAbsPath' not present in '$initFile'; nothing to do.)"; else newContents=$(command grep -Ev "$instLineRegEx" "$initFile") && command printf '%s\n' "$newContents" > "$initFile"; ec=$?; unset -f ${scriptFileAbsPath##*/} 2> /dev/null; fi; fi; if (( install )); then if (( ec == 0 )); then command printf '%s\n' "Sourcing of '$scriptFileAbsPath' installed in '$initFile'."; else command printf '%s\n' "ERROR: Failed to install sourcing of '$scriptFileAbsPath' in '$initFile'; please manually add line '. $scriptFileAbsPath'." 1>&2; fi; else if (( ec == 0 )); then command printf '%s\n' "Sourcing of '$scriptFileAbsPath' uninstalled from '$initFile'."; else command printf '%s\n' "ERROR: Failed to uninstall sourcing of '$scriptFileAbsPath' from '$initFile'; please manually remove the line containing '. $scriptFileAbsPath'." 1>&2; fi; fi; return $ec }; function __typex_init () { [[ -n $ZSH_VERSION ]] && { __typex_prevPosixBuiltinsOptState=${options[posixbuiltins]}; options[POSIX_BUILTINS]=on; __typex_prevKshArrayEmulationOptState=${options[ksharrays]}; options[ksharrays]=on } || unset __typex_prevPosixBuiltinsOptState __typex_prevKshArrayEmulationSOpttate }; function __typex_restore () { [[ -n $__typex_prevPosixBuiltinsOptState ]] && options[posixbuiltins]=$__typex_prevPosixBuiltinsOptState; [[ -n $__typex_prevKshArrayEmulationOptState ]] && options[ksharrays]=$__typex_prevKshArrayEmulationOptState }; __typex_init; command typeset thisFuncName=$([[ -n $BASH_VERSION ]] && command printf %s "$FUNCNAME" || command printf %s "$0"); command typeset notSourced=0; [[ $1 == '--not-sourced' ]] && { shift; notSourced=1 }; command typeset all=1; command typeset CDPATH= numNotFound=0 name= names= isExplicitPath=0 isKeyword=0 keywordOutput= def= found=0 isBuiltIn=0 specialFileType= brokenSymlink=0 extraOpt= files= file= thisfile= fileCategory= fileType= scriptType= ver= fileLinkChain= trueFile= errMsgSuffix= shell=; command typeset fileSystemOnly=0 noVersion=0 verbose=0 install=0 uninstall=0; command typeset allowOptsAfterOperands=1 i=0 optName= isLong=0 prefix= optArg= haveOptArgAttached=0 haveOptArgAsNextArg=0 acceptOptArg=0 needOptArg=0; command typeset -a operands; __typex_reMatch=; while (( $# )); do if __typex_reMatch "$1" '^(-)[a-zA-Z0-9]+.*$' || __typex_reMatch "$1" '^(--)[a-zA-Z0-9]+.*$'; then prefix=${__typex_reMatch[1]}; [[ $prefix == '--' ]] && isLong=1 || isLong=0; for ((i = 1; i < (isLong ? 2 : ${#1}); i++ )) do command typeset acceptOptArg=0 needOptArg=0 haveOptArgAttached=0 haveOptArgAsNextArg=0 optArgAttached= optArgOpt= optArgReq=; if (( isLong )); then optName=${1:2}; __typex_reMatch "$optName" '^([^=]+)=(.*)$' && { optName=${__typex_reMatch[1]}; optArgAttached=${__typex_reMatch[2]}; haveOptArgAttached=1 }; else optName=${1:$i:1}; optArgAttached=${1:$i+1}; (( ${#optArgAttached} >= 1 )) && haveOptArgAttached=1; fi; (( haveOptArgAttached )) && optArgOpt=$optArgAttached optArgReq=$optArgAttached || { (( $# > 1 )) && { optArgReq=$2; haveOptArgAsNextArg=1 } }; case $optName in p | files-only) fileSystemOnly=1 ;; v | verbose) verbose=1 ;; V | skip-version) noVersion=1 ;; i | install-sourcing) install=1 ;; u | uninstall-sourcing) uninstall=1 ;; *) { echo "$thisFuncName: ARGUMENT ERROR: Unknown option: ${prefix}${optName}" 1>&2; __typex_restore; return 2 } ;; esac; (( needOptArg )) && { (( ! haveOptArgAttached && ! haveOptArgAsNextArg )) && { echo "$thisFuncName: ARGUMENT ERROR: Option ${prefix}${optName} is missing its argument." 1>&2; __typex_restore; return 2 } || (( haveOptArgAsNextArg )) && shift }; (( acceptOptArg || needOptArg )) && break; done; else if [[ $1 == '--' ]]; then shift; operands+=("$@"); break; else if (( allowOptsAfterOperands )); then operands+=("$1"); else operands=("$@"); break; fi; fi; fi; shift; done; (( ${#operands[@]} > 0 )) && set -- "${operands[@]}"; unset allowOptsAfterOperands operands i optName isLong prefix optArgAttached haveOptArgAttached haveOptArgAsNextArg acceptOptArg needOptArg; if (( install || uninstall )); then (( !fileSystemOnly && !noVersion && !(install && uninstall) && $# == 0 )) || { echo "$thisFuncName: ARGUMENT ERROR: Incompatible options specified." 1>&2; __typex_restore; return 2 }; (( uninstall )) && install=0; command typeset shellCount=0 okCount=0; for shell in bash ksh zsh; do (( ++shellCount )); if [[ $TYPEX_TEST_ALL_INITFILES != '1' ]]; then if [[ -n $ZSH_VERSION ]]; then command which -p $shell > /dev/null 2>&1 || continue; else command which $shell > /dev/null 2>&1 || continue; fi; fi; __typex_install $shell $install $notSourced "$__typex_scriptpath" && (( ++okCount )); done; (( install && okCount )) && command printf '%s\n' 'Open a new shell tab or window for sourcing to take effect.'; if (( okCount == shellCount )); then __typex_restore; return 0; else __typex_restore; return $(( shellCount - okCount )); fi; fi; if (( $# == 0 )); then names=($(f=$(command ps -o comm= $( (( notSourced )) && command printf $PPID || command printf $$ )); [[ $f =~ ^- ]] && command printf %s "$SHELL" || command printf %s "$f")); fileSystemOnly=1; else names=("$@"); fi; if (( ! fileSystemOnly )); then fileSystemOnly=1; for name in "${names[@]}"; do [[ $name == */* ]] || { fileSystemOnly=0; break }; done; fi; if (( ! fileSystemOnly && notSourced )); then fileSystemOnly=1; if __typex_isParentSupportedShell; then command cat 1>&2 <\` To install sourcing persistently for interactive shells, run \`${__typex_scriptpath##*/} -i\`. Use \`-p\` to suppress this warning if you're only looking for executable *files*. EOF else command cat 1>&2 < /dev/null | command egrep -q ' keyword$' && isKeyword=1; else if [[ -n $ZSH_VERSION ]]; then command type -wa "$name" 2> /dev/null | command egrep -q ' reserved$' && isKeyword=1; else command type -ta "$name" 2> /dev/null | command fgrep -qx 'keyword' && isKeyword=1; fi; fi; if (( isKeyword )); then found=1; keywordOutput=$(command printf '%-10s %s' 'KEYWORD:' "$name"); fi; if [[ -n $keywordOutput && -n $KSH_VERSION ]]; then command printf '%s\n' "$keywordOutput"; fi; def=$(command alias "$name" 2>/dev/null); if [[ -n $def ]]; then found=1; command printf '%-10s %s\n' 'ALIAS:' "${def#alias }"; (( all )) || { __typex_restore; return 0 }; def=$(cut -d= -f2- <<<"$def" | tr -d \'\" | cut -d' ' -f1); typex -- "$def" 2> /dev/null | sed 's/^/ /'; fi; if [[ -n $keywordOutput && -z $KSH_VERSION ]]; then command printf '%s\n' "$keywordOutput"; fi; def=$(command typeset -f "$name" 2>/dev/null); if [[ -n $def ]]; then found=1; command printf '%-10s %s' 'FUNCTION:' "$name()"; if [[ -n $BASH_VERSION ]]; then command declare -F | command egrep -q -- "-fx $name\$" && command printf ' # -x'; fi; command printf '\n'; (( verbose )) && command sed 's/^/ /' <<< "$def"; (( all )) || { __typex_restore; return 0 }; fi; if [[ -n $KSH_VERSION ]]; then command builtin | command fgrep -qx -- "$name" && isBuiltIn=1; else if [[ -n $ZSH_VERSION ]]; then command type -wa -- "$name" 2> /dev/null | command egrep -q ':\s+builtin$' && isBuiltIn=1; else command type -ta -- "$name" 2> /dev/null | command fgrep -qx 'builtin' && isBuiltIn=1; fi; fi; if (( isBuiltIn )); then command printf '%-10s %s\n' 'BUILTIN:' "$name"; (( all )) || { __typex_restore; return 0 }; found=1; fi; fi; files=; if (( isExplicitPath )) || [[ $name == '.' ]]; then if [[ -d $name ]]; then files=$(command cd "$name" && command echo "$PWD"); else if [[ -e $name || -L $name ]]; then [[ ! -e $name ]] && brokenSymlink=1; [[ -n $KSH_VERSION && $name =~ ^'../.' ]] && name="${PWD%/}/$name"; files=$(command cd -- "$(command dirname -- "$name")" && command echo "${PWD%/}/")$(command basename -- "$name"); [[ $files =~ / ]] || { __typex_restore; return 1 }; else :; fi; fi; else if [[ -n $ZSH_VERSION ]]; then files=$(command which -ap -- "$name" 2>/dev/null) || files=''; else files=$(command which -a -- "$name" 2>/dev/null) || files=''; fi; fi; if [[ -n $files ]]; then found=1; while command read -r file; do (( brokenSymlink )) || extraOpt='-L'; fileType=$(command file -b $extraOpt -- "$file"); if [[ -d $file ]]; then fileCategory='DIRECTORY:'; else if [[ -x $file ]]; then scriptType=$(command egrep -o '(POSIX )?(\w+ )script' <<<"$fileType"); [[ -z $scriptType ]] && command egrep -q '\' <<< "$fileType" && scriptType='script w/o shebang line'; [[ -n $scriptType ]] && fileCategory='SCRIPT:' || fileCategory='BINARY:'; else fileCategory='FILE:'; fi; fi; fileLinkChain=$(__typex_rreadlinkchain "$file"); if [[ ! $fileLinkChain =~ ' ' ]]; then trueFile=$fileLinkChain; if [[ "$file" != "$trueFile" ]]; then command printf '%-10s %s -> %s' "$fileCategory" "$file" "$fileLinkChain"; else command printf '%-10s %s' "$fileCategory" "$file"; fi; else trueFile=$(command tail -n 1 <<<"$fileLinkChain"); command printf '%-10s %s' "$fileCategory" "$(command awk -v RS= -v sep=' -> ' '{ gsub("\n$", ""); gsub("\n", "@" sep); printf "%s", $0 }' <<<"$fileLinkChain")"; fi; if [[ -d $file ]]; then :; else if [[ -x $file ]]; then [[ -n $scriptType ]] && printf ' (%s)' "$scriptType"; ver=; if (( ! noVersion )); then ver=$("$file" --version &1 | command sed '/^$/d; q' | command fgrep -v -- '--version' | command fgrep -vi -- 'unknown invalid illegal unrecognized not recognized' | command egrep -i -e '[0-9]\.' -e 'version' -e 'build' ); fi; [[ -z $ver ]] && ver=$(__typex_getFileTimestamp "$trueFile" m '%Y-%m-%d'); printf ' [%s]' "$ver"; else printf ' (%s)' "$fileType"; fi; fi; if (( verbose )); then while command read -r thisfile; do command printf '\n %s' "$(command ls -dFAhl -- "$thisfile" | command cut -d/ -f1)"; done <<< "${fileLinkChain:-$file}"; if [[ ! -d $file ]]; then if [[ -n $scriptType ]]; then command printf '\n %s' "$(command head -n 1 "$file")"; else if [[ -x $file ]]; then command printf '\n %s' "$(sed '1! s/^/ /' <<<"$fileType")"; fi; fi; fi; fi; command printf '\n'; (( all )) || break; done <<< "$files"; fi; if (( ! found )); then (( ++numNotFound )); if (( isExplicitPath )); then errMsgSuffix=": No such file or directory, or insufficient permissions for inspection."; else (( fileSystemOnly )) && errMsgSuffix=' is not an executable in the PATH.' || errMsgSuffix=' is neither an alias, keyword, function, builtin, nor an executable in the PATH.'; [[ -e $name ]] && errMsgSuffix+=' However, it does exist as a filesystem item in the current directory. To target that, prefix with "./"'; fi; command printf '%s\n' "$thisFuncName: \"${name}\"${errMsgSuffix}" 1>&2; fi; done; __typex_restore; return $numNotFound } up () { local dir='../'; [[ "$1" == '-h' || "$1" == '--help' ]] && { echo -e "usage:\n\t$FUNCNAME [n]\n\t$FUNCNAME dirname\n Moves up N levels in the path to the current working directory, 1 by default.\n If DIRNAME is given, it must be the full name of an ancestral directory (case does not matter).\n If there are multiple matches, the one *lowest* in the hierarchy is changed to." && return 0 }; if [[ -n "$1" ]]; then if [[ $1 =~ ^[0-9]+$ ]]; then local strpath=$( printf "%${1}s" ); dir=${strpath// /$dir}; else if [[ $1 =~ ^/ ]]; then dir=$1; else local wdLower=$(echo -n "$PWD" | tr '[:upper:]' '[:lower:]'); local tokenLower=$(echo -n "$1" | tr '[:upper:]' '[:lower:]'); local newParentDirLower=${wdLower%/$tokenLower/*}; [[ "$newParentDirLower" == "$wdLower" ]] && { echo "$FUNCNAME: No ancestral directory named '$1' found." 1>&2; return 1 }; local targetDirPathLength=$(( ${#newParentDirLower} + 1 + ${#tokenLower} )); dir=${PWD:0:$targetDirPathLength}; fi; fi; fi; pushd "$dir" > /dev/null } vmrun () { "/Applications/VMware Fusion.app/Contents/Library/vmrun" "$@" } vo () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&1 | $FUNCNAME' instead of just '| $FUNCNAME'. - With COMMAND specified, executes it, and captures both its stdout and stderr output. If COMMAND returns a nonzero exit code, a warning is printed to stderr. This utility itself, however, always returns exit code 0. If the output captured contains ANSI color escape sequences or troff formatting such as from `man` output, such formatting is automatically removed. Examples: $FUNCNAME ls *.txt nosuch ls *.txt nosuch | $FUNCNAME ls *.txt nosuch 2>&1 | $FUNCNAME EOF return 0; fi local ph=''; [[ $(uname) == 'Darwin' ]] || ph='.XXXXXXXXXX'; local ftemp=$(mktemp -t "$FUNCNAME$ph"); if (( $# )); then ( shopt -s expand_aliases; eval "$@" 2>&1 | stripFormatting > "$ftemp"; [[ ${PIPESTATUS[0]} -eq 0 ]] || echo "$FUNCNAME: WARNING: Command returned nonzero exit code: ${PIPESTATUS[0]}" 1>&2 ); else cat | stripFormatting > "$ftemp"; fi; local editor=$(which -a subl code | fgrep -v -x "$MK_UTIL_FOLDER/subl" | head -n 1); [[ -n $editor ]] || { echo "ERROR: Neither \`code\` nor \`subl\` are in your PATH." 2> /dev/null; exit 1 }; local newWin=1; (( newWin )) && newWinOpt=--new-window; ( { "$editor" --wait $newWinOpt "$ftemp"; rm -f "$ftemp" } & ) } doIt you * The command line being run * The files being read (put the files on a webserver if they are big) If you get the error on smaller/fewer files, please include those instead. parallel: This should not happen. You have found a bug. Please contact and include: * The version number: 20170322 * The bugid: open3-GLOB(0x7fec06235128) shopt -u autocd&>/dev/null; shopt -u cdable_vars&>/dev/null; shopt -u cdspell&>/dev/null; shopt -u checkhash&>/dev/null; shopt -u checkjobs&>/dev/null; shopt -u checkwinsize&>/dev/null; shopt -s cmdhist&>/dev/null; shopt -u compat31&>/dev/null; shopt -u compat32&>/dev/null; shopt -u compat40&>/dev/null; shopt -u compat41&>/dev/null; shopt -u compat42&>/dev/null; shopt -u compat43&>/dev/null; shopt -s complete_fullquote&>/dev/null; shopt -u direxpand&>/dev/null; shopt -u dirspell&>/dev/null; shopt -u dotglob&>/dev/null; shopt -u execfail&>/dev/null; shopt -s expand_aliases&>/dev/null; shopt -s extdebug&>/dev/null; shopt -u extglob&>/dev/null; shopt -s extquote&>/dev/null; shopt -u failglob&>/dev/null; shopt -s force_fignore&>/dev/null; shopt -u globasciiranges&>/dev/null; shopt -u globstar&>/dev/null; shopt -u gnu_errfmt&>/dev/null; shopt -u histappend&>/dev/null; shopt -u histreedit&>/dev/null; shopt -u histverify&>/dev/null; shopt -s hostcomplete&>/dev/null; shopt -u huponexit&>/dev/null; shopt -u inherit_errexit&>/dev/null; shopt -s interactive_comments&>/dev/null; shopt -u lastpipe&>/dev/null; shopt -u lithist&>/dev/null; shopt -u login_shell&>/dev/null; shopt -u mailwarn&>/dev/null; shopt -s no_empty_cmd_completion&>/dev/null; shopt -s nocaseglob&>/dev/null; shopt -u nocasematch&>/dev/null; shopt -u nullglob&>/dev/null; shopt -s progcomp&>/dev/null; shopt -s promptvars&>/dev/null; shopt -u restricted_shell&>/dev/null; shopt -u shift_verbose&>/dev/null; shopt -s sourcepath&>/dev/null; shopt -u xpg_echo&>/dev/null; shopt -s expand_aliases &>/dev/null alias ash='(f=$(ps -o comm= $$); [[ $f =~ ^- ]] && echo $SHELL || which "$f")' alias bi='bundleid' alias bv='echo $BASH_VERSION' alias cdb='cd "$OLDPWD"' alias cpg='"$HOME/Desktop/pg"/cpg' alias dec='de "$@"' alias dn='/dev/null' alias dpg='"$HOME/Desktop/pg"/dpg' alias dt='cat -et' alias e='/Users/jdoe/MkUtil/editf' alias ecc='editf $MK_UTIL_FOLDER/sourced.d/bash_completion.d/custom-completions' alias ecpg='editf "$HOME/Desktop/pg"/cpg' alias edpg='editf "$HOME/Desktop/pg"/dpg' alias eh='enc --html' alias ei='editf ~/.bashrc' alias ejaypg='editf "$HOME/Desktop/pg"/jaypg' alias ekpg='editf "$HOME/Desktop/pg"/kpg' alias enp='editf ~/.nesh_profile.coffee' alias enpg='editf "$HOME/Desktop/pg"/npg' alias ep='editf ~/.bash_profile' alias epg='editf "$HOME/Desktop/pg"/pg' alias epg.cpp='editf "$HOME/Desktop/pg"/pg.cpp' alias epg.cs='editf "$HOME/Desktop/pg"/pg.cs' alias epg.html='editf "$HOME/Desktop/pg"/pg.html' alias epg.md='editf "$HOME/Desktop/pg"/pg.md' alias epg.ts='editf "$HOME/Desktop/pg"/pg.ts' alias epg2='editf "$HOME/Desktop/pg"/pg2' alias epg4='editf "$HOME/Desktop/pg"/pg4' alias epgjxa.scpt='editf "$HOME/Desktop/pg"/pgjxa.scpt' alias ephpg='editf "$HOME/Desktop/pg"/phpg' alias epi='editf ~/.perli_rc' alias eplpg='editf "$HOME/Desktop/pg"/plpg' alias epy3pg='editf "$HOME/Desktop/pg"/py3pg' alias epypg='editf "$HOME/Desktop/pg"/pypg' alias eqcd='editf $MK_UTIL_FOLDER/sourced.d/quickCdDefs' alias erpg='editf "$HOME/Desktop/pg"/rpg' alias es='edits' alias eshallpg='editf "$HOME/Desktop/pg"/shallpg' alias eshpg='editf "$HOME/Desktop/pg"/shpg' alias etclpg='editf "$HOME/Desktop/pg"/tclpg' alias eu='enc --uri' alias ex='enc --xml' alias exppg='editf "$HOME/Desktop/pg"/xppg' alias ezpg='editf "$HOME/Desktop/pg"/zpg' alias fhx='od -t x1' alias fp='fullpath' alias fq='findq' alias fx='findexes' alias gc='git checkout' alias gcb='pbpaste' alias gcm='typex' alias gfs='getFinderSel' alias gl='git log --pretty=oneline' alias gs='git status -b --short' alias gt='git describe --abbrev=0 --tags' alias gvr='git remote -v | awk '\''{ print $2; exit }'\'' | xargs open' alias hd='hexdump' alias hg='echo "(Using MacHg binary via an alias.)"; "/Applications/MacHg.app/Contents/Resources/localhg"' alias imgcat='/Users/jdoe/.iterm2/imgcat' alias imgls='/Users/jdoe/.iterm2/imgls' alias it2attention='/Users/jdoe/.iterm2/it2attention' alias it2check='/Users/jdoe/.iterm2/it2check' alias it2copy='/Users/jdoe/.iterm2/it2copy' alias it2dl='/Users/jdoe/.iterm2/it2dl' alias it2getvar='/Users/jdoe/.iterm2/it2getvar' alias it2setcolor='/Users/jdoe/.iterm2/it2setcolor' alias it2setkeylabel='/Users/jdoe/.iterm2/it2setkeylabel' alias it2ul='/Users/jdoe/.iterm2/it2ul' alias it2universion='/Users/jdoe/.iterm2/it2universion' alias jaypg='"$HOME/Desktop/pg"/jaypg' alias josa='osascript -l JavaScript' alias kbs='keyboardspec' alias kpg='"$HOME/Desktop/pg"/kpg' alias lf='declare -F | awk '\''{ print $3 }'\''' alias lfe='declare -Fx | awk -F'\''[ =]'\'' '\''{ print $3 }'\''' alias lsregister='/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister' alias lsx='fls -FAhl' alias lv='(shopt -so posix; declare | awk -F= '\''{ print $1 }'\'')' alias lve='export -p | awk -F'\''[ =]'\'' '\''{ print $3 }'\''' alias lx='PATH=".:$PATH"' alias m='manx' alias md='mkdir' alias mdp='markdown.pl' alias mg='manxg' alias mmdp='multimarkdown' alias mo='manopt' alias mu='markup-js' alias mw='manw' alias ne='node -e' alias np='node -p' alias npg='"$HOME/Desktop/pg"/npg' alias npmenv='echo "ENTERING CHILD SHELL with npm ENVIRONMENT for $PWD..." && npm run env -- $SHELL || echo "ERROR: You must call this function from an npm package directory; child shell NOT entered." >&2' alias npmh='npm home' alias nr='npm run' alias ns='newscript' alias nsh='nesh -e <(coffee -bp ~/.nesh_profile.coffee)' alias nshc='nesh -c -e ~/.nesh_profile.coffee' alias nt='newtab' alias nw='newwin' alias nx='npm run-script env --' alias o='open' alias oa='open -a' alias oda='od -a' alias odx='od -t x1' alias omd='open -a '\''Marked 2'\''' alias osa='osascript' alias ou='openurl' alias oud='openurl -d' alias p='printf "%s\n"' alias p1='ping -c 1 -t 1' alias pd='perldoc' alias pf='declare -f' alias pg='"$HOME/Desktop/pg"/pg' alias pg.cpp='g++ -o "$HOME/Desktop/pg"/pgb "$HOME/Desktop/pg"/pg.cpp && "$HOME/Desktop/pg"/pgb' alias pg.cs='pushd "$HOME/Desktop/pg"/pg.cs >/dev/null && echo === NOTE: cwd is temporarily ./pg.cs === && dotnet run; popd >/dev/null' alias pg.html='"$HOME/Desktop/pg"/pg.html' alias pg.md='open -a Marked.app -- "$HOME/Desktop/pg"/pg.md' alias pg.ts='printf "Compiling to "$HOME/Desktop/pg"/pg.js (tsc) and invoking (node)..." && tsc "$HOME/Desktop/pg"/pg.ts && printf "\r%*s\r" 79 && node "$HOME/Desktop/pg"/pg.js' alias pg2='"$HOME/Desktop/pg"/pg2' alias pg4='"$HOME/Desktop/pg"/pg4' alias pgjxa.scpt='osascript -l JavaScript "$HOME/Desktop/pg"/pgjxa.scpt' alias phpg='"$HOME/Desktop/pg"/phpg' alias plb='/usr/libexec/PlistBuddy' alias plpg='"$HOME/Desktop/pg"/plpg' alias posh='powershell' alias ptc='pathToClipboard' alias py='python' alias py2='python' alias py3='python3' alias py3pg='"$HOME/Desktop/pg"/py3pg' alias pypg='"$HOME/Desktop/pg"/pypg' alias q='quote' alias rbn='shutdownnow -r' alias ri='{ echo "Reloading the initialization file (~/.bashrc)..."; . ~/.bashrc; }' alias rp='{ echo "Reloading the profile file (~/.bash_profile)..."; . ~/.bash_profile; }' alias rpg='"$HOME/Desktop/pg"/rpg' alias rsi='resizeimages' alias scb='tc' alias sdn='shutdownnow' alias shallpg='"$HOME/Desktop/pg"/shallpg' alias sho='vo' alias shpg='"$HOME/Desktop/pg"/shpg' alias sln='shutdownnow -s' alias st='steroids' alias tcl='rlwrap tclsh' alias tclpg='"$HOME/Desktop/pg"/tclpg' alias tkc='(tkcon &) && osascript <<<$'\''repeat while true\n delay 0.1\n if application "Wish" is running then\n try\n activate application "Wish"\n return\n end try\n end if\nend repeat'\''' alias toascii='iconv -f utf8 -t ascii -c' alias topc='top -l 2 -n 10 -o cpu -stats cpu,command | fgrep -v " top" | tail -n 10' alias tp='typex' alias ts='timestamps' alias ueh='enc -u --html' alias ueu='enc -u --uri' alias uex='enc -u --xml' alias uti='mdls -name kMDItemContentType' alias utis='mdls -name kMDItemContentTypeTree' alias vman='marked-man | cat >/tmp/vman$$ && man /tmp/vman$$' alias vmd='cat >/tmp/vmd$$ && open -a "Marked 2" /tmp/vmd$$' alias wh='which' alias wha='whichapp' alias xppg='"$HOME/Desktop/pg"/xppg' alias zpg='"$HOME/Desktop/pg"/zpg' declare -x Apple_PubSub_Socket_Render="/private/tmp/com.apple.launchd.ZSsLeK3KyX/Render" declare -- BASH="/usr/local/bin/bash4" declare -x CLICOLOR="" declare -x COLORFGBG="0;15" declare -x COLORTERM="truecolor" declare -- COLUMNS="220" declare -x COMP_WORDBREAKS="@ \"'><;|&(:" declare -x DISPLAY="/private/tmp/com.apple.launchd.WdrYFjwfT0/org.macosforge.xquartz:0" declare -x EDITOR="sublwait" declare -x FCEDIT="sublwait" declare -x GEM_HOME="/Users/jdoe/.rvm/gems/ruby-2.4.0" declare -x GEM_PATH="/Users/jdoe/.rvm/gems/ruby-2.4.0:/Users/jdoe/.rvm/gems/ruby-2.4.0@global" declare -i HISTCMD="1" declare -- HISTCONTROL="ignoredups" declare -- HISTFILE="/Users/jdoe/.bash_history" declare -- HISTFILESIZE="500" declare -- HISTSIZE="500" declare -x HOME="/Users/jdoe" declare -- HOSTNAME="MkiMac.home" declare -- HOSTTYPE="x86_64" declare -- IFS=" " declare -x IRBRC="/Users/jdoe/.rvm/rubies/ruby-2.4.0/.irbrc" declare -x ITERM_ORIG_PS1="\$( [ \"\$USER\" = 'root' ] && printf %s \\u:\\w || # sudo { { [ \"\$0\" = 'bash' ] || [ \"\$0\" = '/bin/bash' ] || [ \"\$0\" = '-bash' ]; } && { # bash _PS1 30 # cwd-shortening function if [[ -d .git ]]; then # git repos: show the branch name and, if there are uncommitted changes, append an asterisk printf ' [%s%s]' \"\$(git symbolic-ref --short HEAD 2>/dev/null || echo '(NO HEAD)')\" \"\$([[ -n \$(git status --porcelain) ]] && printf '\\[\\e[0;31m\\]*\\[\\e[0m\\]')\" fi } || printf \"[\$0] \$PWD\" # other shells; note that we can't use coloring in a cross-shell-compatible fashion } printf '\$ ' )" declare -- ITERM_PREEXEC_INTERACTIVE_MODE="" declare -x ITERM_PREV_PS1="\\[133;D;\$?1337;RemoteHost=jdoe@MkiMac.home1337;CurrentDir=/Users/jdoe/Desktop/pg133;A\\]\$( [ \"\$USER\" = 'root' ] && printf %s \\u:\\w || # sudo { { [ \"\$0\" = 'bash' ] || [ \"\$0\" = '/bin/bash' ] || [ \"\$0\" = '-bash' ]; } && { # bash _PS1 30 # cwd-shortening function if [[ -d .git ]]; then # git repos: show the branch name and, if there are uncommitted changes, append an asterisk printf ' [%s%s]' \"\$(git symbolic-ref --short HEAD 2>/dev/null || echo '(NO HEAD)')\" \"\$([[ -n \$(git status --porcelain) ]] && printf '\\[\\e[0;31m\\]*\\[\\e[0m\\]')\" fi } || printf \"[\$0] \$PWD\" # other shells; note that we can't use coloring in a cross-shell-compatible fashion } printf '\$ ' )\\[133;B\\]" declare -x ITERM_PROFILE="Default" declare -x ITERM_SESSION_ID="w0t0p0:F3C22F95-3FCF-4888-A3A1-D57093BD9C50" declare -- ITERM_SHELL_INTEGRATION_INSTALLED="Yes" declare -x LANG="en_US.UTF-8" declare -i LINENO="70" declare -- LINES="75" declare -x LOGNAME="jdoe" declare -- MACHTYPE="x86_64-apple-darwin16.3.0" declare -i MAILCHECK="60" declare -x MK_PLAYGROUND_FOLDER="/Users/jdoe/Desktop/pg" declare -x MK_UTIL_FOLDER="/Users/jdoe/MkUtil" declare -x MK_UTIL_FOLDER_PERSONAL="/Users/jdoe/MkUtil.Win/Users/jdoe" declare -x MY_RUBY_HOME="/Users/jdoe/.rvm/rubies/ruby-2.4.0" declare -x N_PREFIX="/Users/jdoe/n" declare -x OLDPWD="/Users/jdoe" declare -- OPTERR="1" declare -i OPTIND="1" declare -- OSTYPE="darwin16.3.0" declare -x PATH="/Users/jdoe/.rvm/gems/ruby-2.4.0/bin:/Users/jdoe/.rvm/gems/ruby-2.4.0@global/bin:/Users/jdoe/.rvm/rubies/ruby-2.4.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/jdoe/bin:/Users/jdoe/MkUtil:/Users/jdoe/.dotnet:/Users/jdoe/n/bin:/Users/jdoe/.rvm/bin" declare -- PROMPT_COMMAND="iterm2_preexec_invoke_cmd" declare -x PS1="\$( [ \"\$USER\" = 'root' ] && printf %s \\u:\\w || # sudo { { [ \"\$0\" = 'bash' ] || [ \"\$0\" = '/bin/bash' ] || [ \"\$0\" = '-bash' ]; } && { # bash _PS1 30 # cwd-shortening function if [[ -d .git ]]; then # git repos: show the branch name and, if there are uncommitted changes, append an asterisk printf ' [%s%s]' \"\$(git symbolic-ref --short HEAD 2>/dev/null || echo '(NO HEAD)')\" \"\$([[ -n \$(git status --porcelain) ]] && printf '\\[\\e[0;31m\\]*\\[\\e[0m\\]')\" fi } || printf \"[\$0] \$PWD\" # other shells; note that we can't use coloring in a cross-shell-compatible fashion } printf '\$ ' )" declare -- PS2="> " declare -- PS4="+ " declare -x PWD="/Users/jdoe/Desktop/pg" declare -i RANDOM="13804" declare -x RUBY_VERSION="ruby-2.4.0" declare -i SECONDS="91" declare -x SECURITYSESSIONID="186a7" declare -x SHELL="/bin/bash" declare -x SHLVL="2" declare -x SSH_AUTH_SOCK="/private/tmp/com.apple.launchd.QpR2TVefkw/Listeners" declare -x TERM="xterm" declare -x TERM_PROGRAM="iTerm.app" declare -x TERM_PROGRAM_VERSION="3.1.beta.3" declare -x TERM_SESSION_ID="w0t0p0:F3C22F95-3FCF-4888-A3A1-D57093BD9C50" declare -x TMPDIR="/var/folders/19/0lxcl7hd63d6fqd813glqppc0000gn/T/" declare -x USER="jdoe" declare -x XPC_FLAGS="0x0" declare -x XPC_SERVICE_NAME="0" declare -x __CF_USER_TEXT_ENCODING="0x1F5:0x0:0x0" declare -- __git_all_commands="" declare -- __git_diff_algorithms="myers minimal patience histogram" declare -- __git_diff_common_options="--stat --numstat --shortstat --summary --patch-with-stat --name-only --name-status --color --no-color --color-words --no-renames --check --full-index --binary --abbrev --diff-filter= --find-copies-harder --text --ignore-space-at-eol --ignore-space-change --ignore-all-space --ignore-blank-lines --exit-code --quiet --ext-diff --no-ext-diff --no-prefix --src-prefix= --dst-prefix= --inter-hunk-context= --patience --histogram --minimal --raw --word-diff --dirstat --dirstat= --dirstat-by-file --dirstat-by-file= --cumulative --diff-algorithm= " declare -- __git_fetch_options=" --quiet --verbose --append --upload-pack --force --keep --depth= --tags --no-tags --all --prune --dry-run --recurse-submodules= " declare -- __git_fetch_recurse_submodules="yes on-demand no" declare -- __git_flow_config_file_options=" --local --global --system --file= " declare -- __git_format_patch_options=" --stdout --attach --no-attach --thread --thread= --no-thread --numbered --start-number --numbered-files --keep-subject --signoff --signature --no-signature --in-reply-to= --cc= --full-index --binary --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix= --inline --suffix= --ignore-if-in-upstream --subject-prefix= --output-directory --reroll-count --to= --quiet --notes " declare -- __git_log_common_options=" --not --all --branches --tags --remotes --first-parent --merges --no-merges --max-count= --max-age= --since= --after= --min-age= --until= --before= --min-parents= --max-parents= --no-min-parents --no-max-parents " declare -- __git_log_date_formats="relative iso8601 rfc2822 short local default raw" declare -- __git_log_gitk_options=" --dense --sparse --full-history --simplify-merges --simplify-by-decoration --left-right --notes --no-notes " declare -- __git_log_pretty_formats="oneline short medium full fuller email raw format:" declare -- __git_log_shortlog_options=" --author= --committer= --grep= --all-match " declare -- __git_merge_options=" --no-commit --no-stat --log --no-log --squash --strategy --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit --verify-signatures --no-verify-signatures --gpg-sign --quiet --verbose --progress --no-progress " declare -- __git_merge_strategies="" declare -- __git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare " declare -- __git_porcelain_commands="" declare -- __git_push_recurse_submodules="check on-demand" declare -- __git_send_email_confirm_options="always never auto cc compose" declare -- __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all" declare -- __git_whitespacelist="nowarn warn error error-all fix" declare -- __typex_scriptpath="/Users/jdoe/n/bin/typex" declare -- _grep_REGEXP="(.*)" declare -- _ignore_UNDERSCORE="" declare -- _list_alias_BODIES="alias ash bi bv cdb cpg dec dn dpg dt e ecc ecpg edpg eh ei ejaypg ekpg enp enpg ep epg epg.cpp epg.cs epg.html epg.md epg.ts epg2 epg4 epgjxa.scpt ephpg epi eplpg epy3pg epypg eqcd erpg es eshallpg eshpg etclpg eu ex exppg ezpg fhx fp fq fx gc gcb gcm gfs gl gs gt gvr hd hg imgcat imgls it2attention it2check it2copy it2dl it2getvar it2setcolor it2setkeylabel it2ul it2universion jaypg josa kbs kpg lf lfe lsregister lsx lv lve lx m md mdp mg mmdp mo mu mw ne np npg npmenv npmh nr ns nsh nshc nt nw nx o oa oda odx omd osa ou oud p p1 pd pf pg pg.cpp pg.cs pg.html pg.md pg.ts pg2 pg4 pgjxa.scpt phpg plb plpg posh ptc py py2 py3 py3pg pypg q rbn ri rp rpg rsi scb sdn shallpg sho shpg sln st tcl tclpg tkc toascii topc tp ts ueh ueu uex uti utis vman vmd wh wha xppg zpg" declare -- _list_function_BODIES="typeset -f = =awk =gawk =mawk =perl _PS1 __git_aliased_command __git_aliases __git_commands __git_complete __git_complete_file __git_complete_force_with_lease __git_complete_index_file __git_complete_remote_or_refspec __git_complete_revlist __git_complete_revlist_file __git_complete_strategy __git_compute_all_commands __git_compute_merge_strategies __git_compute_porcelain_commands __git_config_get_set_variables __git_count_arguments __git_find_on_cmdline __git_flow_config __git_flow_feature __git_flow_hotfix __git_flow_init __git_flow_list_branches __git_flow_list_local_branches __git_flow_list_remote_branches __git_flow_prefix __git_flow_release __git_flow_support __git_func_wrap __git_has_doubledash __git_heads __git_index_files __git_list_all_commands __git_list_merge_strategies __git_list_porcelain_commands __git_ls_files_helper __git_main __git_match_ctag __git_pretty_aliases __git_reassemble_comp_words_by_ref __git_refs __git_refs2 __git_refs_remotes __git_remotes __git_tags __git_wrap__git_main __git_wrap__gitk_main __gitcomp __gitcomp_file __gitcomp_nl __gitcomp_nl_append __gitcompadd __gitcompappend __gitdir __gitk_main __typex_isParentSupportedShell __typex_isSupportedShell _complete_edits _complete_lx _complete_make _complete_pf _complete_pv _complete_unset _complete_up _get_comp_words_by_ref _git _git_add _git_am _git_apply _git_archive _git_bisect _git_branch _git_bundle _git_checkout _git_cherry _git_cherry_pick _git_clean _git_clone _git_commit _git_config _git_describe _git_diff _git_difftool _git_fetch _git_flow _git_format_patch _git_fsck _git_gc _git_gitk _git_grep _git_help _git_init _git_log _git_ls_files _git_ls_remote _git_ls_tree _git_merge _git_merge_base _git_mergetool _git_mv _git_name_rev _git_notes _git_pull _git_push _git_rebase _git_reflog _git_remote _git_replace _git_reset _git_revert _git_rm _git_send_email _git_shortlog _git_show _git_show_branch _git_stage _git_stash _git_submodule _git_svn _git_tag _git_whatchanged _gitk _npm_completion _tobase af brm calc cdp de dfs difs doIt docker-start docker-stop dsh ec env_parallel f fa fag fas fasu fau fawf fawfc fawfd fawfp fcfg fcu fd fdb fdbp fdl fdla fdt feb febi febo ff fh fhomer fic fif findexes findq fkkac fkkai fl fla flau flsys flu fngb fngm fobt foldIndent foss fpg fpgw fph fppg fpr fpref fprefu fql fqlu fs fsba fsd fsl fslu fsn fsph fss fstp fstpu fsu fsv fsvms ft ftr ftu fu fub fuc fulb fullpath fus fuw fvms fwac getip getips installnode iterm2_begin_osc iterm2_end_osc iterm2_preexec_install iterm2_preexec_invoke_cmd iterm2_preexec_invoke_exec iterm2_print_state_data iterm2_print_user_vars iterm2_print_version_number iterm2_prompt_mark iterm2_prompt_prefix iterm2_prompt_suffix iterm2_set_user_var kill-script list-available-locales lock lsp mang manx manxg mkcd mktempfile npmf npml pathToClipboard pbpaste_html pbpaste_rtf pifs precmd preexec pushdX pv ql resetcolors resume-script sl stripColors stripFormatting suspend-script tc tobin todec tohex tooct trim typex up vmrun vo" declare -x _system_arch="x86_64" declare -x _system_name="OSX" declare -x _system_type="Darwin" declare -x _system_version="10.12" declare -- hist_ent=" 502 . pg; doIt() { echo \"\$\$: [\$*]\"; }; { echo hi; echo there; echo you; echo too; } | env_parallel -n 1 -j 12 doIt {} 2>&1 | vo" declare -- iterm2_hostname="MkiMac.home" declare -- iterm2_ran_preexec="yes" declare -- last_hist_ent=" 502 . pg; doIt() { echo \"\$\$: [\$*]\"; }; { echo hi; echo there; echo you; echo too; } | env_parallel -n 1 -j 12 doIt {} 2>&1 | vo" declare -x rvm_bin_path="/Users/jdoe/.rvm/bin" declare -x rvm_path="/Users/jdoe/.rvm" declare -x rvm_prefix="/Users/jdoe" declare -x rvm_version="1.29.1 (latest)" = () { =perl "$@" } =awk () { local awkBin=${FUNCNAME[1]}; awkBin=${awkBin:-$FUNCNAME}; awkBin=${awkBin#=}; $awkBin "BEGIN { print $* }" } =gawk () { =awk "$@" } =mawk () { =awk "$@" } =perl () { [[ $1 == '-h' || $1 == '--help' ]] && { echo 'Simple command-line calcuations using Perl - the expression specfied is passed as-is to Perl'\''s `print`. Examples: =perl 0x41 =perl 2**10'; return 0 }; perl -le "print $*" } _PS1 () { local pre= name="$PWD" length="$1"; if (( length > 0 )); then [[ "$name" != "${name#$HOME/}" || -z "${name#$HOME}" ]] && pre+='~' name="${name#$HOME}" length=$[length-1]; ((${#name}>$length)) && name="/...${name:$[${#name}-length+4]}"; fi; printf '%s' "$pre$name" } __git_aliased_command () { local word cmdline=$(git --git-dir="$(__gitdir)" config --get "alias.$1"); for word in $cmdline; do case "$word" in \!gitk | gitk) echo "gitk"; return ;; \!*) : shell command alias ;; -*) : option ;; *=*) : setting env ;; git) : git itself ;; \(\)) : skip parens of shell function definition ;; {) : skip start of shell helper function ;; :) : skip null command ;; \'*) : skip opening quote after sh -c ;; *) echo "$word"; return ;; esac; done } __git_aliases () { local i IFS=' '; for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do case "$i" in alias.*) i="${i#alias.}"; echo "${i/ */}" ;; esac; done } __git_commands () { if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}"; then printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"; else git help -a | egrep '^ [a-zA-Z0-9]'; fi } __git_complete () { local wrapper="__git_wrap${2}"; eval "$wrapper () { __git_func_wrap $2 ; }"; complete -o bashdefault -o default -o nospace -F $wrapper $1 2> /dev/null || complete -o default -o nospace -F $wrapper $1 } __git_complete_file () { __git_complete_revlist_file } __git_complete_force_with_lease () { local cur_=$1; case "$cur_" in --*=) ;; *:*) __gitcomp_nl "$(__git_refs)" "" "${cur_#*:}" ;; *) __gitcomp_nl "$(__git_refs)" "" "$cur_" ;; esac } __git_complete_index_file () { local pfx="" cur_="$cur"; case "$cur_" in ?*/*) pfx="${cur_%/*}"; cur_="${cur_##*/}"; pfx="${pfx}/" ;; esac; __gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_" } __git_complete_remote_or_refspec () { local cur_="$cur" cmd="${words[1]}"; local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0; if [ "$cmd" = "remote" ]; then ((c++)); fi; while [ $c -lt $cword ]; do i="${words[c]}"; case "$i" in --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;; --all) case "$cmd" in push) no_complete_refspec=1 ;; fetch) return ;; *) ;; esac ;; -*) ;; *) remote="$i"; break ;; esac; ((c++)); done; if [ -z "$remote" ]; then __gitcomp_nl "$(__git_remotes)"; return; fi; if [ $no_complete_refspec = 1 ]; then return; fi; [ "$remote" = "." ] && remote=; case "$cur_" in *:*) case "$COMP_WORDBREAKS" in *:*) : great ;; *) pfx="${cur_%%:*}:" ;; esac; cur_="${cur_#*:}"; lhs=0 ;; +*) pfx="+"; cur_="${cur_#+}" ;; esac; case "$cmd" in fetch) if [ $lhs = 1 ]; then __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"; else __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"; fi ;; pull | remote) if [ $lhs = 1 ]; then __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"; else __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"; fi ;; push) if [ $lhs = 1 ]; then __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"; else __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"; fi ;; esac } __git_complete_revlist () { __git_complete_revlist_file } __git_complete_revlist_file () { local pfx ls ref cur_="$cur"; case "$cur_" in *..?*:*) return ;; ?*:*) ref="${cur_%%:*}"; cur_="${cur_#*:}"; case "$cur_" in ?*/*) pfx="${cur_%/*}"; cur_="${cur_##*/}"; ls="$ref:$pfx"; pfx="$pfx/" ;; *) ls="$ref" ;; esac; case "$COMP_WORDBREAKS" in *:*) : great ;; *) pfx="$ref:$pfx" ;; esac; __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" 2>/dev/null | sed '/^100... blob /{ s,^.* ,, s,$, , } /^120000 blob /{ s,^.* ,, s,$, , } /^040000 tree /{ s,^.* ,, s,$,/, } s/^.* //')" "$pfx" "$cur_" "" ;; *...*) pfx="${cur_%...*}..."; cur_="${cur_#*...}"; __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" ;; *..*) pfx="${cur_%..*}.."; cur_="${cur_#*..}"; __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" ;; *) __gitcomp_nl "$(__git_refs)" ;; esac } __git_complete_strategy () { __git_compute_merge_strategies; case "$prev" in -s | --strategy) __gitcomp "$__git_merge_strategies"; return 0 ;; esac; case "$cur" in --strategy=*) __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"; return 0 ;; esac; return 1 } __git_compute_all_commands () { test -n "$__git_all_commands" || __git_all_commands=$(__git_list_all_commands) } __git_compute_merge_strategies () { test -n "$__git_merge_strategies" || __git_merge_strategies=$(__git_list_merge_strategies) } __git_compute_porcelain_commands () { __git_compute_all_commands; test -n "$__git_porcelain_commands" || __git_porcelain_commands=$(__git_list_porcelain_commands) } __git_config_get_set_variables () { local prevword word config_file= c=$cword; while [ $c -gt 1 ]; do word="${words[c]}"; case "$word" in --system | --global | --local | --file=*) config_file="$word"; break ;; -f | --file) config_file="$word $prevword"; break ;; esac; prevword=$word; c=$((--c)); done; git --git-dir="$(__gitdir)" config $config_file --list 2> /dev/null | while read -r line; do case "$line" in *.*=*) echo "${line/=*/}" ;; esac; done } __git_count_arguments () { local word i c=0; for ((i=1; i < ${#words[@]}; i++)) do word="${words[i]}"; case "$word" in --) ((c = 0)) ;; "$1") ((c = 0)) ;; ?*) ((c++)) ;; esac; done; printf "%d" $c } __git_find_on_cmdline () { local word subcommand c=1; while [ $c -lt $cword ]; do word="${words[c]}"; for subcommand in $1; do if [ "$subcommand" = "$word" ]; then echo "$subcommand"; return; fi; done; ((c++)); done } __git_flow_config () { local subcommands="list set base"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in set) case "$cur" in --*) __gitcomp " $__git_flow_config_file_options "; return ;; esac; __gitcomp " master develop feature hotfix release support versiontagprefix "; return ;; base) case "$cur" in --*) __gitcomp " set get "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches)"; return ;; *) COMPREPLY=() ;; esac } __git_flow_feature () { local subcommands="list start finish publish track diff rebase checkout pull help delete"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in pull) __gitcomp_nl "$(__git_remotes)"; return ;; checkout) __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; delete) case "$cur" in --*) __gitcomp " --noforce --force --noremote --remote "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; finish) case "$cur" in --*) __gitcomp " --nofetch --fetch --norebase --rebase --nopreserve-merges --preserve-merges --nokeep --keep --keepremote --keeplocal --noforce_delete --force_delete --nosquash --squash --no-ff "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; diff) __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; publish) __gitcomp_nl "$(__git_flow_list_branches 'feature')"; return ;; track) __gitcomp_nl "$(__git_flow_list_branches 'feature')"; return ;; *) COMPREPLY=() ;; esac } __git_flow_hotfix () { local subcommands="list start finish track publish help delete"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in finish) case "$cur" in --*) __gitcomp " --nofetch --fetch --sign --signingkey --message --nomessagefile --messagefile= --nopush --push --nokeep --keep --keepremote --keeplocal --noforce_delete --force_delete --notag --tag --nonobackmerge --nobackmerge "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"; return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"; return ;; delete) case "$cur" in --*) __gitcomp " --noforce --force --noremote --remote "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"; return ;; publish) __gitcomp_nl "$(__git_flow_list_branches 'hotfix')"; return ;; track) __gitcomp_nl "$(__git_flow_list_branches 'hotfix')"; return ;; start) case "$cur" in --*) __gitcomp " --nofetch --fetch "; return ;; esac; return ;; *) COMPREPLY=() ;; esac } __git_flow_init () { local subcommands="help"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; fi; case "$cur" in --*) __gitcomp " --nodefaults --defaults --noforce --force $__git_flow_config_file_options "; return ;; esac } __git_flow_list_branches () { local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"; if [ -n "$1" ]; then local prefix="$(__git_flow_prefix $1)"; git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix | while read -r entry; do eval "$entry"; ref="${ref##$prefix}"; echo "$ref"; done | sort; else git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort; fi } __git_flow_list_local_branches () { if [ -n "$1" ]; then local prefix="$(__git_flow_prefix $1)"; git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix | while read -r entry; do eval "$entry"; ref="${ref#$prefix}"; echo "$ref"; done | sort; else git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort; fi } __git_flow_list_remote_branches () { local prefix="$(__git_flow_prefix $1)"; local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"; git for-each-ref --shell --format='%(refname:short)' refs/remotes/$origin/$prefix | while read -r entry; do eval "$entry"; ref="${ref##$prefix}"; echo "$ref"; done | sort } __git_flow_prefix () { case "$1" in feature | release | hotfix | support) git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/"; return ;; esac } __git_flow_release () { local subcommands="list start finish track publish help delete"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in finish) case "$cur" in --*) __gitcomp " --nofetch --fetch --sign --signingkey --message --nomessagefile --messagefile= --nopush --push --nokeep --keep --keepremote --keeplocal --noforce_delete --force_delete --notag --tag --nonobackmerge --nobackmerge --nosquash --squash "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'release')"; return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'release')"; return ;; delete) case "$cur" in --*) __gitcomp " --noforce --force --noremote --remote "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'release')"; return ;; publish) __gitcomp_nl "$(__git_flow_list_branches 'release')"; return ;; track) __gitcomp_nl "$(__git_flow_list_branches 'release')"; return ;; start) case "$cur" in --*) __gitcomp " --nofetch --fetch "; return ;; esac; return ;; *) COMPREPLY=() ;; esac } __git_flow_support () { local subcommands="list start help"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in start) case "$cur" in --*) __gitcomp " --nofetch --fetch "; return ;; esac; return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'support')"; return ;; *) COMPREPLY=() ;; esac } __git_func_wrap () { local cur words cword prev; _get_comp_words_by_ref -n =: cur words cword prev; $1 } __git_has_doubledash () { local c=1; while [ $c -lt $cword ]; do if [ "--" = "${words[c]}" ]; then return 0; fi; ((c++)); done; return 1 } __git_heads () { local dir="$(__gitdir)"; if [ -d "$dir" ]; then git --git-dir="$dir" for-each-ref --format='%(refname:short)' refs/heads; return; fi } __git_index_files () { local dir="$(__gitdir)" root="${2-.}" file; if [ -d "$dir" ]; then __git_ls_files_helper "$root" "$1" | while read -r file; do case "$file" in ?*/*) echo "${file%%/*}" ;; *) echo "$file" ;; esac; done | sort | uniq; fi } __git_list_all_commands () { local i IFS=" "' '; for i in $(__git_commands); do case $i in *--*) : helper pattern ;; *) echo $i ;; esac; done } __git_list_merge_strategies () { git merge -s help 2>&1 | sed -n -e '/[Aa]vailable strategies are: /,/^$/{ s/\.$// s/.*:// s/^[ ]*// s/[ ]*$// p }' } __git_list_porcelain_commands () { local i IFS=" "' '; __git_compute_all_commands; for i in $__git_all_commands; do case $i in *--*) : helper pattern ;; applymbox) : ask gittus ;; applypatch) : ask gittus ;; archimport) : import ;; cat-file) : plumbing ;; check-attr) : plumbing ;; check-ignore) : plumbing ;; check-mailmap) : plumbing ;; check-ref-format) : plumbing ;; checkout-index) : plumbing ;; commit-tree) : plumbing ;; count-objects) : infrequent ;; credential-cache) : credentials helper ;; credential-store) : credentials helper ;; cvsexportcommit) : export ;; cvsimport) : import ;; cvsserver) : daemon ;; daemon) : daemon ;; diff-files) : plumbing ;; diff-index) : plumbing ;; diff-tree) : plumbing ;; fast-import) : import ;; fast-export) : export ;; fsck-objects) : plumbing ;; fetch-pack) : plumbing ;; fmt-merge-msg) : plumbing ;; for-each-ref) : plumbing ;; hash-object) : plumbing ;; http-*) : transport ;; index-pack) : plumbing ;; init-db) : deprecated ;; local-fetch) : plumbing ;; ls-files) : plumbing ;; ls-remote) : plumbing ;; ls-tree) : plumbing ;; mailinfo) : plumbing ;; mailsplit) : plumbing ;; merge-*) : plumbing ;; mktree) : plumbing ;; mktag) : plumbing ;; pack-objects) : plumbing ;; pack-redundant) : plumbing ;; pack-refs) : plumbing ;; parse-remote) : plumbing ;; patch-id) : plumbing ;; prune) : plumbing ;; prune-packed) : plumbing ;; quiltimport) : import ;; read-tree) : plumbing ;; receive-pack) : plumbing ;; remote-*) : transport ;; rerere) : plumbing ;; rev-list) : plumbing ;; rev-parse) : plumbing ;; runstatus) : plumbing ;; sh-setup) : internal ;; shell) : daemon ;; show-ref) : plumbing ;; send-pack) : plumbing ;; show-index) : plumbing ;; ssh-*) : transport ;; stripspace) : plumbing ;; symbolic-ref) : plumbing ;; unpack-file) : plumbing ;; unpack-objects) : plumbing ;; update-index) : plumbing ;; update-ref) : plumbing ;; update-server-info) : daemon ;; upload-archive) : plumbing ;; upload-pack) : plumbing ;; write-tree) : plumbing ;; var) : infrequent ;; verify-pack) : infrequent ;; verify-tag) : plumbing ;; *) echo $i ;; esac; done } __git_ls_files_helper () { ( test -n "${CDPATH+set}" && unset CDPATH; cd "$1"; if [ "$2" == "--committable" ]; then git diff-index --name-only --relative HEAD; else git ls-files --exclude-standard $2; fi ) 2> /dev/null } __git_main () { local i c=1 command __git_dir; while [ $c -lt $cword ]; do i="${words[c]}"; case "$i" in --git-dir=*) __git_dir="${i#--git-dir=}" ;; --git-dir) ((c++)); __git_dir="${words[c]}" ;; --bare) __git_dir="." ;; --help) command="help"; break ;; -c | --work-tree | --namespace) ((c++)) ;; -*) ;; *) command="$i"; break ;; esac; ((c++)); done; if [ -z "$command" ]; then case "$cur" in --*) __gitcomp " --paginate --no-pager --git-dir= --bare --version --exec-path --exec-path= --html-path --man-path --info-path --work-tree= --namespace= --no-replace-objects --help " ;; *) __git_compute_porcelain_commands; __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;; esac; return; fi; local completion_func="_git_${command//-/_}"; declare -f $completion_func > /dev/null && $completion_func && return; local expansion=$(__git_aliased_command "$command"); if [ -n "$expansion" ]; then words[1]=$expansion; completion_func="_git_${expansion//-/_}"; declare -f $completion_func > /dev/null && $completion_func; fi } __git_match_ctag () { awk "/^${1////\\/}/ { print \$1 }" "$2" } __git_pretty_aliases () { local i IFS=' '; for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do case "$i" in pretty.*) i="${i#pretty.}"; echo "${i/ */}" ;; esac; done } __git_reassemble_comp_words_by_ref () { local exclude i j first; exclude="${1//[^$COMP_WORDBREAKS]}"; cword_=$COMP_CWORD; if [ -z "$exclude" ]; then words_=("${COMP_WORDS[@]}"); return; fi; for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)) do first=t; while [ $i -gt 0 ] && [ -n "${COMP_WORDS[$i]}" ] && [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]; do if [ $j -ge 2 ] && [ -n "$first" ]; then ((j--)); fi; first=; words_[$j]=${words_[j]}${COMP_WORDS[i]}; if [ $i = $COMP_CWORD ]; then cword_=$j; fi; if (($i < ${#COMP_WORDS[@]} - 1)); then ((i++)); else return; fi; done; words_[$j]=${words_[j]}${COMP_WORDS[i]}; if [ $i = $COMP_CWORD ]; then cword_=$j; fi; done } __git_refs () { local i hash dir="$(__gitdir "${1-}")" track="${2-}"; local format refs; if [ -d "$dir" ]; then case "$cur" in refs | refs/*) format="refname"; refs="${cur%/*}"; track="" ;; *) for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do if [ -e "$dir/$i" ]; then echo $i; fi; done; format="refname:short"; refs="refs/tags refs/heads refs/remotes" ;; esac; git --git-dir="$dir" for-each-ref --format="%($format)" $refs; if [ -n "$track" ]; then local ref entry; git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" "refs/remotes/" | while read -r entry; do eval "$entry"; ref="${ref#*/}"; if [[ "$ref" == "$cur"* ]]; then echo "$ref"; fi; done | sort | uniq -u; fi; return; fi; case "$cur" in refs | refs/*) git ls-remote "$dir" "$cur*" 2> /dev/null | while read -r hash i; do case "$i" in *^{}) ;; *) echo "$i" ;; esac; done ;; *) echo "HEAD"; git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##" ;; esac } __git_refs2 () { local i; for i in $(__git_refs "$1"); do echo "$i:$i"; done } __git_refs_remotes () { local i hash; git ls-remote "$1" 'refs/heads/*' 2> /dev/null | while read -r hash i; do echo "$i:refs/remotes/$1/${i#refs/heads/}"; done } __git_remotes () { local i IFS=' ' d="$(__gitdir)"; test -d "$d/remotes" && ls -1 "$d/remotes"; for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do i="${i#remote.}"; echo "${i/.url*/}"; done } __git_tags () { local dir="$(__gitdir)"; if [ -d "$dir" ]; then git --git-dir="$dir" for-each-ref --format='%(refname:short)' refs/tags; return; fi } __git_wrap__git_main () { __git_func_wrap __git_main } __git_wrap__gitk_main () { __git_func_wrap __gitk_main } __gitcomp () { local cur_="${3-$cur}"; case "$cur_" in --*=) ;; *) local c i=0 IFS=' '; for c in $1; do c="$c${4-}"; if [[ $c == "$cur_"* ]]; then case $c in --*=* | *.) ;; *) c="$c " ;; esac; COMPREPLY[i++]="${2-}$c"; fi; done ;; esac } __gitcomp_file () { local IFS=' '; __gitcompadd "$1" "${2-}" "${3-$cur}" ""; compopt -o filenames +o nospace 2> /dev/null || compgen -f /non-existing-dir/ > /dev/null } __gitcomp_nl () { COMPREPLY=(); __gitcomp_nl_append "$@" } __gitcomp_nl_append () { local IFS=' '; __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }" } __gitcompadd () { COMPREPLY=(); __gitcompappend "$@" } __gitcompappend () { local i=${#COMPREPLY[@]}; for x in $1; do if [[ "$x" == "$3"* ]]; then COMPREPLY[i++]="$2$x$4"; fi; done } __gitdir () { if [ -z "${1-}" ]; then if [ -n "${__git_dir-}" ]; then echo "$__git_dir"; else if [ -n "${GIT_DIR-}" ]; then test -d "${GIT_DIR-}" || return 1; echo "$GIT_DIR"; else if [ -d .git ]; then echo .git; else git rev-parse --git-dir 2> /dev/null; fi; fi; fi; else if [ -d "$1/.git" ]; then echo "$1/.git"; else echo "$1"; fi; fi } __gitk_main () { __git_has_doubledash && return; local g="$(__gitdir)"; local merge=""; if [ -f "$g/MERGE_HEAD" ]; then merge="--merge"; fi; case "$cur" in --*) __gitcomp " $__git_log_common_options $__git_log_gitk_options $merge "; return ;; esac; __git_complete_revlist } __typex_isParentSupportedShell () { case "$(command basename -- "$(command ps -o comm= $PPID | command sed 's/^-//')")" in bash | ksh | zsh) return 0 ;; esac; return 1 } __typex_isSupportedShell () { [ -n "$BASH_VERSION" ] && return 0; [ -n "$KSH_VERSION" ] && return 0; [ -n "$ZSH_VERSION" ] && return 0; return 1 } _complete_edits () { local util utils; local token=${COMP_WORDS[$COMP_CWORD]}; local tokenLen=${#token}; if [[ $(uname) == 'Darwin' ]]; then IFS=' ' read -d '' -ra utils < <(find "$MK_UTIL_FOLDER" "$MK_UTIL_FOLDER/sourced.d" -type f -perm -a=x -exec basename -a {} +); else IFS=' ' read -d '' -ra utils < <(find "$MK_UTIL_FOLDER" "$MK_UTIL_FOLDER/sourced.d" -type f -perm -a=x -printf '%f\n'); fi; local nocasematchWasOff=0; shopt nocasematch > /dev/null || nocasematchWasOff=1; (( nocasematchWasOff )) && shopt -s nocasematch; COMPREPLY=(); for util in "${utils[@]}"; do if [[ ${util:0:$(( tokenLen ))} == "$token" ]]; then COMPREPLY+=("$(printf '%q' "$util")"); fi; done; (( nocasematchWasOff )) && shopt -u nocasematch } _complete_lx () { local localExeDir='.'; local token=${COMP_WORDS[$COMP_CWORD]}; local tokenLen=${#token}; if [[ $(uname) == 'Darwin' ]]; then IFS=' ' read -d '' -ra localExes < <(find "$localExeDir" -maxdepth 1 -type f -perm -a=x -exec basename -a {} +); else IFS=' ' read -d '' -ra localExes < <(find "$localExeDir" -maxdepth 1 -type f -executable -printf '%f\n'); fi; local nocasematchWasOff=0; shopt nocasematch > /dev/null || nocasematchWasOff=1; (( nocasematchWasOff )) && shopt -s nocasematch; COMPREPLY=(); for localExe in "${localExes[@]}"; do if [[ ${localExe:0:$(( tokenLen ))} == "$token" ]]; then COMPREPLY+=("$(printf '%q' "$localExe")"); fi; done; (( nocasematchWasOff )) && shopt -u nocasematch } _complete_make () { local token=${COMP_WORDS[$COMP_CWORD]}; local targets=$(make -pRrq : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($1 !~ "^[#.]") {print $1}}' | egrep -v '^[^[:alnum:]]' | sort | xargs); COMPREPLY=($(compgen -W "$targets" -- "$token")) } _complete_pf () { COMPREPLY=($(compgen -A function -- "${COMP_WORDS[$COMP_CWORD]}")) } _complete_pv () { local varNames=$(compgen -v); local token=${COMP_WORDS[$COMP_CWORD]}; local mustReset=$(shopt -q nocasematch; echo $?); shopt -s nocasematch; [[ "${token:0:1}" == '$' ]] && token=${token:1}; local matches w; matches=(); if [[ -n $token ]]; then for w in $varNames; do if [[ "$w" == "$token"* ]]; then matches+=("$w"); fi; done; else matches=($varNames); fi; (( mustReset )) && shopt -u nocasematch; COMPREPLY=("${matches[@]}") } _complete_unset () { local token=${COMP_WORDS[$COMP_CWORD]}; local funcAndVarNames=$(compgen -A function; compgen -A variable); local mustReset=$(shopt -q nocasematch; echo $?); shopt -s nocasematch; [[ "${token:0:1}" == '$' ]] && token=${token:1}; local matches w; matches=(); if [[ -n $token ]]; then for w in $funcAndVarNames; do if [[ "$w" == "$token"* ]]; then matches+=("$w"); fi; done; else matches=($funcAndVarNames); fi; (( mustReset )) && shopt -u nocasematch; COMPREPLY=("${matches[@]}") } _complete_up () { COMPREPLY=(); local curToken=${COMP_WORDS[COMP_CWORD]}; curToken=${curToken//'\'}; if [[ $curToken =~ ^/ ]]; then local IFS=' '; COMPREPLY=($(compgen -o dirnames -- "$curToken")); else if [[ $curToken =~ ^[0-9]+/? ]]; then local strpath=$( printf "%${curToken%%/*}s" ); local upDirSpec=${strpath// /../}; local dir=$(cd "$upDirSpec"; echo -n "$PWD/"); if [[ "$dir" == '//' ]]; then dir='/'; fi; COMPREPLY=("$dir"); else local caseInsensitive=0; bind -v | egrep -i '\bcompletion-ignore-case[[:space:]]+on\b' &> /dev/null && caseInsensitive=1; local nocasematchWasOff=0; if (( caseInsensitive )); then nocasematchWasOff=1; shopt nocasematch > /dev/null && nocasematchWasOff=0; (( nocasematchWasOff )) && shopt -s nocasematch > /dev/null; fi; local pathSoFar=''; local matchingPath=''; local parentPath=${PWD%/*}; local IFS='/'; local name; for name in ${parentPath:1}; do pathSoFar+=/$name; if [[ "$name" == "$curToken"* ]]; then matchingPath="$pathSoFar/"; fi; done; (( caseInsensitive && nocasematchWasOff )) && shopt -u nocasematch > /dev/null; [[ -n "$matchingPath" ]] && COMPREPLY=("$matchingPath"); fi; fi } _get_comp_words_by_ref () { local exclude cur_ words_ cword_; if [ "$1" = "-n" ]; then exclude=$2; shift 2; fi; __git_reassemble_comp_words_by_ref "$exclude"; cur_=${words_[cword_]}; while [ $# -gt 0 ]; do case "$1" in cur) cur=$cur_ ;; prev) prev=${words_[$cword_-1]} ;; words) words=("${words_[@]}") ;; cword) cword=$cword_ ;; esac; shift; done } _git () { __git_wrap__git_main } _git_add () { case "$cur" in --*) __gitcomp " --interactive --refresh --patch --update --dry-run --ignore-errors --intent-to-add "; return ;; esac; __git_complete_index_file "--others --modified --directory --no-empty-directory" } _git_am () { local dir="$(__gitdir)"; if [ -d "$dir"/rebase-apply ]; then __gitcomp "--skip --continue --resolved --abort"; return; fi; case "$cur" in --whitespace=*) __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"; return ;; --*) __gitcomp " --3way --committer-date-is-author-date --ignore-date --ignore-whitespace --ignore-space-change --interactive --keep --no-utf8 --signoff --utf8 --whitespace= --scissors "; return ;; esac } _git_apply () { case "$cur" in --whitespace=*) __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"; return ;; --*) __gitcomp " --stat --numstat --summary --check --index --cached --index-info --reverse --reject --unidiff-zero --apply --no-add --exclude= --ignore-whitespace --ignore-space-change --whitespace= --inaccurate-eof --verbose "; return ;; esac } _git_archive () { case "$cur" in --format=*) __gitcomp "$(git archive --list)" "" "${cur##--format=}"; return ;; --remote=*) __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"; return ;; --*) __gitcomp " --format= --list --verbose --prefix= --remote= --exec= "; return ;; esac; __git_complete_file } _git_bisect () { __git_has_doubledash && return; local subcommands="start bad good skip reset visualize replay log run"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then if [ -f "$(__gitdir)"/BISECT_START ]; then __gitcomp "$subcommands"; else __gitcomp "replay start"; fi; return; fi; case "$subcommand" in bad | good | reset | skip | start) __gitcomp_nl "$(__git_refs)" ;; *) ;; esac } _git_branch () { local i c=1 only_local_ref="n" has_r="n"; while [ $c -lt $cword ]; do i="${words[c]}"; case "$i" in -d | -m) only_local_ref="y" ;; -r) has_r="y" ;; esac; ((c++)); done; case "$cur" in --set-upstream-to=*) __gitcomp "$(__git_refs)" "" "${cur##--set-upstream-to=}" ;; --*) __gitcomp " --color --no-color --verbose --abbrev= --no-abbrev --track --no-track --contains --merged --no-merged --set-upstream-to= --edit-description --list --unset-upstream " ;; *) if [ $only_local_ref = "y" -a $has_r = "n" ]; then __gitcomp_nl "$(__git_heads)"; else __gitcomp_nl "$(__git_refs)"; fi ;; esac } _git_bundle () { local cmd="${words[2]}"; case "$cword" in 2) __gitcomp "create list-heads verify unbundle" ;; 3) ;; *) case "$cmd" in create) __git_complete_revlist ;; esac ;; esac } _git_checkout () { __git_has_doubledash && return; case "$cur" in --conflict=*) __gitcomp "diff3 merge" "" "${cur##--conflict=}" ;; --*) __gitcomp " --quiet --ours --theirs --track --no-track --merge --conflict= --orphan --patch " ;; *) local flags="--track --no-track --no-guess" track=1; if [ -n "$(__git_find_on_cmdline "$flags")" ]; then track=''; fi; __gitcomp_nl "$(__git_refs '' $track)" ;; esac } _git_cherry () { __gitcomp "$(__git_refs)" } _git_cherry_pick () { local dir="$(__gitdir)"; if [ -f "$dir"/CHERRY_PICK_HEAD ]; then __gitcomp "--continue --quit --abort"; return; fi; case "$cur" in --*) __gitcomp "--edit --no-commit --signoff --strategy= --mainline" ;; *) __gitcomp_nl "$(__git_refs)" ;; esac } _git_clean () { case "$cur" in --*) __gitcomp "--dry-run --quiet"; return ;; esac; __git_complete_index_file "--others --directory" } _git_clone () { case "$cur" in --*) __gitcomp " --local --no-hardlinks --shared --reference --quiet --no-checkout --bare --mirror --origin --upload-pack --template= --depth --single-branch --branch "; return ;; esac } _git_commit () { case "$prev" in -c | -C) __gitcomp_nl "$(__git_refs)" "" "${cur}"; return ;; esac; case "$cur" in --cleanup=*) __gitcomp "default strip verbatim whitespace " "" "${cur##--cleanup=}"; return ;; --reuse-message=* | --reedit-message=* | --fixup=* | --squash=*) __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"; return ;; --untracked-files=*) __gitcomp "all no normal" "" "${cur##--untracked-files=}"; return ;; --*) __gitcomp " --all --author= --signoff --verify --no-verify --edit --no-edit --amend --include --only --interactive --dry-run --reuse-message= --reedit-message= --reset-author --file= --message= --template= --cleanup= --untracked-files --untracked-files= --verbose --quiet --fixup= --squash= "; return ;; esac; if git rev-parse --verify --quiet HEAD > /dev/null; then __git_complete_index_file "--committable"; else __git_complete_index_file "--cached"; fi } _git_config () { case "$prev" in branch.*.remote | branch.*.pushremote) __gitcomp_nl "$(__git_remotes)"; return ;; branch.*.merge) __gitcomp_nl "$(__git_refs)"; return ;; branch.*.rebase) __gitcomp "false true"; return ;; remote.pushdefault) __gitcomp_nl "$(__git_remotes)"; return ;; remote.*.fetch) local remote="${prev#remote.}"; remote="${remote%.fetch}"; if [ -z "$cur" ]; then __gitcomp_nl "refs/heads/" "" "" ""; return; fi; __gitcomp_nl "$(__git_refs_remotes "$remote")"; return ;; remote.*.push) local remote="${prev#remote.}"; remote="${remote%.push}"; __gitcomp_nl "$(git --git-dir="$(__gitdir)" for-each-ref --format='%(refname):%(refname)' refs/heads)"; return ;; pull.twohead | pull.octopus) __git_compute_merge_strategies; __gitcomp "$__git_merge_strategies"; return ;; color.branch | color.diff | color.interactive | color.showbranch | color.status | color.ui) __gitcomp "always never auto"; return ;; color.pager) __gitcomp "false true"; return ;; color.*.*) __gitcomp " normal black red green yellow blue magenta cyan white bold dim ul blink reverse "; return ;; diff.submodule) __gitcomp "log short"; return ;; help.format) __gitcomp "man info web html"; return ;; log.date) __gitcomp "$__git_log_date_formats"; return ;; sendemail.aliasesfiletype) __gitcomp "mutt mailrc pine elm gnus"; return ;; sendemail.confirm) __gitcomp "$__git_send_email_confirm_options"; return ;; sendemail.suppresscc) __gitcomp "$__git_send_email_suppresscc_options"; return ;; --get | --get-all | --unset | --unset-all) __gitcomp_nl "$(__git_config_get_set_variables)"; return ;; *.*) return ;; esac; case "$cur" in --*) __gitcomp " --system --global --local --file= --list --replace-all --get --get-all --get-regexp --add --unset --unset-all --remove-section --rename-section "; return ;; branch.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_"; return ;; branch.*) local pfx="${cur%.*}." cur_="${cur#*.}"; __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."; __gitcomp_nl_append 'autosetupmerge autosetuprebase ' "$pfx" "$cur_"; return ;; guitool.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp " argprompt cmd confirm needsfile noconsole norescan prompt revprompt revunmerged title " "$pfx" "$cur_"; return ;; difftool.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "cmd path" "$pfx" "$cur_"; return ;; man.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "cmd path" "$pfx" "$cur_"; return ;; mergetool.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"; return ;; pager.*) local pfx="${cur%.*}." cur_="${cur#*.}"; __git_compute_all_commands; __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"; return ;; remote.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp " url proxy fetch push mirror skipDefaultUpdate receivepack uploadpack tagopt pushurl " "$pfx" "$cur_"; return ;; remote.*) local pfx="${cur%.*}." cur_="${cur#*.}"; __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."; __gitcomp_nl_append "pushdefault" "$pfx" "$cur_"; return ;; url.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"; return ;; esac; __gitcomp " add.ignoreErrors advice.commitBeforeMerge advice.detachedHead advice.implicitIdentity advice.pushNonFastForward advice.resolveConflict advice.statusHints alias. am.keepcr apply.ignorewhitespace apply.whitespace branch.autosetupmerge branch.autosetuprebase browser. clean.requireForce color.branch color.branch.current color.branch.local color.branch.plain color.branch.remote color.decorate.HEAD color.decorate.branch color.decorate.remoteBranch color.decorate.stash color.decorate.tag color.diff color.diff.commit color.diff.frag color.diff.func color.diff.meta color.diff.new color.diff.old color.diff.plain color.diff.whitespace color.grep color.grep.context color.grep.filename color.grep.function color.grep.linenumber color.grep.match color.grep.selected color.grep.separator color.interactive color.interactive.error color.interactive.header color.interactive.help color.interactive.prompt color.pager color.showbranch color.status color.status.added color.status.changed color.status.header color.status.nobranch color.status.untracked color.status.updated color.ui commit.status commit.template core.abbrev core.askpass core.attributesfile core.autocrlf core.bare core.bigFileThreshold core.compression core.createObject core.deltaBaseCacheLimit core.editor core.eol core.excludesfile core.fileMode core.fsyncobjectfiles core.gitProxy core.ignoreStat core.ignorecase core.logAllRefUpdates core.loosecompression core.notesRef core.packedGitLimit core.packedGitWindowSize core.pager core.preferSymlinkRefs core.preloadindex core.quotepath core.repositoryFormatVersion core.safecrlf core.sharedRepository core.sparseCheckout core.symlinks core.trustctime core.warnAmbiguousRefs core.whitespace core.worktree diff.autorefreshindex diff.external diff.ignoreSubmodules diff.mnemonicprefix diff.noprefix diff.renameLimit diff.renames diff.statGraphWidth diff.submodule diff.suppressBlankEmpty diff.tool diff.wordRegex diff.algorithm difftool. difftool.prompt fetch.recurseSubmodules fetch.unpackLimit format.attach format.cc format.coverLetter format.headers format.numbered format.pretty format.signature format.signoff format.subjectprefix format.suffix format.thread format.to gc. gc.aggressiveWindow gc.auto gc.autopacklimit gc.packrefs gc.pruneexpire gc.reflogexpire gc.reflogexpireunreachable gc.rerereresolved gc.rerereunresolved gitcvs.allbinary gitcvs.commitmsgannotation gitcvs.dbTableNamePrefix gitcvs.dbdriver gitcvs.dbname gitcvs.dbpass gitcvs.dbuser gitcvs.enabled gitcvs.logfile gitcvs.usecrlfattr guitool. gui.blamehistoryctx gui.commitmsgwidth gui.copyblamethreshold gui.diffcontext gui.encoding gui.fastcopyblame gui.matchtrackingbranch gui.newbranchtemplate gui.pruneduringfetch gui.spellingdictionary gui.trustmtime help.autocorrect help.browser help.format http.lowSpeedLimit http.lowSpeedTime http.maxRequests http.minSessions http.noEPSV http.postBuffer http.proxy http.sslCAInfo http.sslCAPath http.sslCert http.sslCertPasswordProtected http.sslKey http.sslVerify http.useragent i18n.commitEncoding i18n.logOutputEncoding imap.authMethod imap.folder imap.host imap.pass imap.port imap.preformattedHTML imap.sslverify imap.tunnel imap.user init.templatedir instaweb.browser instaweb.httpd instaweb.local instaweb.modulepath instaweb.port interactive.singlekey log.date log.decorate log.showroot mailmap.file man. man.viewer merge. merge.conflictstyle merge.log merge.renameLimit merge.renormalize merge.stat merge.tool merge.verbosity mergetool. mergetool.keepBackup mergetool.keepTemporaries mergetool.prompt notes.displayRef notes.rewrite. notes.rewrite.amend notes.rewrite.rebase notes.rewriteMode notes.rewriteRef pack.compression pack.deltaCacheLimit pack.deltaCacheSize pack.depth pack.indexVersion pack.packSizeLimit pack.threads pack.window pack.windowMemory pager. pretty. pull.octopus pull.twohead push.default rebase.autosquash rebase.stat receive.autogc receive.denyCurrentBranch receive.denyDeleteCurrent receive.denyDeletes receive.denyNonFastForwards receive.fsckObjects receive.unpackLimit receive.updateserverinfo remote.pushdefault remotes. repack.usedeltabaseoffset rerere.autoupdate rerere.enabled sendemail. sendemail.aliasesfile sendemail.aliasfiletype sendemail.bcc sendemail.cc sendemail.cccmd sendemail.chainreplyto sendemail.confirm sendemail.envelopesender sendemail.from sendemail.identity sendemail.multiedit sendemail.signedoffbycc sendemail.smtpdomain sendemail.smtpencryption sendemail.smtppass sendemail.smtpserver sendemail.smtpserveroption sendemail.smtpserverport sendemail.smtpuser sendemail.suppresscc sendemail.suppressfrom sendemail.thread sendemail.to sendemail.validate showbranch.default status.relativePaths status.showUntrackedFiles status.submodulesummary submodule. tar.umask transfer.unpackLimit url. user.email user.name user.signingkey web.browser branch. remote. " } _git_describe () { case "$cur" in --*) __gitcomp " --all --tags --contains --abbrev= --candidates= --exact-match --debug --long --match --always "; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_diff () { __git_has_doubledash && return; case "$cur" in --diff-algorithm=*) __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"; return ;; --*) __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex --base --ours --theirs --no-index $__git_diff_common_options "; return ;; esac; __git_complete_revlist_file } _git_difftool () { __git_has_doubledash && return; case "$cur" in --tool=*) __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"; return ;; --*) __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex --base --ours --theirs --no-renames --diff-filter= --find-copies-harder --relative --ignore-submodules --tool="; return ;; esac; __git_complete_revlist_file } _git_fetch () { case "$cur" in --recurse-submodules=*) __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"; return ;; --*) __gitcomp "$__git_fetch_options"; return ;; esac; __git_complete_remote_or_refspec } _git_flow () { local subcommands="init feature release hotfix support help version config finish delete publish rebase"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in init) __git_flow_init; return ;; feature) __git_flow_feature; return ;; release) __git_flow_release; return ;; hotfix) __git_flow_hotfix; return ;; support) __git_flow_support; return ;; config) __git_flow_config; return ;; *) COMPREPLY=() ;; esac } _git_format_patch () { case "$cur" in --thread=*) __gitcomp " deep shallow " "" "${cur##--thread=}"; return ;; --*) __gitcomp "$__git_format_patch_options"; return ;; esac; __git_complete_revlist } _git_fsck () { case "$cur" in --*) __gitcomp " --tags --root --unreachable --cache --no-reflogs --full --strict --verbose --lost-found "; return ;; esac } _git_gc () { case "$cur" in --*) __gitcomp "--prune --aggressive"; return ;; esac } _git_gitk () { _gitk } _git_grep () { __git_has_doubledash && return; case "$cur" in --*) __gitcomp " --cached --text --ignore-case --word-regexp --invert-match --full-name --line-number --extended-regexp --basic-regexp --fixed-strings --perl-regexp --files-with-matches --name-only --files-without-match --max-depth --count --and --or --not --all-match "; return ;; esac; case "$cword,$prev" in 2,* | *,-*) if test -r tags; then __gitcomp_nl "$(__git_match_ctag "$cur" tags)"; return; fi ;; esac; __gitcomp_nl "$(__git_refs)" } _git_help () { case "$cur" in --*) __gitcomp "--all --info --man --web"; return ;; esac; __git_compute_all_commands; __gitcomp "$__git_all_commands $(__git_aliases) attributes cli core-tutorial cvs-migration diffcore gitk glossary hooks ignore modules namespaces repository-layout tutorial tutorial-2 workflows " } _git_init () { case "$cur" in --shared=*) __gitcomp " false true umask group all world everybody " "" "${cur##--shared=}"; return ;; --*) __gitcomp "--quiet --bare --template= --shared --shared="; return ;; esac } _git_log () { __git_has_doubledash && return; local g="$(git rev-parse --git-dir 2>/dev/null)"; local merge=""; if [ -f "$g/MERGE_HEAD" ]; then merge="--merge"; fi; case "$cur" in --pretty=* | --format=*) __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) " "" "${cur#*=}"; return ;; --date=*) __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"; return ;; --decorate=*) __gitcomp "long short" "" "${cur##--decorate=}"; return ;; --*) __gitcomp " $__git_log_common_options $__git_log_shortlog_options $__git_log_gitk_options --root --topo-order --date-order --reverse --follow --full-diff --abbrev-commit --abbrev= --relative-date --date= --pretty= --format= --oneline --cherry-pick --graph --decorate --decorate= --walk-reflogs --parents --children $merge $__git_diff_common_options --pickaxe-all --pickaxe-regex "; return ;; esac; __git_complete_revlist } _git_ls_files () { case "$cur" in --*) __gitcomp "--cached --deleted --modified --others --ignored --stage --directory --no-empty-directory --unmerged --killed --exclude= --exclude-from= --exclude-per-directory= --exclude-standard --error-unmatch --with-tree= --full-name --abbrev --ignored --exclude-per-directory "; return ;; esac; __git_complete_index_file "--cached" } _git_ls_remote () { __gitcomp_nl "$(__git_remotes)" } _git_ls_tree () { __git_complete_file } _git_merge () { __git_complete_strategy && return; case "$cur" in --*) __gitcomp "$__git_merge_options --rerere-autoupdate --no-rerere-autoupdate --abort"; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_merge_base () { case "$cur" in --*) __gitcomp "--octopus --independent --is-ancestor --fork-point"; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_mergetool () { case "$cur" in --tool=*) __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"; return ;; --*) __gitcomp "--tool="; return ;; esac } _git_mv () { case "$cur" in --*) __gitcomp "--dry-run"; return ;; esac; if [ $(__git_count_arguments "mv") -gt 0 ]; then __git_complete_index_file "--cached --others --directory"; else __git_complete_index_file "--cached"; fi } _git_name_rev () { __gitcomp "--tags --all --stdin" } _git_notes () { local subcommands='add append copy edit list prune remove show'; local subcommand="$(__git_find_on_cmdline "$subcommands")"; case "$subcommand,$cur" in ,--*) __gitcomp '--ref' ;; ,*) case "$prev" in --ref) __gitcomp_nl "$(__git_refs)" ;; *) __gitcomp "$subcommands --ref" ;; esac ;; add,--reuse-message=* | append,--reuse-message=* | add,--reedit-message=* | append,--reedit-message=*) __gitcomp_nl "$(__git_refs)" "" "${cur#*=}" ;; add,--* | append,--*) __gitcomp '--file= --message= --reedit-message= --reuse-message=' ;; copy,--*) __gitcomp '--stdin' ;; prune,--*) __gitcomp '--dry-run --verbose' ;; prune,*) ;; *) case "$prev" in -m | -F) ;; *) __gitcomp_nl "$(__git_refs)" ;; esac ;; esac } _git_pull () { __git_complete_strategy && return; case "$cur" in --recurse-submodules=*) __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"; return ;; --*) __gitcomp " --rebase --no-rebase $__git_merge_options $__git_fetch_options "; return ;; esac; __git_complete_remote_or_refspec } _git_push () { case "$prev" in --repo) __gitcomp_nl "$(__git_remotes)"; return ;; --recurse-submodules) __gitcomp "$__git_push_recurse_submodules"; return ;; esac; case "$cur" in --repo=*) __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"; return ;; --recurse-submodules=*) __gitcomp "$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}"; return ;; --force-with-lease=*) __git_complete_force_with_lease "${cur##--force-with-lease=}"; return ;; --*) __gitcomp " --all --mirror --tags --dry-run --force --verbose --quiet --prune --delete --follow-tags --receive-pack= --repo= --set-upstream --force-with-lease --force-with-lease= --recurse-submodules= "; return ;; esac; __git_complete_remote_or_refspec } _git_rebase () { local dir="$(__gitdir)"; if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then __gitcomp "--continue --skip --abort"; return; fi; __git_complete_strategy && return; case "$cur" in --whitespace=*) __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"; return ;; --*) __gitcomp " --onto --merge --strategy --interactive --preserve-merges --stat --no-stat --committer-date-is-author-date --ignore-date --ignore-whitespace --whitespace= --autosquash --fork-point --no-fork-point "; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_reflog () { local subcommands="show delete expire"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; else __gitcomp_nl "$(__git_refs)"; fi } _git_remote () { local subcommands="add rename remove set-head set-branches set-url show prune update"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in rename | remove | set-url | show | prune) __gitcomp_nl "$(__git_remotes)" ;; set-head | set-branches) __git_complete_remote_or_refspec ;; update) local i c='' IFS=' '; for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do i="${i#remotes.}"; c="$c ${i/ */}"; done; __gitcomp "$c" ;; *) ;; esac } _git_replace () { __gitcomp_nl "$(__git_refs)" } _git_reset () { __git_has_doubledash && return; case "$cur" in --*) __gitcomp "--merge --mixed --hard --soft --patch"; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_revert () { case "$cur" in --*) __gitcomp "--edit --mainline --no-edit --no-commit --signoff"; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_rm () { case "$cur" in --*) __gitcomp "--cached --dry-run --ignore-unmatch --quiet"; return ;; esac; __git_complete_index_file "--cached" } _git_send_email () { case "$cur" in --confirm=*) __gitcomp " $__git_send_email_confirm_options " "" "${cur##--confirm=}"; return ;; --suppress-cc=*) __gitcomp " $__git_send_email_suppresscc_options " "" "${cur##--suppress-cc=}"; return ;; --smtp-encryption=*) __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"; return ;; --thread=*) __gitcomp " deep shallow " "" "${cur##--thread=}"; return ;; --*) __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to --compose --confirm= --dry-run --envelope-sender --from --identity --in-reply-to --no-chain-reply-to --no-signed-off-by-cc --no-suppress-from --no-thread --quiet --signed-off-by-cc --smtp-pass --smtp-server --smtp-server-port --smtp-encryption= --smtp-user --subject --suppress-cc= --suppress-from --thread --to --validate --no-validate $__git_format_patch_options"; return ;; esac; __git_complete_revlist } _git_shortlog () { __git_has_doubledash && return; case "$cur" in --*) __gitcomp " $__git_log_common_options $__git_log_shortlog_options --numbered --summary "; return ;; esac; __git_complete_revlist } _git_show () { __git_has_doubledash && return; case "$cur" in --pretty=* | --format=*) __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) " "" "${cur#*=}"; return ;; --diff-algorithm=*) __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"; return ;; --*) __gitcomp "--pretty= --format= --abbrev-commit --oneline $__git_diff_common_options "; return ;; esac; __git_complete_revlist_file } _git_show_branch () { case "$cur" in --*) __gitcomp " --all --remotes --topo-order --current --more= --list --independent --merge-base --no-name --color --no-color --sha1-name --sparse --topics --reflog "; return ;; esac; __git_complete_revlist } _git_stage () { _git_add } _git_stash () { local save_opts='--keep-index --no-keep-index --quiet --patch'; local subcommands='save list show apply clear drop pop create branch'; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then case "$cur" in --*) __gitcomp "$save_opts" ;; *) if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then __gitcomp "$subcommands"; fi ;; esac; else case "$subcommand,$cur" in save,--*) __gitcomp "$save_opts" ;; apply,--* | pop,--*) __gitcomp "--index --quiet" ;; show,--* | drop,--* | branch,--*) ;; show,* | apply,* | drop,* | pop,* | branch,*) __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list | sed -n -e 's/:.*//p')" ;; *) ;; esac; fi } _git_submodule () { __git_has_doubledash && return; local subcommands="add status init deinit update summary foreach sync"; if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then case "$cur" in --*) __gitcomp "--quiet --cached" ;; *) __gitcomp "$subcommands" ;; esac; return; fi } _git_svn () { local subcommands=" init fetch clone rebase dcommit log find-rev set-tree commit-diff info create-ignore propget proplist show-ignore show-externals branch tag blame migrate mkdirs reset gc "; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; else local remote_opts="--username= --config-dir= --no-auth-cache"; local fc_opts=" --follow-parent --authors-file= --repack= --no-metadata --use-svm-props --use-svnsync-props --log-window-size= --no-checkout --quiet --repack-flags --use-log-author --localtime --ignore-paths= --include-paths= $remote_opts "; local init_opts=" --template= --shared= --trunk= --tags= --branches= --stdlayout --minimize-url --no-metadata --use-svm-props --use-svnsync-props --rewrite-root= --prefix= --use-log-author --add-author-from $remote_opts "; local cmt_opts=" --edit --rmdir --find-copies-harder --copy-similarity= "; case "$subcommand,$cur" in fetch,--*) __gitcomp "--revision= --fetch-all $fc_opts" ;; clone,--*) __gitcomp "--revision= $fc_opts $init_opts" ;; init,--*) __gitcomp "$init_opts" ;; dcommit,--*) __gitcomp " --merge --strategy= --verbose --dry-run --fetch-all --no-rebase --commit-url --revision --interactive $cmt_opts $fc_opts " ;; set-tree,--*) __gitcomp "--stdin $cmt_opts $fc_opts" ;; create-ignore,--* | propget,--* | proplist,--* | show-ignore,--* | show-externals,--* | mkdirs,--*) __gitcomp "--revision=" ;; log,--*) __gitcomp " --limit= --revision= --verbose --incremental --oneline --show-commit --non-recursive --authors-file= --color " ;; rebase,--*) __gitcomp " --merge --verbose --strategy= --local --fetch-all --dry-run $fc_opts " ;; commit-diff,--*) __gitcomp "--message= --file= --revision= $cmt_opts" ;; info,--*) __gitcomp "--url" ;; branch,--*) __gitcomp "--dry-run --message --tag" ;; tag,--*) __gitcomp "--dry-run --message" ;; blame,--*) __gitcomp "--git-format" ;; migrate,--*) __gitcomp " --config-dir= --ignore-paths= --minimize --no-auth-cache --username= " ;; reset,--*) __gitcomp "--revision= --parent" ;; *) ;; esac; fi } _git_tag () { local i c=1 f=0; while [ $c -lt $cword ]; do i="${words[c]}"; case "$i" in -d | -v) __gitcomp_nl "$(__git_tags)"; return ;; -f) f=1 ;; esac; ((c++)); done; case "$prev" in -m | -F) ;; -* | tag) if [ $f = 1 ]; then __gitcomp_nl "$(__git_tags)"; fi ;; *) __gitcomp_nl "$(__git_refs)" ;; esac } _git_whatchanged () { _git_log } _gitk () { __git_wrap__gitk_main } _npm_completion () { local si="$IFS"; IFS=' ' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" COMP_LINE="$COMP_LINE" COMP_POINT="$COMP_POINT" npm completion -- "${COMP_WORDS[@]}" 2>/dev/null)) || return $?; IFS="$si" } _tobase () { local _outputBaseSpecChar=${outputBaseSpecChar:-d}; local n; for n in "$@"; do printf "%#${_outputBaseSpecChar}\n" $(( n )); done } af () { f "$@" } brm () { [[ $1 == '-h' || $1 == '--help' ]] && { echo 'Prints the contents of ${BASH_REMATCH[@]} in diagnostic form.'; return 0 }; (( $# )) && { echo 'ERROR: Unexpected parameter(s) specified. Use -h for help.' 1>&2; return 2 }; local i m; for m in "${BASH_REMATCH[@]}"; do echo "[$((i++))] = [$m]"; done } calc () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "usage: $FUNCNAME expression\n Evaluates the specified arithmetic expression using (( )) and prints the result.\n Useful for simple calculations and converting hex or oct numbers to decimals." && return 0; echo $(( $@ )) } cdp () { local CDPATH=~:~/Documents/Projects:~/Documents/Projects/OSS:~/Documents/Projects/AlfredWorkflows; builtin cd "$@" } de () { local a i=0; for a in "$@"; do printf '%s\n' "\$$((i+=1))=[$a]"; done } dfs () { df -hl | grep 'disk0s2' | awk '{print $4"/"$2" free ("$5" used)"}' } difs () { echo -n "$IFS" | od -a } doIt () { echo "$$: [$*]" } docker-start () { typeset vm=${1:-default} sts; case $vm in -h | --help) echo 'usage: docker-start [] Ensures that the specified/default Docker VM is started and the environment is initialized.'; return 0 ;; esac; sts=$(docker-machine status "$vm") || return; [[ $sts == 'Running' ]] && echo "(Docker VM '$vm' is already running.)" || { echo "-- Starting Docker VM '$vm' (\`docker-machine start "$vm"\`; this will take a while)..."; docker-machine start "$vm" || return }; echo "-- Setting DOCKER_* environment variables (\`eval \"\$(docker-machine env "$vm")\"\`)..."; eval "$(docker-machine env "$vm")" || return; export | grep -o 'DOCKER_.*'; echo "-- Docker VM '$vm' is running." } docker-stop () { typeset vm=${1:-default} sts envVarNames fndx; case $vm in -h | --help) echo 'usage: docker-stop [] Ensures that the specified/default Docker VM is stopped and the environment is cleaned up.'; return 0 ;; esac; sts=$(docker-machine status "$vm") || return; [[ $sts == 'Running' ]] && { echo "-- Stopping Docker VM '$vm' (\`docker-machine stop "$vm"\`)..."; docker-machine stop "$vm" || return } || echo "(Docker VM '$vm' is not running.)"; [[ -n $BASH_VERSION ]] && fndx=3 || fndx=1; envVarNames=($(export | awk -v fndx="$fndx" '$fndx ~ /^DOCKER_/ { sub(/=.*/,"", $fndx); print $fndx }')); if [[ -n $envVarNames ]]; then echo "-- Unsetting DOCKER_* environment variables ($(echo "${envVarNames[@]}" | sed 's/ /, /g'))..."; unset "${envVarNames[@]}"; else echo "(No DOCKER_* environment variables to unset.)"; fi; echo "-- Docker VM '$vm' is stopped." } dsh () { function die () { echo "${FUNCNAME[1]}(): ERROR: ${1:-"ABORTING due to unexpected error."}" 1>&2; return ${2:-1} }; function dieSyntax () { echo "${FUNCNAME[1]}(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h or --h for help." 1>&2; return 2 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; return $ecode } env_parallel () { local _grep_REGEXP="$( perl -e ' for(@ARGV){ /^_$/ and $next_is_env = 0; $next_is_env and push @envvar, split/,/, $_; $next_is_env = /^--env$/; } $vars = join "|",map { quotemeta $_ } @envvar; print $vars ? "($vars)" : "(.*)"; ' -- "$@" )"; local _ignore_UNDERSCORE="$( perl -e ' for(@ARGV){ $next_is_env and push @envvar, split/,/, $_; $next_is_env=/^--env$/; } if(grep { /^_$/ } @envvar) { if(not open(IN, "<", "$ENV{HOME}/.parallel/ignored_vars")) { print STDERR "parallel: Error: ", "Run \"parallel --record-env\" in a clean environment first.\n"; } else { chomp(@ignored_vars = ); $vars = join "|",map { quotemeta $_ } "env_parallel", @ignored_vars; print $vars ? "($vars)" : "(,,nO,,VaRs,,)"; } } ' -- "$@" )"; if ! perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then ( compgen -a; compgen -A function; compgen -A variable ) | cat > $HOME/.parallel/ignored_vars; return 0; fi; local _alias_NAMES="$(compgen -a | grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ )"; local _list_alias_BODIES="alias $_alias_NAMES"; if [[ "$_alias_NAMES" = "" ]]; then _list_alias_BODIES="true"; fi; unset _alias_NAMES; local _function_NAMES="$(compgen -A function | grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ )"; local _list_function_BODIES="typeset -f $_function_NAMES"; if [[ "$_function_NAMES" = "" ]]; then _list_function_BODIES="true"; fi; unset _function_NAMES; local _variable_NAMES="$(compgen -A variable | grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ | grep -vFf <(readonly) | grep -Ev '^(BASHOPTS|BASHPID|EUID|GROUPS|FUNCNAME|DIRSTACK|_|PIPESTATUS|PPID|SHELLOPTS|UID|USERNAME|BASH_[A-Z_]+)$')"; local _list_variable_VALUES="typeset -p $_variable_NAMES"; if [[ "$_variable_NAMES" = "" ]]; then _list_variable_VALUES="true"; fi; unset _variable_NAMES; export PARALLEL_ENV="$( shopt 2>/dev/null | perl -pe 's:\s+off:;: and s/^/shopt -u /; s:\s+on:;: and s/^/shopt -s /; s:;$:&>/dev/null;:'; echo 'shopt -s expand_aliases &>/dev/null'; $_list_alias_BODIES; $_list_variable_VALUES; $_list_function_BODIES)"; unset _list_alias_BODIES; unset _list_variable_VALUES; unset _list_function_BODIES; `which parallel` "$@"; _parallel_exit_CODE=$?; unset PARALLEL_ENV; return $_parallel_exit_CODE } f () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <] Description: Opens the specified folder in Finder, or, if invoked as "af", in Alfred 2's file browser. By default, the current folder is targeted. You can also specify a file, in which case its containing folder is opened. can also be the name of a quick-cd function defined in the current shell. Quick-cd functions by conventions start with 'f', and, for convenience, you may specify the function name without the initial 'f'. Examples: $FUNCNAME /Library $FUNCNAME fh # 'fh' is quick-cd function for home folder; 'h' would work, too. EOF return 0; fi (( ${#@} >= 2 )) && echo -e "$FUNCNAME: PARAMETER ERROR: Unexpected parameter(s) specified. Use -h or --h to get help." 1>&2 && return 3; local haveFolder=$(( ${#1} ? 1 : 0 )); if (( haveFolder )); then if [[ -f "$1" ]]; then pushd "$(dirname "$1")" > /dev/null || return 2; else if [[ -d "$1" ]]; then pushd "$1" > /dev/null || return 2; else if [[ ${1/\/} != $1 ]]; then echo "ERROR: '$1', assumed to be a folder path, does not exist." 1>&2; return 1; else quickCdFunc="$1"; if [[ ! "$quickCdFunc" =~ ^[fF] ]]; then quickCdFunc="f$quickCdFunc"; fi; declare -f "$quickCdFunc" > /dev/null || { echo "ERROR: '$1' is neither an existing file or folder nor the name of a quick-cd function." 1>&2; return 1 }; $quickCdFunc > /dev/null || return 2; fi; fi; fi; fi; if [[ ${FUNCNAME[1]} == 'af' ]]; then osascript -e 'tell application "Alfred 2" to search "'"$PWD"'"'; else echo Opening Finder to \"$PWD\"...; open .; fi; if (( haveFolder )); then popd > /dev/null; fi } fa () { pushdX /Applications "$@" } fag () { pushdX "$HOME/Projects/CreativeSmarts/AppGyver" "$@" } fas () { pushdX /Library/Application\ Support "$@" } fasu () { pushdX ~/Library/Application\ Support "$@" } fau () { pushdX ~/Applications "$@" } fawf () { pushdX "$HOME/Dropbox/Alfred.alfredpreferences/workflows" "$@" } fawfc () { pushdX "$HOME/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data" "$@" } fawfd () { pushdX "$HOME/Library/Application Support/Alfred 2/Workflow Data" "$@" } fawfp () { pushdX "$HOME/Projects/AlfredWorkflows" "$@" } fcfg () { pushdX ~/Documents/Config "$@" } fcu () { pushdX ~/Library/Caches "$@" } fd () { pushdX ~/Documents "$@" } fdb () { pushdX ~/Dropbox "$@" } fdbp () { pushdX ~/Dropbox/Public "$@" } fdl () { pushdX ~/Downloads "$@" } fdla () { pushdX ~/Documents/DownloadArchive "$@" } fdt () { pushdX ~/Desktop "$@" } feb () { pushdX ~/Documents/eBooks "$@" } febi () { pushdX ~/Documents/eBooks/IT "$@" } febo () { pushdX ~/Calibre\ Library/ "$@" } ff () { local isFunc=1; [[ -z "$FUNCNAME" ]] && isFunc=0; local thisName=$FUNCNAME; (( isFunc )) || thisName=$(basename "$BASH_SOURCE"); if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2 && { (( isFunc )) && return 3 || exit 3 }; find . -iname "*$@*" } fh () { pushdX ~ "$@" } fhomer () { pushdX "/Volumes/jdoe" "$@" } fic () { pushdX "$HOME/Documents/Config/Icons" "$@" } fif () { local isFunc=1; [[ -z "$FUNCNAME" ]] && isFunc=0; local thisName=$FUNCNAME; (( isFunc )) || thisName=$(basename "$BASH_SOURCE"); if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2 && { (( isFunc )) && return 3 || exit 3 }; egrep -lr "$@" . } findexes () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "Synopsis:\n $FUNCNAME [dir]\n\nDescription:\n Finds all executable files in the specified subtree. Uses \`find\` with the \`-type\` and \`-perm\` primaries." && return 0; find "${1:-.}" -type f -perm "-u=x" } findq () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "Synopsis:\n $FUNCNAME {params for \`find\`}\n\nDescription:\n Same as \`find\` with the (implied) \`print\` primary (for listing matching paths),\n except that paths whose names contain reserved chars. are quoted (escaped);\n\n e.g.: 'a name with spaces' -> 'a\ name \ with\ spaces'\n\n Therefore it's safe to pass the output of this function to \`xargs\`.\n e.g.: \`$FUNCNAME . | xargs file\` lists the file type of every file in the current folder's subtree.\n\n CAVEAT: Do not specify a \`find\` primary - \`print\` is implied.\n" && return 0; find "$@" -print0 | while IFS='' read -r -d '' f; do printf '%q\n' "$f"; done } fkkac () { pushdX "$HOME/Projects/CreativeSmarts/AppGyver/Kakooma" "$@" } fkkai () { pushdX "$HOME/Projects/CreativeSmarts/Kakooma iOS Apps/src" "$@" } fl () { pushdX /Library "$@" } fla () { pushdX /Library/LaunchAgents "$@" } flau () { pushdX ~/Library/LaunchAgents "$@" } flsys () { pushdX /System/Library "$@" } flu () { pushdX ~/Library "$@" } fngb () { pushdX "$(npm bin -g)" "$@" } fngm () { pushdX "$(npm prefix -g)"/lib/node_modules "$@" } fobt () { pushdX "/Volumes/C/Users/jdoe/Documents/Projects/ta/onboarding-termination" "$@" } foldIndent () { local width=${1:-80} indent=${2- }; (( width-=${#indent} )); while IFS= read -r line; do fold -s -w $width <<< "$line" | awk 'NR>1 { print "'"$indent"'" $0; next } 1'; done } foss () { pushdX "$HOME/Projects/OSS" "$@" } fpg () { pushdX "$HOME/Desktop/pg" "$@" } fpgw () { pushdX "/Volumes/C/Users/jdoe/Desktop/pg" "$@" } fph () { pushdX ~/Pictures/ "$@" } fppg () { pushdX ~/Projects/pg "$@" } fpr () { pushdX ~/Projects "$@" } fpref () { pushdX /Library/Preferences "$@" } fprefu () { pushdX ~/Library/Preferences "$@" } fql () { pushdX /Library/QuickLook "$@" } fqlu () { pushdX ~/Library/QuickLook "$@" } fs () { pushdX /Library/Services "$@" } fsba () { pushdX ~/Library/Containers "$@" } fsd () { pushdX "/Volumes/data" "$@" } fsl () { pushdX /Library/'Script Libraries' "$@" } fslu () { pushdX ~/Library/'Script Libraries' "$@" } fsn () { pushdX "/Volumes/C/Users/jdoe/Documents/Projects/ta/sponsored-renewal/PsScripts" "$@" } fsph () { pushdX "/Volumes/media/Photos" "$@" } fss () { pushdX ~/Library/'Saved Searches' "$@" } fstp () { d=$([[ $(uname) == 'Darwin' ]] && printf "$HOME/Library/Application Support/Sublime Text 3/Packages" || printf "$HOME/.config/sublime-text-2/Packages"); pushdX "$d" "$@" } fstpu () { d=$([[ $(uname) == 'Darwin' ]] && printf "$HOME/Library/Application Support/Sublime Text 3/Packages/User" || printf "$HOME/.config/sublime-text-2/Packages/User"); pushdX "$d" "$@" } fsu () { pushdX ~/Library/Services "$@" } fsv () { pushdX "/Volumes/media/Videos" "$@" } fsvms () { pushdX '/Volumes/data/VMs/VMware Fusion/Virtual Machines' "$@" } ft () { pushdX '/tmp' "$@" } ftr () { pushdX "/Volumes/data/Transfer" "$@" } ftu () { pushdX "$TMPDIR" "$@" } fu () { pushdX "$MK_UTIL_FOLDER" "$@" } fub () { pushdX ~/bin "$@" } fuc () { pushdX "$MK_UTIL_FOLDER/sourced.d/bash_completion.d" "$@" } fulb () { pushdX '/usr/local/bin' "$@" } fullpath () { [[ "$1" == '--help' || "$1" == '-h' ]] && { echo -e "usage: $FUNCNAME [-ep] [path]\n Prints the absolute version of the specified path; defaults to \$PWD.\n The path is normalized, i.e, '.' and '..' components are resolved, if present.\n If only a filename is given and the file doesn't exist in the current folder, -p will search for it in the \$PATH, too.\n -e reports an error if the resulting path doesn't exist."; return 0 }; local params=() decompressed=0 argsReached=0 p=''; for p in "$@"; do if [[ $argsReached -eq 0 && $p == -[a-z,A-Z,0-9]?* ]]; then decompressed=1; params+=(${p:0:2}); for ((i = 2; i < ${#p}; i++ )) do params+=("-${p:$i:1}"); done; else [[ $p == '--' ]] && argsReached=1; params+=("$p"); fi; done; if (( decompressed )); then set -- "${params[@]}"; fi; unset params decompressed argsReached p; local fp searchInPath mustExist; while (( $# )); do case "$1" in -p) searchInPath=1 ;; -e) mustExist=1 ;; --) shift; break ;; -*) echo "PARAMETER ERROR: Unrecognized option: '$1'. To force interpretation as non-option, precede with '--'." 1>&2; return 2 ;; *) break ;; esac; shift; done; [[ -z $2 ]] || { echo "PARAMETER ERROR: Too many parameters specified. Use -h for help." 1>&2; return 2 }; if [[ -z $1 ]]; then fp=$PWD; else if [[ "${1:0:1}" == '/' ]]; then fp=$1; else fp="$PWD/$1"; if [[ -n $searchInPath && ! -e "$fp" && "${1/\//}" == "$1" ]]; then fp=$(which "$1" 2>/dev/null) || fp="$1"; fi; fi; fi; if [[ $fp =~ (/|^)(\.\.?)(/|$) && ( -e "$fp" || -d "$(dirname "$fp")" ) ]]; then local fld; [[ -d "$fp" ]] && fld=$fp || fld=$(dirname "$fp"); local fldResolved=$(cd "$fld"; pwd); [[ -d "$fp" ]] && fp=$fldResolved || fp=$fldResolved/$(basename "$fp"); fi; [[ -n $mustExist && ! -e "$fp" ]] && { echo "ERROR: Path '$fp' does not exist." 1>&2; return 1 }; echo "$fp" } fus () { pushdX "$MK_UTIL_FOLDER/sourced.d" "$@" } fuw () { pushdX "$MK_UTIL_FOLDER.Win" "$@" } fvms () { dirs=(~/'Documents/Virtual Machines.localized' ~/'Documents/Virtual Machines'); for dir in "${dirs[@]}"; do [[ -d "$dir" ]] && { pushdX "$dir" "$@"; return }; done } fwac () { pushdX "/Volumes/C/Users/jdoe/Documents/Projects/ta/workday-ad-consistency" "$@" } getip () { [[ "$1" == '--help' || "$1" == '-h' ]] && { echo -e "usage: $FUNCNAME\n Prints the IPv4 address of the first *bound* Ethernet interface (e.g., en0); cf. getips()."; return 0 }; if [[ $(uname) == 'Darwin' ]]; then for ifName in $(ifconfig -l | egrep -o "\ben[0-9]+"); do local protName='inet'; local addrFragment=$(ifconfig "$ifName" | egrep -o "\b$protName \S+"); if [[ -n $addrFragment ]]; then echo "$addrFragment" | egrep -o '[0-9].*'; return 0; fi; done; return 1; else local addr; addr=$(ip route get 10.0.0.1 | awk '{print $NF; exit}'); [[ -n $addr ]] || return 1; echo "$addr"; fi } getips () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "usage: $FUNCNAME [-b] [interface-type]\n Prints all this machine's IPv4 addresses of the specified interface *type* (Ethernet by default); cf. getip()\n Use \`ifconfig\` directly to get a specific interface's address.\n -b prints addresses only (suppresses the interface-name prefix) and skips interfaces without address." && return 0; local bare=0; [[ $1 == -b ]] && { bare=1; shift }; local ifType=${1:-en}; for ifName in $(ifconfig -l | egrep -o "\b${ifType}\d+"); do local protName='inet'; local addrFragment=$(ifconfig "$ifName" | egrep -o "\b$protName \S+"); local addr=${addrFragment#$protName }; if (( bare )); then [[ -n $addr ]] && echo "$addr"; else echo "$ifName: $addr"; fi; done; return 0 } installnode () { local THIS_NAME=$FUNCNAME; function _installnode_die () { echo "$THIS_NAME(): ERROR: ${1:-"ABORTING due to unexpected error."}" 1>&2; return ${2:-1} }; function _installnode_dieSyntax () { echo "$THIS_NAME(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h for help." 1>&2; return 2 }; function _installnode_indexOf () { local e ndx=-1; for e in "${@:2}"; do (( ++ndx )); [[ "$e" == "$1" ]] && echo $ndx && return 0; done; echo '-1'; return 1 }; function _installnode_isIn () { _installnode_indexOf "$@" > /dev/null }; function _installnode_pruneToMajorMinor () { printf '%s' | cut -d '.' -f 1-2 <<< "$1" }; function _installnode_resolveInstalledVersion () { local verSpec=$1 verInstalled; [[ ${verSpec:0:1} == 'v' ]] && verSpec=${verSpec:1}; read -r verInstalled <<< "$(nvm ls "$verSpec" | tail -1)"; [[ $verInstalled =~ \ *(v[[:digit:]]+[.[:digit:]]+) ]] && verInstalled=${BASH_REMATCH[1]} || verInstalled=''; printf '%s' "$verInstalled" }; function _installnode_resolveRemoteVersion () { local verSpec=$1; nvm ls-remote "$verSpec" | tail -1 | egrep -o 'v[[:digit:]]+[.[:digit:]]+' }; function _installnode_getLatestUnstableVersion () { _installnode_resolveRemoteVersion }; function _installnode_getLatestProductionVersion () { local latestOverall major minor; latestOverall=$(nvm ls-remote | tail -1 | egrep -o 'v[[:digit:]]+[.[:digit:]]+'); major=$(cut -d '.' -f 1 <<<"$latestOverall"); minor=$(cut -d '.' -f 2 <<<"$latestOverall"); minor=$(( minor - minor % 2 )); _installnode_resolveRemoteVersion "${major}.${minor}" }; function _installnode_isInstalled () { local verSpec=$1; [[ ${verSpec:0:1} == 'v' ]] || verSpec="v${verSpec}"; nvm ls | egrep -v '(:|->)' | egrep "$verSpec" > /dev/null; return $? }; function _installnode_getDefaultVerSpec () { nvm alias default | cut -d ' ' -f 3 }; function _installnode_getDefaultVer () { nvm alias default | awk -F '->' '{print $3}' | tr -d ' )' }; function _installnode_vercomp () { [[ $1 == $2 ]] && return 0; local i v1=$1 v2=$2; [[ ${v1:0:1} == 'v' ]] && v1=${v1:1}; [[ ${v2:0:1} == 'v' ]] && v2=${v2:1}; local IFS='.'; local i vna1=($v1) vna2=($v2); for ((i=${#vna1[@]}; i<${#vna2[@]}; i++)) do vna1[i]=0; done; for ((i=0; i<${#vna1[@]}; i++)) do [[ -z ${vna2[i]} ]] && vna2[i]=0; (( 10#${vna1[i]} > 10#${vna2[i]} )) && return 1; (( 10#${vna1[i]} < 10#${vna2[i]} )) && return 2; done; return 0 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat < /dev/null; then argsReached=1; fi; fi; params+=("$p"); fi; done; (( decompressed )) && set -- "${params[@]}"; unset params decompressed argsReached p; local showStatus=0 installFresh=0 upgrade=0 installAndCopy=0; local useUnstableVersion=0 skipPrompt=0 force=0; while (( $# )); do case "$1" in status) showStatus=1 ;; fresh) installFresh=1 ;; copy) installAndCopy=1 ;; upgrade) upgrade=1 ;; --) shift; break ;; -d | --unstable) useUnstableVersion=1 ;; -y | --yes) skipPrompt=1 ;; -f | --force) force=1 ;; -?) return $(_installnode_dieSyntax "Unrecognized option: '$1'. To force interpretation as non-option, precede with '--'.") ;; *) break ;; esac; shift; done; local newVerSpec oldVerSpec majorMinorSpec haveNewVerSpec haveOldVerSpec downgrading defaultVerHint defaultVerSpec suggestedNewDefaultVerSpec qualifier otherOptCount descr; newVerSpec=$1; shift; oldVerSpec=$1; shift; [[ -z $1 ]] || return $(_installnode_dieSyntax "Too many parameters specified."); local cmdCount=$(( showStatus + installFresh + installAndCopy + upgrade )); (( cmdCount <= 1 )) || return $(_installnode_dieSyntax "Only 1 command may be specified."); (( cmdCount == 1 )) || showStatus=1; if [[ -n $oldVerSpec ]]; then (( upgrade || installAndCopy )) || return $(_installnode_dieSyntax "An old version number can only be specified with the 'upgrade' and 'copy' commands."); fi; if [[ -n $newVerSpec ]]; then (( ! useUnstableVersion )) || return $(_installnode_dieSyntax "-d implies the latest unstable version, do not also supply an explicit version spec."); fi; haveNewVerSpec=0; if [[ -n $newVerSpec ]]; then haveNewVerSpec=1; [[ ${newVerSpec:0:1} == 'v' ]] || newVerSpec=v${newVerSpec}; fi; haveOldVerSpec=0; if [[ -n $oldVerSpec ]]; then haveOldVerSpec=1; [[ ${oldVerSpec:0:1} == 'v' ]] || oldVerSpec=v${oldVerSpec}; fi; [[ "$(type -t nvm)" != 'function' && -s ~/.nvm/nvm.sh ]] && . ~/.nvm/nvm.sh; [[ "$(type -t nvm)" == 'function' ]] || return $(_installnode_die "nvm (node.js version manager) not found."); if (( haveNewVerSpec )); then resolvedNewVersion=$(_installnode_resolveRemoteVersion "$newVerSpec") || return $(_installnode_die "No available version matching '$newVerSpec' found."); else if (( useUnstableVersion )); then resolvedNewVersion=$(_installnode_getLatestUnstableVersion); else resolvedNewVersion=$(_installnode_getLatestProductionVersion); fi; [[ -n $resolvedNewVersion ]] || return $(_installnode_die "Failed to determine latest available version."); fi; resolvedOldVersion=''; if (( haveOldVerSpec )); then resolvedOldVersion=$(_installnode_resolveInstalledVersion "$oldVerSpec"); [[ -n $resolvedOldVersion ]] || return $(_installnode_die "Old version spec. does not match any installed versions: '$oldVerSpec'"); else if (( haveNewVerSpec )); then majorMinorSpec=$(_installnode_pruneToMajorMinor "$newVerSpec"); else majorMinorSpec=$(_installnode_pruneToMajorMinor "$resolvedNewVersion"); fi; resolvedOldVersion=$(_installnode_resolveInstalledVersion "$majorMinorSpec"); fi; if (( showStatus )); then otherOptCount=$(( skipPrompt + force )); (( otherOptCount == 0 )) || return $(_installnode_dieSyntax "The 'status' command cannot be combined with these options."); descr=''; if (( haveNewVerSpec )); then descr="'$newVerSpec' version"; else if (( useUnstableVersion )); then descr="UNSTABLE version"; else descr="PRODUCTION version"; fi; fi; cat <&2 ;; esac; else if _installnode_isInstalled $resolvedNewVersion; then (( force )) || return $(_installnode_die "Version $resolvedNewVersion is already installed. To force reinstallation, use --force."); echo "WARNING: As requested, REINSTALLING $resolvedNewVersion." 1>&2; fi; fi; if (( installFresh )); then echo "Will INSTALL FRESH: $resolvedNewVersion"; else if (( installAndCopy )); then echo "Will INSTALL: $resolvedNewVersion"; echo "And COPY GLOBAL PACKAGES FROM: $resolvedOldVersion"; else if (( upgrade )); then echo "Will INSTALL: $resolvedNewVersion"; echo "And UPGRADE FROM (copy global packages, then DELETE): $resolvedOldVersion"; fi; fi; fi; while (( ! skipPrompt )); do read -p "CONTINUE? (y/N) " promptInput; [[ $promptInput =~ ^[yY]$ ]] && break; ( [[ $promptInput =~ ^[nN]$ || -z $promptInput ]] ) && { echo "Aborted." 1>&2; return 1 }; echo "Invalid input; please try again (^C to abort)." 1>&2; done; if (( force )) && _installnode_isInstalled "$resolvedNewVersion"; then echo "-- UNinstalling $resolvedOldVersion..."; nvm deactivate > /dev/null; nvm uninstall "$resolvedNewVersion" || return $(_installnode_die); fi; echo "-- INSTALLING $resolvedNewVersion..."; nvm install "$resolvedNewVersion" || return $(_installnode_die); if (( installAndCopy || upgrade )); then echo "-- COPYING global packages from $resolvedOldVersion..."; echo " Note: This CAN TAKE A WHILE, as packages are being rebuilt."; npm_config_loglevel='error' nvm copy-packages "$resolvedOldVersion" > /dev/null || return $(_installnode_die); fi; if (( upgrade )); then echo "-- DELETING old version $resolvedOldVersion..."; nvm uninstall "$resolvedOldVersion" || return $(_installnode_die); fi; if [[ "$resolvedNewVersion" != "$(_installnode_getDefaultVer)" ]]; then suggestedNewDefaultVerSpec=$(_installnode_pruneToMajorMinor "$resolvedNewVersion"); defaultVerSpec=$(_installnode_getDefaultVerSpec); qualifier="the latest $suggestedNewDefaultVerSpec.x version - and therefore now $resolvedNewVersion - "; if [[ "$suggestedNewDefaultVerSpec" == "$(_installnode_getDefaultVerSpec)" ]]; then qualifier="$resolvedNewVersion SPECIFICALLY"; suggestedNewDefaultVerSpec=$resolvedNewVersion; fi; defaultVerHint=" NOTE: The DEFAULT VERSION (spec.) is currently: $(_installnode_getDefaultVerSpec) To make $qualifier the NEW default version, run: nvm alias default $suggestedNewDefaultVerSpec "; fi; if (( SHLVL > 1 )); then echo " -- WARNING: $resolvedNewVersion was SUCCESSFULLY INSTALLED, *but* to MAKE IT TAKE EFFECT, do the following: - open a NEW Terminal tab or window. - and execute the following: nvm use $resolvedNewVersion In the future, consider loading this script - '$BASH_SOURCE' - from your shell profile to avoid having to do this. " 1>&2; else echo "-- Done. ACTIVE VERSION is now $resolvedNewVersion."; fi; if [[ -n $defaultVerHint ]]; then echo "$defaultVerHint"; else echo " $resolvedNewVersion is also the NEW DEFAULT."; fi } iterm2_begin_osc () { printf "\033]" } iterm2_end_osc () { printf "\007" } iterm2_preexec_install () { if ( [ x"${PROMPT_COMMAND:-}" = x ] ); then PROMPT_COMMAND="iterm2_preexec_invoke_cmd"; else PROMPT_COMMAND="$(echo -n $PROMPT_COMMAND | sed -e 's/; *$//'); iterm2_preexec_invoke_cmd"; fi; trap 'iterm2_preexec_invoke_exec "$_"' DEBUG } iterm2_preexec_invoke_cmd () { set -o functrace > /dev/null 2>&1; shopt -s extdebug > /dev/null 2>&1; \local s=$?; last_hist_ent="$(HISTTIMEFORMAT= builtin history 1)"; precmd; if [ -z "${ITERM_ORIG_PS1+xxx}" ]; then export ITERM_ORIG_PS1="$PS1"; fi; if [[ "$PS1" != "$ITERM_PREV_PS1" ]]; then export ITERM_ORIG_PS1="$PS1"; fi; \local iterm2_prompt_prefix_value="$(iterm2_prompt_prefix)"; if [[ $ITERM_ORIG_PS1 != *'$(iterm2_prompt_mark)'* ]]; then iterm2_prompt_prefix_value="$iterm2_prompt_prefix_value$(iterm2_prompt_mark)"; fi; sh -c "exit $s"; export PS1="\[$iterm2_prompt_prefix_value\]$ITERM_ORIG_PS1\[$(iterm2_prompt_suffix)\]"; export ITERM_PREV_PS1="$PS1"; sh -c "exit $s"; ITERM_PREEXEC_INTERACTIVE_MODE="yes" } iterm2_preexec_invoke_exec () { if [ ! -t 1 ]; then return; fi; if [[ -n "${COMP_LINE:-}" ]]; then return; fi; if [[ -z "$ITERM_PREEXEC_INTERACTIVE_MODE" ]]; then return; else if [[ 0 -eq "$BASH_SUBSHELL" ]]; then ITERM_PREEXEC_INTERACTIVE_MODE=""; fi; fi; if [[ "iterm2_preexec_invoke_cmd" == "$BASH_COMMAND" ]]; then ITERM_PREEXEC_INTERACTIVE_MODE=""; return; fi; hist_ent="$(HISTTIMEFORMAT= builtin history 1)"; \local prev_hist_ent="${last_hist_ent}"; last_hist_ent="${hist_ent}"; if [[ "${prev_hist_ent}" != "${hist_ent}" ]]; then \local this_command="$(echo "${hist_ent}" | sed -e "s/^[ ]*[0-9]*[ ]*//g")"; else \local this_command=""; fi; preexec "$this_command" } iterm2_print_state_data () { iterm2_begin_osc; printf "1337;RemoteHost=%s@%s" "$USER" "$iterm2_hostname"; iterm2_end_osc; iterm2_begin_osc; printf "1337;CurrentDir=%s" "$PWD"; iterm2_end_osc; iterm2_print_user_vars } iterm2_print_user_vars () { true } iterm2_print_version_number () { iterm2_begin_osc; printf "1337;ShellIntegrationVersion=4;shell=bash"; iterm2_end_osc } iterm2_prompt_mark () { iterm2_begin_osc; printf "133;A"; iterm2_end_osc } iterm2_prompt_prefix () { iterm2_begin_osc; printf "133;D;\$?"; iterm2_end_osc; iterm2_print_state_data } iterm2_prompt_suffix () { iterm2_begin_osc; printf "133;B"; iterm2_end_osc } iterm2_set_user_var () { iterm2_begin_osc; printf "1337;SetUserVar=%s=%s" "$1" $(printf "%s" "$2" | base64 | tr -d '\n'); iterm2_end_osc } kill-script () { [[ -z $1 || $1 == '-h' || $1 == '--help' ]] && { echo "Usage: $FUNCNAME scriptFileName ..."' '"Kills the specified bash/sh script(s)."; return $(( ${#1} == 0 )) }; local ec=0; for p in "$@"; do pkill -nf '/?(bash|sh)[ ]+(.*/)?'"$p"'( |$)' && echo "'$1' killed." || { ec=$?; echo "ERROR: bash/sh script process not found: '$p'" 1>&2 }; done; return $ec } list-available-locales () { case $(uname) in 'Darwin') locale -a ;; 'Linux') [[ -f /usr/share/i18n/SUPPORTED ]] && { cat /usr/share/i18n/SUPPORTED; return }; which localectl &> /dev/null && { localectl list-locales; return }; { echo "Don't know how to determine available locales for $(uname -a)." 1>&2; return 1 } ;; *) { echo "Don't know how to determine available locales for $(uname)." 1>&2; return 1 } ;; esac } lock () { '/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession' -suspend } lsp () { local isFunc=1; [[ -z "$FUNCNAME" ]] && isFunc=0; local thisName=$FUNCNAME; (( isFunc )) || thisName=$(basename "$BASH_SOURCE"); if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat < Save Project As... CAVEAT: As of ST2 v2.0.1, if a project file is opene and the project happens to be open in ST2 already, a new, *blank* window will open. EOF (( isFunc )) && return 0 || exit 0; fi local projSwitch='--project'; local projFile="$@"; if [[ -z $projFile ]]; then local EXT=.sublime-project; local projFiles=($(shopt -s nullglob; echo *$EXT)); projFile=${projFiles[0]}; if [[ -z $projFile ]]; then projSwitch=''; projFile='.'; echo "Opening folder '$PWD' as implicit, transient ST2 project..."; else echo "Opening project '$projFile'..."; fi; else ls "$projFile" > /dev/null 2>&1 || { echo "ERROR: ST2 project file(s) '$projFile' not found." 1>&2; return 1 }; echo "Opening project(s) '$projFile'..."; fi; subl $projSwitch "$projFile" } mang () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat </dev/null | cut -d= -f2 | xargs); [[ -n $expandedAlias ]] && name=$expandedAlias; if (( $# > 1 )); then man "$@"; else { help -s "$name" | grep -E "^$name:" } &> /dev/null && isBuiltIn=1; if [[ $isBuiltIn -ne 0 && $name != 'printf' ]]; then echo "(\"$name\" is a BUILTIN; using 'help'...)"; help "$name"; return $?; else man "$name" 2> /dev/null && return; fi; echo "(No 'man' page found, trying --help, then -h...)" 1>&2; [[ $(echo $name | tr [:upper:] [:lower:]) == 'setfile' ]] && { $name -h; return 0 }; [[ $(echo $name | tr [:upper:] [:lower:]) == 'plistbuddy' || $name == 'plb' ]] && { local exePath="/usr/libexec/PlistBuddy"; echo "IMPORTANT: 'PlistBuddy' is NOT in the PATH - lives at '$exePath'."' '; $exePath; $exePath -h; return 0 }; local ht=$($name --help 2> /dev/null || $name -h) || return; if [[ -z $ht ]]; then ht=$($name --help 2>&1) || ht=$($name -h 2>&1); fi; echo -E "$ht"; fi } manxg () { local targetCmd=${FUNCNAME%g}; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; return ${2:-1} }; function dieSyntax () { echo "${FUNCNAME[1]}(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h or --h for help." 1>&2; return 2 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; else [[ -n $firstDirCreated ]] || firstDirCreated="$dir"; argsForMkDir+=("$dir"); (( ++createCount )); fi; done; (( createCount )) && { mkdir "${argsForMkDir[@]}" || return $(die) }; cd "$firstDir" || return $(die); msgCreation=''; case $createCount in 0) msgCreation='C' ;; 1) if [[ $firstDirCreated == $firstDir ]]; then msgCreation='Created and c'; else msgCreation='1 dir. created; c'; fi ;; *) msgCreation="$createCount dirs. created; c" ;; esac; echo "${msgCreation}hanged to '$firstDir' [$PWD]." } mktempfile () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "usage: $FUNCNAME [ext]\n Creates a unique temporary file or folder and returns its full path.\n Acts as a simple wrapper around \`mktemp -t tmp\`; i.e., file is created in \$TMPDIR (or /tmp, in its absence);\n optionally specify additional \`mktemp\` options, such as -u to delete the file right away,\n or -d to create a directory instead.\n If you specify EXT, the temporary file is given the specified filename extension." && return 0; local ext; local isDir=0; local dontCreate=0; for p in "$@"; do if [[ "${p:0:1}" != "-" ]]; then [[ -n "$ext" ]] && { echo "$FUNCNAME: PARAMETER ERROR: You can only specify ONE filename extension." 1>&2; return 1 }; ext=$p; else if [[ "$p" == "-d" ]]; then isDir=1; else if [[ "$p" == "-u" ]]; then dontCreate=1; fi; fi; fi; done; [[ isDir -eq 1 && -n $ext ]] && { echo "$FUNCNAME: PARAMETER ERROR: You can only specify a filename extension when you create a file (not a directory)." 1>&2; return 1 }; local passThru=${@/$ext}; local outPath=$(mktemp $passThru -t 'tmp'); [[ -z "$outPath" ]] && return 1; if [[ -n "$ext" ]]; then local oldOutPath=$outPath; [[ "${ext:0:1}" != '.' ]] && ext=".$ext"; outPath+=$ext; if (( ! dontCreate )); then mv "$oldOutPath" "$outPath" || return 1; fi; fi; echo "$outPath" } npmf () { function die () { echo "${FUNCNAME[1]}(): ERROR: ${1:-"ABORTING due to unexpected error."}" 1>&2; return ${2:-1} }; function dieSyntax () { echo "${FUNCNAME[1]}(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h or --h for help." 1>&2; return 2 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat < /dev/null || return $(die) } npml () { function die () { echo "${FUNCNAME[1]}(): ERROR: ${1:-"ABORTING due to unexpected error."}" 1>&2; return ${2:-1} }; function dieSyntax () { echo "${FUNCNAME[1]}(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h for help." 1>&2; return 2 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat </dev/null | perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))'`; if [[ -z $data ]]; then echo ERROR: No HTML data found on clipboard. 1>&2; return 1; fi; echo "$data" } pbpaste_rtf () { local data; data=`osascript -e 'class RTF of (the clipboard as record)' 2>/dev/null | perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))'`; if [[ -z $data ]]; then echo ERROR: No RTF data found on clipboard. 1>&2; return 1; fi; echo "$data" } pifs () { set | egrep '^IFS=' } precmd () { if [[ -z "${iterm2_ran_preexec:-}" ]]; then preexec ""; fi; iterm2_ran_preexec="" } preexec () { iterm2_begin_osc; printf "133;C;"; iterm2_end_osc; if [ -n "${ITERM_ORIG_PS1+xxx}" -a "$PS1" = "$ITERM_PREV_PS1" ]; then export PS1="$ITERM_ORIG_PS1"; fi; iterm2_ran_preexec="yes" } pushdX () { pushd "$1" > /dev/null || return $?; [[ -t 1 ]] && echo "${PWD/#$HOME/~}" || echo "${PWD}"; shift; if (( $# )); then "$@"; fi } pv () { local pipeStatus=(${PIPESTATUS[@]}); local bashReMatch=("${BASH_REMATCH[@]}"); [[ "$1" == '-h' || "$1" == '--help' ]] && { cat < e.g., 'HOME="/Users/jdoe" # -x' $FUNCNAME 'histf*' # -> e.g., $'HISTFILE="/Users/jdoe/.bash_history"\nHISTFILESIZE="500"' EOF return 0 } function __pv_encodeCtrlChars () { local v=$1; v=${v//' '/\\t}; v=${v//' '/\\n}; '/\\r}; v=${v//''/\\v}; local/l=$(( ${#v} - 2 )); printf '%s' "\$'${v:1:$l}'" }; local vname vnamePattern vnames=("$@") allVnames=() matchPatterns=0 countOk=0 patternMatched=0 warnBashVars=0; for vname in "${vnames[@]}"; do if [[ $vname == *[][*?]* ]]; then matchPatterns=1; break; fi; done; if (( $# == 0 || matchPatterns )); then if [[ $BASH_VERSINFO -lt 4 ]]; then local allVnames=($(declare -p | LC_ALL=C sed -n -E -e '1,/^[^=]+\(\)/p' | LC_ALL=C sed -E -n -e '/^[[:alnum:]_]+=/p' | LC_ALL=C awk -F '=' '{ print $1 }')); else local allVnames=($(declare -p | LC_ALL=C egrep '^declare -' | cut -d ' ' -f 3- | cut -d '=' -f 1)); fi; allVnames+=('-'); if (( $# == 0 )); then vnames=("${allVnames[@]}"); else vnamesWithPatterns=("${vnames[@]}"); vnames=(); local mustReset=$(shopt -q nocasematch; echo $?); shopt -s nocasematch; for vnamePattern in "${vnamesWithPatterns[@]}"; do if [[ $vnamePattern == *[][*?]* ]]; then patternMatched=0; for vname in "${allVnames[@]}"; do [[ "$vname" == $vnamePattern ]] && { vnames+=("$vname"); patternMatched=1 }; done; (( patternMatched )) || { echo "WARNING: No variables match pattern: $vnamePattern" 1>&2 }; else vnames+=("$vnamePattern"); fi; done; (( mustReset )) && shopt -u nocasematch; fi; fi; for vname in "${vnames[@]}"; do if [[ $vname == '-' ]]; then echo "-=$- # -r"; else [[ $vname == 'BASH_'* && ! ( $vname == 'BASH_REMATCH' || $vname == 'BASH_VERSION' || $vname == 'BASH_VERSINFO' ) || $vname == '_' ]] && { warnBashVars=1; continue }; local vdef=$(declare -p "$vname" 2> /dev/null); if [[ -z $vdef ]]; then if (( $# )); then echo "WARNING: Variable '$vname' is not defined." 1>&2; fi; else local vdef=${vdef#declare }; local attrs vval; IFS=' =' read -d '' -r attrs vname vval <<< "$vdef"; if [[ $vname == 'PIPESTATUS' ]]; then vval=$(declare -p pipeStatus | cut -d= -f2-); else if [[ $vname == 'BASH_REMATCH' ]]; then vval=$(declare -p bashReMatch | cut -d= -f2-); else vval=$(printf '%s' "$vval"); fi; fi; [[ $vname == 'IFS' ]] && vval=$(__pv_encodeCtrlChars "$vval"); printf '%s' "$vname=$vval"; attrs=${attrs/a/}; [[ -n $attrs && $attrs != '--' && $attrs != '-' ]] && printf " # $attrs"; printf '\n'; (( ++countOk )); fi; fi; done; (( warnBashVars )) && echo "WARNING: Cannot report true value of \$_ and some \$BASH_* variables due to technical limitations."' '"Use \`echo \"\$BASH_...\"\` instead; e.g., \`echo \"\${BASH_SOURCE[@]}\"\`." 1>&2; return $(( countOk == 0 )) } ql () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat < /dev/null } resetcolors () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; return 2 }; printf '\e[0m' } resume-script () { [[ -z $1 || $1 == '-h' || $1 == '--help' ]] && { echo "Usage: $FUNCNAME scriptFileName ..."' '"Resumes the specified bash/sh script(s)."; return $(( ${#1} == 0 )) }; local ec=0; for p in "$@"; do pkill -CONT -nf '/?(bash|sh)[ ]+(.*/)?'"$p"'( |$)' && echo "'$1' resumed." || { ec=$?; echo "ERROR: bash/sh script process not found: '$p'" 1>&2 }; done; return $ec } sl () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2 && return 1 ;; *) break ;; esac; shift; done; [[ -z "$1" ]] && echo -e "$FUNCNAME: PARAMETER ERROR: Too few parameters specified. Use -h or --h to get help." 1>&2 && return 1; local allTokens; if (( !optNoTotal && ${#@} >=2 )); then local allTokens=$*; fi; local totalLen=0; local result=''; while (( ${#@} )); do local len=${#1}; (( totalLen+=len )); result="${result}'$1': $len"' '; shift; done; if [[ -n "$allTokens" ]]; then echo "Total: ${#allTokens}/$totalLen (with/without interior spaces)"; fi; echo -n "$result" } stripColors () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; return 2 }; LC_ALL=C sed -E 's/'''\[([0-9]{1,2})?(;[0-9]{1,2})*m//g' } stripFormatting () { if [[ $(uname) == 'Linux' ]]; then stripColors | col -b; else stripColors | LC_ALL=C col -b; fi } suspend-script () { [[ -z $1 || $1 == '-h' || $1 == '--help' ]] && { echo "Usage: $FUNCNAME scriptFileName ..."' '"Suspends the specified bash/sh script(s)."; return $(( ${#1} == 0 )) }; local ec=0; for p in "$@"; do pkill -STOP -nf '/?(bash|sh)[ ]+(.*/)?'"$p"'( |$)' && echo "'$1' suspended." || { ec=$?; echo "ERROR: bash/sh script process not found: '$p'" 1>&2 }; done; return $ec } tc () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&1 | $FUNCNAME' instead of just '| $FUNCNAME'. - With COMMAND specified, executes it, and copies its stdout output to the clipboard using 'pbcopy'. To capture commands involving pipes and stdout/err redirection, use the postpositional form instead. If COMMAND returns an error, it is reported, and nothing is copied to the clipboard. No stdout output is displayed by default. Pass -p (--passthru) as the 1st argument to also echo what was captured. A nonzero exitcode, possibly accompanied by an error message, indicates failure. Examples: ls | $FUNCNAME $FUNCNAME ls EOF return 0; fi [[ $1 == '-p' || $1 =~ ^--?[Pp][Aa][Ss][Ss][Tt][Hh][Rr][Uu]$ ]] && { local passThru=1; shift }; if (( $# )); then local ftemp=$(mktemp -t "$FUNCNAME"); ( eval "$@" > "$ftemp" ); local ec=$?; (( ec != 0 )) && rm "$ftemp" && echo '(Nothing was copied to clipboard.)' 1>&2 && return $ec; echo -En "$( < "$ftemp" )" | pbcopy; rm "$ftemp"; else pbcopy || return; fi; (( passThru )) && pbpaste } tobin () { local n; for n in "$@"; do bc <<< "obase=2;$(( n ))"; done } todec () { local outputBaseSpecChar='d'; _tobase "$@" } tohex () { local outputBaseSpecChar='x'; _tobase "$@" } tooct () { local outputBaseSpecChar='o'; _tobase "$@" } trim () { var=$1; var="${var#"${var%%[![:space:]]*}"}"; var="${var%"${var##*[![:space:]]}"}"; echo -n "$var" } typex () { case $1 in -h | --help | --version | --man | --man-source | --home) "$__typex_scriptpath" "$@"; return ;; esac; function __typex_rreadlinkchain () { ( command typeset target="$1" targetDir= targetName= CDPATH=; unalias cd pwd readlink dirname basename printf 2> /dev/null; unset -f cd pwd readlink dirname basename printf 2> /dev/null; while :; do [[ -L $target || -e $target ]] || { printf '%s\n' "typex: WARNING: '$target' does not exist." 1>&2; return 1 }; cd "$(dirname -- "$target")"; targetDir=$PWD; targetName=$(basename -- "$target"); [[ $targetName == '/' ]] && targetName=''; done=0; if [[ ! -L $targetName ]]; then targetDir=$(pwd -P); done=1; fi; printf '%s\n' "${targetDir%/}/$targetName"; (( done )) && break; target=$(readlink -- "$targetName"); done ) }; function __typex_getFileTimestamp () { command typeset file="$1" kind="${2:-m}" outFmt="$3" fmtOptChar= fmtChar= osNdx=; osNdx=0; [[ $(command uname) == 'Linux' ]] && osNdx=1; fmtOptChar='fc'; case "$kind" in m) fmtChar='mY' ;; a) fmtChar='aX' ;; b) fmtChar='BW' ;; c) fmtChar='cZ' ;; *) return 1 ;; esac; ts=$(command stat -${fmtOptChar:$osNdx:1} "%${fmtChar:$osNdx:1}" "$file") || return; if [[ -n $outFmt ]]; then case $osNdx in 0) command date -j -f '%s' "$ts" +"$outFmt" || return ;; 1) command date -d @"$ts" +"$outFmt" || return ;; esac; else command printf '%s\n' "$ts"; fi }; function __typex_reMatch () { command typeset ec= outVar="${3:-__typex_reMatch}"; unset -v "$outVar"; [[ $1 =~ $2 ]]; ec=$?; if [[ $ec -eq 0 ]]; then [[ -n $BASH_VERSION ]] && eval "$outVar"'=( "${BASH_REMATCH[@]}" )'; [[ -n $KSH_VERSION ]] && eval "$outVar"'=( "${.sh.match[@]}" )'; [[ -n $ZSH_VERSION ]] && eval "$outVar"'=( "$MATCH" "${match[@]}" )'; fi; return $ec }; function __typex_reQuote () { command sed 's/[^^]/[&]/g; s/\^/\\^/g' <<< "$*" }; function __typex_install () { command typeset targetShellFilename=$1 install=$2 runningStandalone=$3 scriptFileAbsPath=$4; command typeset verbose=1 scriptFileAbsPathQ= initFile= instLineRegEx= found=0 cmd= cmt= ec= newContents=; command typeset dir=${TYPEX_TEST_INITFILE_DIR:-~}; case "$targetShellFilename" in 'bash') [[ $(uname) == 'Darwin' ]] && initFile="$dir/.bash_profile" || initFile="$dir/.bashrc" ;; 'ksh') initFile="$dir/.kshrc" ;; 'zsh') initFile="$dir/.zshrc" ;; *) printf '%s\n' "ERROR: ${scriptFileAbsPath##*/} can only be sourced in bash, ksh, or zsh -- $targetShell is not supported." 1>&2; return 2 ;; esac; scriptFileAbsPathQ=$(command printf '%q' "$scriptFileAbsPath"); cmd="[[ -f $scriptFileAbsPathQ ]] && . $scriptFileAbsPathQ"; cmt="# Added by ${scriptFileAbsPath##*/} -i; ${scriptFileAbsPath##*/} -u to remove."; instLineRegEx='^[[:space:]]*'"$(__typex_reQuote "$cmd")"'([[:space:]]|$)'; [[ -f $initFile ]] && command grep -Eq "$instLineRegEx" "$initFile" && found=1; ec=0; if (( install )); then if (( found )); then (( verbose )) && command printf '%s\n' "(Sourcing command for '$scriptFileAbsPath' already present in '$initFile'; nothing to do.)"; else printf '\n%s %s\n' "$cmd" "$cmt" >> "$initFile"; ec=$?; fi; else if (( ! found )); then (( verbose )) && command printf '%s\n' "(Sourcing command for '$scriptFileAbsPath' not present in '$initFile'; nothing to do.)"; else newContents=$(command grep -Ev "$instLineRegEx" "$initFile") && command printf '%s\n' "$newContents" > "$initFile"; ec=$?; unset -f ${scriptFileAbsPath##*/} 2> /dev/null; fi; fi; if (( install )); then if (( ec == 0 )); then command printf '%s\n' "Sourcing of '$scriptFileAbsPath' installed in '$initFile'."; else command printf '%s\n' "ERROR: Failed to install sourcing of '$scriptFileAbsPath' in '$initFile'; please manually add line '. $scriptFileAbsPath'." 1>&2; fi; else if (( ec == 0 )); then command printf '%s\n' "Sourcing of '$scriptFileAbsPath' uninstalled from '$initFile'."; else command printf '%s\n' "ERROR: Failed to uninstall sourcing of '$scriptFileAbsPath' from '$initFile'; please manually remove the line containing '. $scriptFileAbsPath'." 1>&2; fi; fi; return $ec }; function __typex_init () { [[ -n $ZSH_VERSION ]] && { __typex_prevPosixBuiltinsOptState=${options[posixbuiltins]}; options[POSIX_BUILTINS]=on; __typex_prevKshArrayEmulationOptState=${options[ksharrays]}; options[ksharrays]=on } || unset __typex_prevPosixBuiltinsOptState __typex_prevKshArrayEmulationSOpttate }; function __typex_restore () { [[ -n $__typex_prevPosixBuiltinsOptState ]] && options[posixbuiltins]=$__typex_prevPosixBuiltinsOptState; [[ -n $__typex_prevKshArrayEmulationOptState ]] && options[ksharrays]=$__typex_prevKshArrayEmulationOptState }; __typex_init; command typeset thisFuncName=$([[ -n $BASH_VERSION ]] && command printf %s "$FUNCNAME" || command printf %s "$0"); command typeset notSourced=0; [[ $1 == '--not-sourced' ]] && { shift; notSourced=1 }; command typeset all=1; command typeset CDPATH= numNotFound=0 name= names= isExplicitPath=0 isKeyword=0 keywordOutput= def= found=0 isBuiltIn=0 specialFileType= brokenSymlink=0 extraOpt= files= file= thisfile= fileCategory= fileType= scriptType= ver= fileLinkChain= trueFile= errMsgSuffix= shell=; command typeset fileSystemOnly=0 noVersion=0 verbose=0 install=0 uninstall=0; command typeset allowOptsAfterOperands=1 i=0 optName= isLong=0 prefix= optArg= haveOptArgAttached=0 haveOptArgAsNextArg=0 acceptOptArg=0 needOptArg=0; command typeset -a operands; __typex_reMatch=; while (( $# )); do if __typex_reMatch "$1" '^(-)[a-zA-Z0-9]+.*$' || __typex_reMatch "$1" '^(--)[a-zA-Z0-9]+.*$'; then prefix=${__typex_reMatch[1]}; [[ $prefix == '--' ]] && isLong=1 || isLong=0; for ((i = 1; i < (isLong ? 2 : ${#1}); i++ )) do command typeset acceptOptArg=0 needOptArg=0 haveOptArgAttached=0 haveOptArgAsNextArg=0 optArgAttached= optArgOpt= optArgReq=; if (( isLong )); then optName=${1:2}; __typex_reMatch "$optName" '^([^=]+)=(.*)$' && { optName=${__typex_reMatch[1]}; optArgAttached=${__typex_reMatch[2]}; haveOptArgAttached=1 }; else optName=${1:$i:1}; optArgAttached=${1:$i+1}; (( ${#optArgAttached} >= 1 )) && haveOptArgAttached=1; fi; (( haveOptArgAttached )) && optArgOpt=$optArgAttached optArgReq=$optArgAttached || { (( $# > 1 )) && { optArgReq=$2; haveOptArgAsNextArg=1 } }; case $optName in p | files-only) fileSystemOnly=1 ;; v | verbose) verbose=1 ;; V | skip-version) noVersion=1 ;; i | install-sourcing) install=1 ;; u | uninstall-sourcing) uninstall=1 ;; *) { echo "$thisFuncName: ARGUMENT ERROR: Unknown option: ${prefix}${optName}" 1>&2; __typex_restore; return 2 } ;; esac; (( needOptArg )) && { (( ! haveOptArgAttached && ! haveOptArgAsNextArg )) && { echo "$thisFuncName: ARGUMENT ERROR: Option ${prefix}${optName} is missing its argument." 1>&2; __typex_restore; return 2 } || (( haveOptArgAsNextArg )) && shift }; (( acceptOptArg || needOptArg )) && break; done; else if [[ $1 == '--' ]]; then shift; operands+=("$@"); break; else if (( allowOptsAfterOperands )); then operands+=("$1"); else operands=("$@"); break; fi; fi; fi; shift; done; (( ${#operands[@]} > 0 )) && set -- "${operands[@]}"; unset allowOptsAfterOperands operands i optName isLong prefix optArgAttached haveOptArgAttached haveOptArgAsNextArg acceptOptArg needOptArg; if (( install || uninstall )); then (( !fileSystemOnly && !noVersion && !(install && uninstall) && $# == 0 )) || { echo "$thisFuncName: ARGUMENT ERROR: Incompatible options specified." 1>&2; __typex_restore; return 2 }; (( uninstall )) && install=0; command typeset shellCount=0 okCount=0; for shell in bash ksh zsh; do (( ++shellCount )); if [[ $TYPEX_TEST_ALL_INITFILES != '1' ]]; then if [[ -n $ZSH_VERSION ]]; then command which -p $shell > /dev/null 2>&1 || continue; else command which $shell > /dev/null 2>&1 || continue; fi; fi; __typex_install $shell $install $notSourced "$__typex_scriptpath" && (( ++okCount )); done; (( install && okCount )) && command printf '%s\n' 'Open a new shell tab or window for sourcing to take effect.'; if (( okCount == shellCount )); then __typex_restore; return 0; else __typex_restore; return $(( shellCount - okCount )); fi; fi; if (( $# == 0 )); then names=($(f=$(command ps -o comm= $( (( notSourced )) && command printf $PPID || command printf $$ )); [[ $f =~ ^- ]] && command printf %s "$SHELL" || command printf %s "$f")); fileSystemOnly=1; else names=("$@"); fi; if (( ! fileSystemOnly )); then fileSystemOnly=1; for name in "${names[@]}"; do [[ $name == */* ]] || { fileSystemOnly=0; break }; done; fi; if (( ! fileSystemOnly && notSourced )); then fileSystemOnly=1; if __typex_isParentSupportedShell; then command cat 1>&2 <\` To install sourcing persistently for interactive shells, run \`${__typex_scriptpath##*/} -i\`. Use \`-p\` to suppress this warning if you're only looking for executable *files*. EOF else command cat 1>&2 < /dev/null | command egrep -q ' keyword$' && isKeyword=1; else if [[ -n $ZSH_VERSION ]]; then command type -wa "$name" 2> /dev/null | command egrep -q ' reserved$' && isKeyword=1; else command type -ta "$name" 2> /dev/null | command fgrep -qx 'keyword' && isKeyword=1; fi; fi; if (( isKeyword )); then found=1; keywordOutput=$(command printf '%-10s %s' 'KEYWORD:' "$name"); fi; if [[ -n $keywordOutput && -n $KSH_VERSION ]]; then command printf '%s\n' "$keywordOutput"; fi; def=$(command alias "$name" 2>/dev/null); if [[ -n $def ]]; then found=1; command printf '%-10s %s\n' 'ALIAS:' "${def#alias }"; (( all )) || { __typex_restore; return 0 }; def=$(cut -d= -f2- <<<"$def" | tr -d \'\" | cut -d' ' -f1); typex -- "$def" 2> /dev/null | sed 's/^/ /'; fi; if [[ -n $keywordOutput && -z $KSH_VERSION ]]; then command printf '%s\n' "$keywordOutput"; fi; def=$(command typeset -f "$name" 2>/dev/null); if [[ -n $def ]]; then found=1; command printf '%-10s %s' 'FUNCTION:' "$name()"; if [[ -n $BASH_VERSION ]]; then command declare -F | command egrep -q -- "-fx $name\$" && command printf ' # -x'; fi; command printf '\n'; (( verbose )) && command sed 's/^/ /' <<< "$def"; (( all )) || { __typex_restore; return 0 }; fi; if [[ -n $KSH_VERSION ]]; then command builtin | command fgrep -qx -- "$name" && isBuiltIn=1; else if [[ -n $ZSH_VERSION ]]; then command type -wa -- "$name" 2> /dev/null | command egrep -q ':\s+builtin$' && isBuiltIn=1; else command type -ta -- "$name" 2> /dev/null | command fgrep -qx 'builtin' && isBuiltIn=1; fi; fi; if (( isBuiltIn )); then command printf '%-10s %s\n' 'BUILTIN:' "$name"; (( all )) || { __typex_restore; return 0 }; found=1; fi; fi; files=; if (( isExplicitPath )) || [[ $name == '.' ]]; then if [[ -d $name ]]; then files=$(command cd "$name" && command echo "$PWD"); else if [[ -e $name || -L $name ]]; then [[ ! -e $name ]] && brokenSymlink=1; [[ -n $KSH_VERSION && $name =~ ^'../.' ]] && name="${PWD%/}/$name"; files=$(command cd -- "$(command dirname -- "$name")" && command echo "${PWD%/}/")$(command basename -- "$name"); [[ $files =~ / ]] || { __typex_restore; return 1 }; else :; fi; fi; else if [[ -n $ZSH_VERSION ]]; then files=$(command which -ap -- "$name" 2>/dev/null) || files=''; else files=$(command which -a -- "$name" 2>/dev/null) || files=''; fi; fi; if [[ -n $files ]]; then found=1; while command read -r file; do (( brokenSymlink )) || extraOpt='-L'; fileType=$(command file -b $extraOpt -- "$file"); if [[ -d $file ]]; then fileCategory='DIRECTORY:'; else if [[ -x $file ]]; then scriptType=$(command egrep -o '(POSIX )?(\w+ )script' <<<"$fileType"); [[ -z $scriptType ]] && command egrep -q '\' <<< "$fileType" && scriptType='script w/o shebang line'; [[ -n $scriptType ]] && fileCategory='SCRIPT:' || fileCategory='BINARY:'; else fileCategory='FILE:'; fi; fi; fileLinkChain=$(__typex_rreadlinkchain "$file"); if [[ ! $fileLinkChain =~ ' ' ]]; then trueFile=$fileLinkChain; if [[ "$file" != "$trueFile" ]]; then command printf '%-10s %s -> %s' "$fileCategory" "$file" "$fileLinkChain"; else command printf '%-10s %s' "$fileCategory" "$file"; fi; else trueFile=$(command tail -n 1 <<<"$fileLinkChain"); command printf '%-10s %s' "$fileCategory" "$(command awk -v RS= -v sep=' -> ' '{ gsub("\n$", ""); gsub("\n", "@" sep); printf "%s", $0 }' <<<"$fileLinkChain")"; fi; if [[ -d $file ]]; then :; else if [[ -x $file ]]; then [[ -n $scriptType ]] && printf ' (%s)' "$scriptType"; ver=; if (( ! noVersion )); then ver=$("$file" --version &1 | command sed '/^$/d; q' | command fgrep -v -- '--version' | command fgrep -vi -- 'unknown invalid illegal unrecognized not recognized' | command egrep -i -e '[0-9]\.' -e 'version' -e 'build' ); fi; [[ -z $ver ]] && ver=$(__typex_getFileTimestamp "$trueFile" m '%Y-%m-%d'); printf ' [%s]' "$ver"; else printf ' (%s)' "$fileType"; fi; fi; if (( verbose )); then while command read -r thisfile; do command printf '\n %s' "$(command ls -dFAhl -- "$thisfile" | command cut -d/ -f1)"; done <<< "${fileLinkChain:-$file}"; if [[ ! -d $file ]]; then if [[ -n $scriptType ]]; then command printf '\n %s' "$(command head -n 1 "$file")"; else if [[ -x $file ]]; then command printf '\n %s' "$(sed '1! s/^/ /' <<<"$fileType")"; fi; fi; fi; fi; command printf '\n'; (( all )) || break; done <<< "$files"; fi; if (( ! found )); then (( ++numNotFound )); if (( isExplicitPath )); then errMsgSuffix=": No such file or directory, or insufficient permissions for inspection."; else (( fileSystemOnly )) && errMsgSuffix=' is not an executable in the PATH.' || errMsgSuffix=' is neither an alias, keyword, function, builtin, nor an executable in the PATH.'; [[ -e $name ]] && errMsgSuffix+=' However, it does exist as a filesystem item in the current directory. To target that, prefix with "./"'; fi; command printf '%s\n' "$thisFuncName: \"${name}\"${errMsgSuffix}" 1>&2; fi; done; __typex_restore; return $numNotFound } up () { local dir='../'; [[ "$1" == '-h' || "$1" == '--help' ]] && { echo -e "usage:\n\t$FUNCNAME [n]\n\t$FUNCNAME dirname\n Moves up N levels in the path to the current working directory, 1 by default.\n If DIRNAME is given, it must be the full name of an ancestral directory (case does not matter).\n If there are multiple matches, the one *lowest* in the hierarchy is changed to." && return 0 }; if [[ -n "$1" ]]; then if [[ $1 =~ ^[0-9]+$ ]]; then local strpath=$( printf "%${1}s" ); dir=${strpath// /$dir}; else if [[ $1 =~ ^/ ]]; then dir=$1; else local wdLower=$(echo -n "$PWD" | tr '[:upper:]' '[:lower:]'); local tokenLower=$(echo -n "$1" | tr '[:upper:]' '[:lower:]'); local newParentDirLower=${wdLower%/$tokenLower/*}; [[ "$newParentDirLower" == "$wdLower" ]] && { echo "$FUNCNAME: No ancestral directory named '$1' found." 1>&2; return 1 }; local targetDirPathLength=$(( ${#newParentDirLower} + 1 + ${#tokenLower} )); dir=${PWD:0:$targetDirPathLength}; fi; fi; fi; pushd "$dir" > /dev/null } vmrun () { "/Applications/VMware Fusion.app/Contents/Library/vmrun" "$@" } vo () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&1 | $FUNCNAME' instead of just '| $FUNCNAME'. - With COMMAND specified, executes it, and captures both its stdout and stderr output. If COMMAND returns a nonzero exit code, a warning is printed to stderr. This utility itself, however, always returns exit code 0. If the output captured contains ANSI color escape sequences or troff formatting such as from `man` output, such formatting is automatically removed. Examples: $FUNCNAME ls *.txt nosuch ls *.txt nosuch | $FUNCNAME ls *.txt nosuch 2>&1 | $FUNCNAME EOF return 0; fi local ph=''; [[ $(uname) == 'Darwin' ]] || ph='.XXXXXXXXXX'; local ftemp=$(mktemp -t "$FUNCNAME$ph"); if (( $# )); then ( shopt -s expand_aliases; eval "$@" 2>&1 | stripFormatting > "$ftemp"; [[ ${PIPESTATUS[0]} -eq 0 ]] || echo "$FUNCNAME: WARNING: Command returned nonzero exit code: ${PIPESTATUS[0]}" 1>&2 ); else cat | stripFormatting > "$ftemp"; fi; local editor=$(which -a subl code | fgrep -v -x "$MK_UTIL_FOLDER/subl" | head -n 1); [[ -n $editor ]] || { echo "ERROR: Neither \`code\` nor \`subl\` are in your PATH." 2> /dev/null; exit 1 }; local newWin=1; (( newWin )) && newWinOpt=--new-window; ( { "$editor" --wait $newWinOpt "$ftemp"; rm -f "$ftemp" } & ) } doIt there * The command line being run * The files being read (put the files on a webserver if they are big) If you get the error on smaller/fewer files, please include those instead. parallel: This should not happen. You have found a bug. Please contact and include: * The version number: 20170322 * The bugid: open3-GLOB(0x7fec0728e248) shopt -u autocd&>/dev/null; shopt -u cdable_vars&>/dev/null; shopt -u cdspell&>/dev/null; shopt -u checkhash&>/dev/null; shopt -u checkjobs&>/dev/null; shopt -u checkwinsize&>/dev/null; shopt -s cmdhist&>/dev/null; shopt -u compat31&>/dev/null; shopt -u compat32&>/dev/null; shopt -u compat40&>/dev/null; shopt -u compat41&>/dev/null; shopt -u compat42&>/dev/null; shopt -u compat43&>/dev/null; shopt -s complete_fullquote&>/dev/null; shopt -u direxpand&>/dev/null; shopt -u dirspell&>/dev/null; shopt -u dotglob&>/dev/null; shopt -u execfail&>/dev/null; shopt -s expand_aliases&>/dev/null; shopt -s extdebug&>/dev/null; shopt -u extglob&>/dev/null; shopt -s extquote&>/dev/null; shopt -u failglob&>/dev/null; shopt -s force_fignore&>/dev/null; shopt -u globasciiranges&>/dev/null; shopt -u globstar&>/dev/null; shopt -u gnu_errfmt&>/dev/null; shopt -u histappend&>/dev/null; shopt -u histreedit&>/dev/null; shopt -u histverify&>/dev/null; shopt -s hostcomplete&>/dev/null; shopt -u huponexit&>/dev/null; shopt -u inherit_errexit&>/dev/null; shopt -s interactive_comments&>/dev/null; shopt -u lastpipe&>/dev/null; shopt -u lithist&>/dev/null; shopt -u login_shell&>/dev/null; shopt -u mailwarn&>/dev/null; shopt -s no_empty_cmd_completion&>/dev/null; shopt -s nocaseglob&>/dev/null; shopt -u nocasematch&>/dev/null; shopt -u nullglob&>/dev/null; shopt -s progcomp&>/dev/null; shopt -s promptvars&>/dev/null; shopt -u restricted_shell&>/dev/null; shopt -u shift_verbose&>/dev/null; shopt -s sourcepath&>/dev/null; shopt -u xpg_echo&>/dev/null; shopt -s expand_aliases &>/dev/null alias ash='(f=$(ps -o comm= $$); [[ $f =~ ^- ]] && echo $SHELL || which "$f")' alias bi='bundleid' alias bv='echo $BASH_VERSION' alias cdb='cd "$OLDPWD"' alias cpg='"$HOME/Desktop/pg"/cpg' alias dec='de "$@"' alias dn='/dev/null' alias dpg='"$HOME/Desktop/pg"/dpg' alias dt='cat -et' alias e='/Users/jdoe/MkUtil/editf' alias ecc='editf $MK_UTIL_FOLDER/sourced.d/bash_completion.d/custom-completions' alias ecpg='editf "$HOME/Desktop/pg"/cpg' alias edpg='editf "$HOME/Desktop/pg"/dpg' alias eh='enc --html' alias ei='editf ~/.bashrc' alias ejaypg='editf "$HOME/Desktop/pg"/jaypg' alias ekpg='editf "$HOME/Desktop/pg"/kpg' alias enp='editf ~/.nesh_profile.coffee' alias enpg='editf "$HOME/Desktop/pg"/npg' alias ep='editf ~/.bash_profile' alias epg='editf "$HOME/Desktop/pg"/pg' alias epg.cpp='editf "$HOME/Desktop/pg"/pg.cpp' alias epg.cs='editf "$HOME/Desktop/pg"/pg.cs' alias epg.html='editf "$HOME/Desktop/pg"/pg.html' alias epg.md='editf "$HOME/Desktop/pg"/pg.md' alias epg.ts='editf "$HOME/Desktop/pg"/pg.ts' alias epg2='editf "$HOME/Desktop/pg"/pg2' alias epg4='editf "$HOME/Desktop/pg"/pg4' alias epgjxa.scpt='editf "$HOME/Desktop/pg"/pgjxa.scpt' alias ephpg='editf "$HOME/Desktop/pg"/phpg' alias epi='editf ~/.perli_rc' alias eplpg='editf "$HOME/Desktop/pg"/plpg' alias epy3pg='editf "$HOME/Desktop/pg"/py3pg' alias epypg='editf "$HOME/Desktop/pg"/pypg' alias eqcd='editf $MK_UTIL_FOLDER/sourced.d/quickCdDefs' alias erpg='editf "$HOME/Desktop/pg"/rpg' alias es='edits' alias eshallpg='editf "$HOME/Desktop/pg"/shallpg' alias eshpg='editf "$HOME/Desktop/pg"/shpg' alias etclpg='editf "$HOME/Desktop/pg"/tclpg' alias eu='enc --uri' alias ex='enc --xml' alias exppg='editf "$HOME/Desktop/pg"/xppg' alias ezpg='editf "$HOME/Desktop/pg"/zpg' alias fhx='od -t x1' alias fp='fullpath' alias fq='findq' alias fx='findexes' alias gc='git checkout' alias gcb='pbpaste' alias gcm='typex' alias gfs='getFinderSel' alias gl='git log --pretty=oneline' alias gs='git status -b --short' alias gt='git describe --abbrev=0 --tags' alias gvr='git remote -v | awk '\''{ print $2; exit }'\'' | xargs open' alias hd='hexdump' alias hg='echo "(Using MacHg binary via an alias.)"; "/Applications/MacHg.app/Contents/Resources/localhg"' alias imgcat='/Users/jdoe/.iterm2/imgcat' alias imgls='/Users/jdoe/.iterm2/imgls' alias it2attention='/Users/jdoe/.iterm2/it2attention' alias it2check='/Users/jdoe/.iterm2/it2check' alias it2copy='/Users/jdoe/.iterm2/it2copy' alias it2dl='/Users/jdoe/.iterm2/it2dl' alias it2getvar='/Users/jdoe/.iterm2/it2getvar' alias it2setcolor='/Users/jdoe/.iterm2/it2setcolor' alias it2setkeylabel='/Users/jdoe/.iterm2/it2setkeylabel' alias it2ul='/Users/jdoe/.iterm2/it2ul' alias it2universion='/Users/jdoe/.iterm2/it2universion' alias jaypg='"$HOME/Desktop/pg"/jaypg' alias josa='osascript -l JavaScript' alias kbs='keyboardspec' alias kpg='"$HOME/Desktop/pg"/kpg' alias lf='declare -F | awk '\''{ print $3 }'\''' alias lfe='declare -Fx | awk -F'\''[ =]'\'' '\''{ print $3 }'\''' alias lsregister='/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister' alias lsx='fls -FAhl' alias lv='(shopt -so posix; declare | awk -F= '\''{ print $1 }'\'')' alias lve='export -p | awk -F'\''[ =]'\'' '\''{ print $3 }'\''' alias lx='PATH=".:$PATH"' alias m='manx' alias md='mkdir' alias mdp='markdown.pl' alias mg='manxg' alias mmdp='multimarkdown' alias mo='manopt' alias mu='markup-js' alias mw='manw' alias ne='node -e' alias np='node -p' alias npg='"$HOME/Desktop/pg"/npg' alias npmenv='echo "ENTERING CHILD SHELL with npm ENVIRONMENT for $PWD..." && npm run env -- $SHELL || echo "ERROR: You must call this function from an npm package directory; child shell NOT entered." >&2' alias npmh='npm home' alias nr='npm run' alias ns='newscript' alias nsh='nesh -e <(coffee -bp ~/.nesh_profile.coffee)' alias nshc='nesh -c -e ~/.nesh_profile.coffee' alias nt='newtab' alias nw='newwin' alias nx='npm run-script env --' alias o='open' alias oa='open -a' alias oda='od -a' alias odx='od -t x1' alias omd='open -a '\''Marked 2'\''' alias osa='osascript' alias ou='openurl' alias oud='openurl -d' alias p='printf "%s\n"' alias p1='ping -c 1 -t 1' alias pd='perldoc' alias pf='declare -f' alias pg='"$HOME/Desktop/pg"/pg' alias pg.cpp='g++ -o "$HOME/Desktop/pg"/pgb "$HOME/Desktop/pg"/pg.cpp && "$HOME/Desktop/pg"/pgb' alias pg.cs='pushd "$HOME/Desktop/pg"/pg.cs >/dev/null && echo === NOTE: cwd is temporarily ./pg.cs === && dotnet run; popd >/dev/null' alias pg.html='"$HOME/Desktop/pg"/pg.html' alias pg.md='open -a Marked.app -- "$HOME/Desktop/pg"/pg.md' alias pg.ts='printf "Compiling to "$HOME/Desktop/pg"/pg.js (tsc) and invoking (node)..." && tsc "$HOME/Desktop/pg"/pg.ts && printf "\r%*s\r" 79 && node "$HOME/Desktop/pg"/pg.js' alias pg2='"$HOME/Desktop/pg"/pg2' alias pg4='"$HOME/Desktop/pg"/pg4' alias pgjxa.scpt='osascript -l JavaScript "$HOME/Desktop/pg"/pgjxa.scpt' alias phpg='"$HOME/Desktop/pg"/phpg' alias plb='/usr/libexec/PlistBuddy' alias plpg='"$HOME/Desktop/pg"/plpg' alias posh='powershell' alias ptc='pathToClipboard' alias py='python' alias py2='python' alias py3='python3' alias py3pg='"$HOME/Desktop/pg"/py3pg' alias pypg='"$HOME/Desktop/pg"/pypg' alias q='quote' alias rbn='shutdownnow -r' alias ri='{ echo "Reloading the initialization file (~/.bashrc)..."; . ~/.bashrc; }' alias rp='{ echo "Reloading the profile file (~/.bash_profile)..."; . ~/.bash_profile; }' alias rpg='"$HOME/Desktop/pg"/rpg' alias rsi='resizeimages' alias scb='tc' alias sdn='shutdownnow' alias shallpg='"$HOME/Desktop/pg"/shallpg' alias sho='vo' alias shpg='"$HOME/Desktop/pg"/shpg' alias sln='shutdownnow -s' alias st='steroids' alias tcl='rlwrap tclsh' alias tclpg='"$HOME/Desktop/pg"/tclpg' alias tkc='(tkcon &) && osascript <<<$'\''repeat while true\n delay 0.1\n if application "Wish" is running then\n try\n activate application "Wish"\n return\n end try\n end if\nend repeat'\''' alias toascii='iconv -f utf8 -t ascii -c' alias topc='top -l 2 -n 10 -o cpu -stats cpu,command | fgrep -v " top" | tail -n 10' alias tp='typex' alias ts='timestamps' alias ueh='enc -u --html' alias ueu='enc -u --uri' alias uex='enc -u --xml' alias uti='mdls -name kMDItemContentType' alias utis='mdls -name kMDItemContentTypeTree' alias vman='marked-man | cat >/tmp/vman$$ && man /tmp/vman$$' alias vmd='cat >/tmp/vmd$$ && open -a "Marked 2" /tmp/vmd$$' alias wh='which' alias wha='whichapp' alias xppg='"$HOME/Desktop/pg"/xppg' alias zpg='"$HOME/Desktop/pg"/zpg' declare -x Apple_PubSub_Socket_Render="/private/tmp/com.apple.launchd.ZSsLeK3KyX/Render" declare -- BASH="/usr/local/bin/bash4" declare -x CLICOLOR="" declare -x COLORFGBG="0;15" declare -x COLORTERM="truecolor" declare -- COLUMNS="220" declare -x COMP_WORDBREAKS="@ \"'><;|&(:" declare -x DISPLAY="/private/tmp/com.apple.launchd.WdrYFjwfT0/org.macosforge.xquartz:0" declare -x EDITOR="sublwait" declare -x FCEDIT="sublwait" declare -x GEM_HOME="/Users/jdoe/.rvm/gems/ruby-2.4.0" declare -x GEM_PATH="/Users/jdoe/.rvm/gems/ruby-2.4.0:/Users/jdoe/.rvm/gems/ruby-2.4.0@global" declare -i HISTCMD="1" declare -- HISTCONTROL="ignoredups" declare -- HISTFILE="/Users/jdoe/.bash_history" declare -- HISTFILESIZE="500" declare -- HISTSIZE="500" declare -x HOME="/Users/jdoe" declare -- HOSTNAME="MkiMac.home" declare -- HOSTTYPE="x86_64" declare -- IFS=" " declare -x IRBRC="/Users/jdoe/.rvm/rubies/ruby-2.4.0/.irbrc" declare -x ITERM_ORIG_PS1="\$( [ \"\$USER\" = 'root' ] && printf %s \\u:\\w || # sudo { { [ \"\$0\" = 'bash' ] || [ \"\$0\" = '/bin/bash' ] || [ \"\$0\" = '-bash' ]; } && { # bash _PS1 30 # cwd-shortening function if [[ -d .git ]]; then # git repos: show the branch name and, if there are uncommitted changes, append an asterisk printf ' [%s%s]' \"\$(git symbolic-ref --short HEAD 2>/dev/null || echo '(NO HEAD)')\" \"\$([[ -n \$(git status --porcelain) ]] && printf '\\[\\e[0;31m\\]*\\[\\e[0m\\]')\" fi } || printf \"[\$0] \$PWD\" # other shells; note that we can't use coloring in a cross-shell-compatible fashion } printf '\$ ' )" declare -- ITERM_PREEXEC_INTERACTIVE_MODE="" declare -x ITERM_PREV_PS1="\\[133;D;\$?1337;RemoteHost=jdoe@MkiMac.home1337;CurrentDir=/Users/jdoe/Desktop/pg133;A\\]\$( [ \"\$USER\" = 'root' ] && printf %s \\u:\\w || # sudo { { [ \"\$0\" = 'bash' ] || [ \"\$0\" = '/bin/bash' ] || [ \"\$0\" = '-bash' ]; } && { # bash _PS1 30 # cwd-shortening function if [[ -d .git ]]; then # git repos: show the branch name and, if there are uncommitted changes, append an asterisk printf ' [%s%s]' \"\$(git symbolic-ref --short HEAD 2>/dev/null || echo '(NO HEAD)')\" \"\$([[ -n \$(git status --porcelain) ]] && printf '\\[\\e[0;31m\\]*\\[\\e[0m\\]')\" fi } || printf \"[\$0] \$PWD\" # other shells; note that we can't use coloring in a cross-shell-compatible fashion } printf '\$ ' )\\[133;B\\]" declare -x ITERM_PROFILE="Default" declare -x ITERM_SESSION_ID="w0t0p0:F3C22F95-3FCF-4888-A3A1-D57093BD9C50" declare -- ITERM_SHELL_INTEGRATION_INSTALLED="Yes" declare -x LANG="en_US.UTF-8" declare -i LINENO="70" declare -- LINES="75" declare -x LOGNAME="jdoe" declare -- MACHTYPE="x86_64-apple-darwin16.3.0" declare -i MAILCHECK="60" declare -x MK_PLAYGROUND_FOLDER="/Users/jdoe/Desktop/pg" declare -x MK_UTIL_FOLDER="/Users/jdoe/MkUtil" declare -x MK_UTIL_FOLDER_PERSONAL="/Users/jdoe/MkUtil.Win/Users/jdoe" declare -x MY_RUBY_HOME="/Users/jdoe/.rvm/rubies/ruby-2.4.0" declare -x N_PREFIX="/Users/jdoe/n" declare -x OLDPWD="/Users/jdoe" declare -- OPTERR="1" declare -i OPTIND="1" declare -- OSTYPE="darwin16.3.0" declare -x PATH="/Users/jdoe/.rvm/gems/ruby-2.4.0/bin:/Users/jdoe/.rvm/gems/ruby-2.4.0@global/bin:/Users/jdoe/.rvm/rubies/ruby-2.4.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/jdoe/bin:/Users/jdoe/MkUtil:/Users/jdoe/.dotnet:/Users/jdoe/n/bin:/Users/jdoe/.rvm/bin" declare -- PROMPT_COMMAND="iterm2_preexec_invoke_cmd" declare -x PS1="\$( [ \"\$USER\" = 'root' ] && printf %s \\u:\\w || # sudo { { [ \"\$0\" = 'bash' ] || [ \"\$0\" = '/bin/bash' ] || [ \"\$0\" = '-bash' ]; } && { # bash _PS1 30 # cwd-shortening function if [[ -d .git ]]; then # git repos: show the branch name and, if there are uncommitted changes, append an asterisk printf ' [%s%s]' \"\$(git symbolic-ref --short HEAD 2>/dev/null || echo '(NO HEAD)')\" \"\$([[ -n \$(git status --porcelain) ]] && printf '\\[\\e[0;31m\\]*\\[\\e[0m\\]')\" fi } || printf \"[\$0] \$PWD\" # other shells; note that we can't use coloring in a cross-shell-compatible fashion } printf '\$ ' )" declare -- PS2="> " declare -- PS4="+ " declare -x PWD="/Users/jdoe/Desktop/pg" declare -i RANDOM="13804" declare -x RUBY_VERSION="ruby-2.4.0" declare -i SECONDS="91" declare -x SECURITYSESSIONID="186a7" declare -x SHELL="/bin/bash" declare -x SHLVL="2" declare -x SSH_AUTH_SOCK="/private/tmp/com.apple.launchd.QpR2TVefkw/Listeners" declare -x TERM="xterm" declare -x TERM_PROGRAM="iTerm.app" declare -x TERM_PROGRAM_VERSION="3.1.beta.3" declare -x TERM_SESSION_ID="w0t0p0:F3C22F95-3FCF-4888-A3A1-D57093BD9C50" declare -x TMPDIR="/var/folders/19/0lxcl7hd63d6fqd813glqppc0000gn/T/" declare -x USER="jdoe" declare -x XPC_FLAGS="0x0" declare -x XPC_SERVICE_NAME="0" declare -x __CF_USER_TEXT_ENCODING="0x1F5:0x0:0x0" declare -- __git_all_commands="" declare -- __git_diff_algorithms="myers minimal patience histogram" declare -- __git_diff_common_options="--stat --numstat --shortstat --summary --patch-with-stat --name-only --name-status --color --no-color --color-words --no-renames --check --full-index --binary --abbrev --diff-filter= --find-copies-harder --text --ignore-space-at-eol --ignore-space-change --ignore-all-space --ignore-blank-lines --exit-code --quiet --ext-diff --no-ext-diff --no-prefix --src-prefix= --dst-prefix= --inter-hunk-context= --patience --histogram --minimal --raw --word-diff --dirstat --dirstat= --dirstat-by-file --dirstat-by-file= --cumulative --diff-algorithm= " declare -- __git_fetch_options=" --quiet --verbose --append --upload-pack --force --keep --depth= --tags --no-tags --all --prune --dry-run --recurse-submodules= " declare -- __git_fetch_recurse_submodules="yes on-demand no" declare -- __git_flow_config_file_options=" --local --global --system --file= " declare -- __git_format_patch_options=" --stdout --attach --no-attach --thread --thread= --no-thread --numbered --start-number --numbered-files --keep-subject --signoff --signature --no-signature --in-reply-to= --cc= --full-index --binary --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix= --inline --suffix= --ignore-if-in-upstream --subject-prefix= --output-directory --reroll-count --to= --quiet --notes " declare -- __git_log_common_options=" --not --all --branches --tags --remotes --first-parent --merges --no-merges --max-count= --max-age= --since= --after= --min-age= --until= --before= --min-parents= --max-parents= --no-min-parents --no-max-parents " declare -- __git_log_date_formats="relative iso8601 rfc2822 short local default raw" declare -- __git_log_gitk_options=" --dense --sparse --full-history --simplify-merges --simplify-by-decoration --left-right --notes --no-notes " declare -- __git_log_pretty_formats="oneline short medium full fuller email raw format:" declare -- __git_log_shortlog_options=" --author= --committer= --grep= --all-match " declare -- __git_merge_options=" --no-commit --no-stat --log --no-log --squash --strategy --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit --verify-signatures --no-verify-signatures --gpg-sign --quiet --verbose --progress --no-progress " declare -- __git_merge_strategies="" declare -- __git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare " declare -- __git_porcelain_commands="" declare -- __git_push_recurse_submodules="check on-demand" declare -- __git_send_email_confirm_options="always never auto cc compose" declare -- __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all" declare -- __git_whitespacelist="nowarn warn error error-all fix" declare -- __typex_scriptpath="/Users/jdoe/n/bin/typex" declare -- _grep_REGEXP="(.*)" declare -- _ignore_UNDERSCORE="" declare -- _list_alias_BODIES="alias ash bi bv cdb cpg dec dn dpg dt e ecc ecpg edpg eh ei ejaypg ekpg enp enpg ep epg epg.cpp epg.cs epg.html epg.md epg.ts epg2 epg4 epgjxa.scpt ephpg epi eplpg epy3pg epypg eqcd erpg es eshallpg eshpg etclpg eu ex exppg ezpg fhx fp fq fx gc gcb gcm gfs gl gs gt gvr hd hg imgcat imgls it2attention it2check it2copy it2dl it2getvar it2setcolor it2setkeylabel it2ul it2universion jaypg josa kbs kpg lf lfe lsregister lsx lv lve lx m md mdp mg mmdp mo mu mw ne np npg npmenv npmh nr ns nsh nshc nt nw nx o oa oda odx omd osa ou oud p p1 pd pf pg pg.cpp pg.cs pg.html pg.md pg.ts pg2 pg4 pgjxa.scpt phpg plb plpg posh ptc py py2 py3 py3pg pypg q rbn ri rp rpg rsi scb sdn shallpg sho shpg sln st tcl tclpg tkc toascii topc tp ts ueh ueu uex uti utis vman vmd wh wha xppg zpg" declare -- _list_function_BODIES="typeset -f = =awk =gawk =mawk =perl _PS1 __git_aliased_command __git_aliases __git_commands __git_complete __git_complete_file __git_complete_force_with_lease __git_complete_index_file __git_complete_remote_or_refspec __git_complete_revlist __git_complete_revlist_file __git_complete_strategy __git_compute_all_commands __git_compute_merge_strategies __git_compute_porcelain_commands __git_config_get_set_variables __git_count_arguments __git_find_on_cmdline __git_flow_config __git_flow_feature __git_flow_hotfix __git_flow_init __git_flow_list_branches __git_flow_list_local_branches __git_flow_list_remote_branches __git_flow_prefix __git_flow_release __git_flow_support __git_func_wrap __git_has_doubledash __git_heads __git_index_files __git_list_all_commands __git_list_merge_strategies __git_list_porcelain_commands __git_ls_files_helper __git_main __git_match_ctag __git_pretty_aliases __git_reassemble_comp_words_by_ref __git_refs __git_refs2 __git_refs_remotes __git_remotes __git_tags __git_wrap__git_main __git_wrap__gitk_main __gitcomp __gitcomp_file __gitcomp_nl __gitcomp_nl_append __gitcompadd __gitcompappend __gitdir __gitk_main __typex_isParentSupportedShell __typex_isSupportedShell _complete_edits _complete_lx _complete_make _complete_pf _complete_pv _complete_unset _complete_up _get_comp_words_by_ref _git _git_add _git_am _git_apply _git_archive _git_bisect _git_branch _git_bundle _git_checkout _git_cherry _git_cherry_pick _git_clean _git_clone _git_commit _git_config _git_describe _git_diff _git_difftool _git_fetch _git_flow _git_format_patch _git_fsck _git_gc _git_gitk _git_grep _git_help _git_init _git_log _git_ls_files _git_ls_remote _git_ls_tree _git_merge _git_merge_base _git_mergetool _git_mv _git_name_rev _git_notes _git_pull _git_push _git_rebase _git_reflog _git_remote _git_replace _git_reset _git_revert _git_rm _git_send_email _git_shortlog _git_show _git_show_branch _git_stage _git_stash _git_submodule _git_svn _git_tag _git_whatchanged _gitk _npm_completion _tobase af brm calc cdp de dfs difs doIt docker-start docker-stop dsh ec env_parallel f fa fag fas fasu fau fawf fawfc fawfd fawfp fcfg fcu fd fdb fdbp fdl fdla fdt feb febi febo ff fh fhomer fic fif findexes findq fkkac fkkai fl fla flau flsys flu fngb fngm fobt foldIndent foss fpg fpgw fph fppg fpr fpref fprefu fql fqlu fs fsba fsd fsl fslu fsn fsph fss fstp fstpu fsu fsv fsvms ft ftr ftu fu fub fuc fulb fullpath fus fuw fvms fwac getip getips installnode iterm2_begin_osc iterm2_end_osc iterm2_preexec_install iterm2_preexec_invoke_cmd iterm2_preexec_invoke_exec iterm2_print_state_data iterm2_print_user_vars iterm2_print_version_number iterm2_prompt_mark iterm2_prompt_prefix iterm2_prompt_suffix iterm2_set_user_var kill-script list-available-locales lock lsp mang manx manxg mkcd mktempfile npmf npml pathToClipboard pbpaste_html pbpaste_rtf pifs precmd preexec pushdX pv ql resetcolors resume-script sl stripColors stripFormatting suspend-script tc tobin todec tohex tooct trim typex up vmrun vo" declare -x _system_arch="x86_64" declare -x _system_name="OSX" declare -x _system_type="Darwin" declare -x _system_version="10.12" declare -- hist_ent=" 502 . pg; doIt() { echo \"\$\$: [\$*]\"; }; { echo hi; echo there; echo you; echo too; } | env_parallel -n 1 -j 12 doIt {} 2>&1 | vo" declare -- iterm2_hostname="MkiMac.home" declare -- iterm2_ran_preexec="yes" declare -- last_hist_ent=" 502 . pg; doIt() { echo \"\$\$: [\$*]\"; }; { echo hi; echo there; echo you; echo too; } | env_parallel -n 1 -j 12 doIt {} 2>&1 | vo" declare -x rvm_bin_path="/Users/jdoe/.rvm/bin" declare -x rvm_path="/Users/jdoe/.rvm" declare -x rvm_prefix="/Users/jdoe" declare -x rvm_version="1.29.1 (latest)" = () { =perl "$@" } =awk () { local awkBin=${FUNCNAME[1]}; awkBin=${awkBin:-$FUNCNAME}; awkBin=${awkBin#=}; $awkBin "BEGIN { print $* }" } =gawk () { =awk "$@" } =mawk () { =awk "$@" } =perl () { [[ $1 == '-h' || $1 == '--help' ]] && { echo 'Simple command-line calcuations using Perl - the expression specfied is passed as-is to Perl'\''s `print`. Examples: =perl 0x41 =perl 2**10'; return 0 }; perl -le "print $*" } _PS1 () { local pre= name="$PWD" length="$1"; if (( length > 0 )); then [[ "$name" != "${name#$HOME/}" || -z "${name#$HOME}" ]] && pre+='~' name="${name#$HOME}" length=$[length-1]; ((${#name}>$length)) && name="/...${name:$[${#name}-length+4]}"; fi; printf '%s' "$pre$name" } __git_aliased_command () { local word cmdline=$(git --git-dir="$(__gitdir)" config --get "alias.$1"); for word in $cmdline; do case "$word" in \!gitk | gitk) echo "gitk"; return ;; \!*) : shell command alias ;; -*) : option ;; *=*) : setting env ;; git) : git itself ;; \(\)) : skip parens of shell function definition ;; {) : skip start of shell helper function ;; :) : skip null command ;; \'*) : skip opening quote after sh -c ;; *) echo "$word"; return ;; esac; done } __git_aliases () { local i IFS=' '; for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do case "$i" in alias.*) i="${i#alias.}"; echo "${i/ */}" ;; esac; done } __git_commands () { if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}"; then printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"; else git help -a | egrep '^ [a-zA-Z0-9]'; fi } __git_complete () { local wrapper="__git_wrap${2}"; eval "$wrapper () { __git_func_wrap $2 ; }"; complete -o bashdefault -o default -o nospace -F $wrapper $1 2> /dev/null || complete -o default -o nospace -F $wrapper $1 } __git_complete_file () { __git_complete_revlist_file } __git_complete_force_with_lease () { local cur_=$1; case "$cur_" in --*=) ;; *:*) __gitcomp_nl "$(__git_refs)" "" "${cur_#*:}" ;; *) __gitcomp_nl "$(__git_refs)" "" "$cur_" ;; esac } __git_complete_index_file () { local pfx="" cur_="$cur"; case "$cur_" in ?*/*) pfx="${cur_%/*}"; cur_="${cur_##*/}"; pfx="${pfx}/" ;; esac; __gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_" } __git_complete_remote_or_refspec () { local cur_="$cur" cmd="${words[1]}"; local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0; if [ "$cmd" = "remote" ]; then ((c++)); fi; while [ $c -lt $cword ]; do i="${words[c]}"; case "$i" in --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;; --all) case "$cmd" in push) no_complete_refspec=1 ;; fetch) return ;; *) ;; esac ;; -*) ;; *) remote="$i"; break ;; esac; ((c++)); done; if [ -z "$remote" ]; then __gitcomp_nl "$(__git_remotes)"; return; fi; if [ $no_complete_refspec = 1 ]; then return; fi; [ "$remote" = "." ] && remote=; case "$cur_" in *:*) case "$COMP_WORDBREAKS" in *:*) : great ;; *) pfx="${cur_%%:*}:" ;; esac; cur_="${cur_#*:}"; lhs=0 ;; +*) pfx="+"; cur_="${cur_#+}" ;; esac; case "$cmd" in fetch) if [ $lhs = 1 ]; then __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"; else __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"; fi ;; pull | remote) if [ $lhs = 1 ]; then __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"; else __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"; fi ;; push) if [ $lhs = 1 ]; then __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"; else __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"; fi ;; esac } __git_complete_revlist () { __git_complete_revlist_file } __git_complete_revlist_file () { local pfx ls ref cur_="$cur"; case "$cur_" in *..?*:*) return ;; ?*:*) ref="${cur_%%:*}"; cur_="${cur_#*:}"; case "$cur_" in ?*/*) pfx="${cur_%/*}"; cur_="${cur_##*/}"; ls="$ref:$pfx"; pfx="$pfx/" ;; *) ls="$ref" ;; esac; case "$COMP_WORDBREAKS" in *:*) : great ;; *) pfx="$ref:$pfx" ;; esac; __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" 2>/dev/null | sed '/^100... blob /{ s,^.* ,, s,$, , } /^120000 blob /{ s,^.* ,, s,$, , } /^040000 tree /{ s,^.* ,, s,$,/, } s/^.* //')" "$pfx" "$cur_" "" ;; *...*) pfx="${cur_%...*}..."; cur_="${cur_#*...}"; __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" ;; *..*) pfx="${cur_%..*}.."; cur_="${cur_#*..}"; __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" ;; *) __gitcomp_nl "$(__git_refs)" ;; esac } __git_complete_strategy () { __git_compute_merge_strategies; case "$prev" in -s | --strategy) __gitcomp "$__git_merge_strategies"; return 0 ;; esac; case "$cur" in --strategy=*) __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"; return 0 ;; esac; return 1 } __git_compute_all_commands () { test -n "$__git_all_commands" || __git_all_commands=$(__git_list_all_commands) } __git_compute_merge_strategies () { test -n "$__git_merge_strategies" || __git_merge_strategies=$(__git_list_merge_strategies) } __git_compute_porcelain_commands () { __git_compute_all_commands; test -n "$__git_porcelain_commands" || __git_porcelain_commands=$(__git_list_porcelain_commands) } __git_config_get_set_variables () { local prevword word config_file= c=$cword; while [ $c -gt 1 ]; do word="${words[c]}"; case "$word" in --system | --global | --local | --file=*) config_file="$word"; break ;; -f | --file) config_file="$word $prevword"; break ;; esac; prevword=$word; c=$((--c)); done; git --git-dir="$(__gitdir)" config $config_file --list 2> /dev/null | while read -r line; do case "$line" in *.*=*) echo "${line/=*/}" ;; esac; done } __git_count_arguments () { local word i c=0; for ((i=1; i < ${#words[@]}; i++)) do word="${words[i]}"; case "$word" in --) ((c = 0)) ;; "$1") ((c = 0)) ;; ?*) ((c++)) ;; esac; done; printf "%d" $c } __git_find_on_cmdline () { local word subcommand c=1; while [ $c -lt $cword ]; do word="${words[c]}"; for subcommand in $1; do if [ "$subcommand" = "$word" ]; then echo "$subcommand"; return; fi; done; ((c++)); done } __git_flow_config () { local subcommands="list set base"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in set) case "$cur" in --*) __gitcomp " $__git_flow_config_file_options "; return ;; esac; __gitcomp " master develop feature hotfix release support versiontagprefix "; return ;; base) case "$cur" in --*) __gitcomp " set get "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches)"; return ;; *) COMPREPLY=() ;; esac } __git_flow_feature () { local subcommands="list start finish publish track diff rebase checkout pull help delete"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in pull) __gitcomp_nl "$(__git_remotes)"; return ;; checkout) __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; delete) case "$cur" in --*) __gitcomp " --noforce --force --noremote --remote "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; finish) case "$cur" in --*) __gitcomp " --nofetch --fetch --norebase --rebase --nopreserve-merges --preserve-merges --nokeep --keep --keepremote --keeplocal --noforce_delete --force_delete --nosquash --squash --no-ff "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; diff) __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; publish) __gitcomp_nl "$(__git_flow_list_branches 'feature')"; return ;; track) __gitcomp_nl "$(__git_flow_list_branches 'feature')"; return ;; *) COMPREPLY=() ;; esac } __git_flow_hotfix () { local subcommands="list start finish track publish help delete"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in finish) case "$cur" in --*) __gitcomp " --nofetch --fetch --sign --signingkey --message --nomessagefile --messagefile= --nopush --push --nokeep --keep --keepremote --keeplocal --noforce_delete --force_delete --notag --tag --nonobackmerge --nobackmerge "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"; return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"; return ;; delete) case "$cur" in --*) __gitcomp " --noforce --force --noremote --remote "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"; return ;; publish) __gitcomp_nl "$(__git_flow_list_branches 'hotfix')"; return ;; track) __gitcomp_nl "$(__git_flow_list_branches 'hotfix')"; return ;; start) case "$cur" in --*) __gitcomp " --nofetch --fetch "; return ;; esac; return ;; *) COMPREPLY=() ;; esac } __git_flow_init () { local subcommands="help"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; fi; case "$cur" in --*) __gitcomp " --nodefaults --defaults --noforce --force $__git_flow_config_file_options "; return ;; esac } __git_flow_list_branches () { local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"; if [ -n "$1" ]; then local prefix="$(__git_flow_prefix $1)"; git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix | while read -r entry; do eval "$entry"; ref="${ref##$prefix}"; echo "$ref"; done | sort; else git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort; fi } __git_flow_list_local_branches () { if [ -n "$1" ]; then local prefix="$(__git_flow_prefix $1)"; git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix | while read -r entry; do eval "$entry"; ref="${ref#$prefix}"; echo "$ref"; done | sort; else git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort; fi } __git_flow_list_remote_branches () { local prefix="$(__git_flow_prefix $1)"; local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"; git for-each-ref --shell --format='%(refname:short)' refs/remotes/$origin/$prefix | while read -r entry; do eval "$entry"; ref="${ref##$prefix}"; echo "$ref"; done | sort } __git_flow_prefix () { case "$1" in feature | release | hotfix | support) git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/"; return ;; esac } __git_flow_release () { local subcommands="list start finish track publish help delete"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in finish) case "$cur" in --*) __gitcomp " --nofetch --fetch --sign --signingkey --message --nomessagefile --messagefile= --nopush --push --nokeep --keep --keepremote --keeplocal --noforce_delete --force_delete --notag --tag --nonobackmerge --nobackmerge --nosquash --squash "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'release')"; return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'release')"; return ;; delete) case "$cur" in --*) __gitcomp " --noforce --force --noremote --remote "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'release')"; return ;; publish) __gitcomp_nl "$(__git_flow_list_branches 'release')"; return ;; track) __gitcomp_nl "$(__git_flow_list_branches 'release')"; return ;; start) case "$cur" in --*) __gitcomp " --nofetch --fetch "; return ;; esac; return ;; *) COMPREPLY=() ;; esac } __git_flow_support () { local subcommands="list start help"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in start) case "$cur" in --*) __gitcomp " --nofetch --fetch "; return ;; esac; return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'support')"; return ;; *) COMPREPLY=() ;; esac } __git_func_wrap () { local cur words cword prev; _get_comp_words_by_ref -n =: cur words cword prev; $1 } __git_has_doubledash () { local c=1; while [ $c -lt $cword ]; do if [ "--" = "${words[c]}" ]; then return 0; fi; ((c++)); done; return 1 } __git_heads () { local dir="$(__gitdir)"; if [ -d "$dir" ]; then git --git-dir="$dir" for-each-ref --format='%(refname:short)' refs/heads; return; fi } __git_index_files () { local dir="$(__gitdir)" root="${2-.}" file; if [ -d "$dir" ]; then __git_ls_files_helper "$root" "$1" | while read -r file; do case "$file" in ?*/*) echo "${file%%/*}" ;; *) echo "$file" ;; esac; done | sort | uniq; fi } __git_list_all_commands () { local i IFS=" "' '; for i in $(__git_commands); do case $i in *--*) : helper pattern ;; *) echo $i ;; esac; done } __git_list_merge_strategies () { git merge -s help 2>&1 | sed -n -e '/[Aa]vailable strategies are: /,/^$/{ s/\.$// s/.*:// s/^[ ]*// s/[ ]*$// p }' } __git_list_porcelain_commands () { local i IFS=" "' '; __git_compute_all_commands; for i in $__git_all_commands; do case $i in *--*) : helper pattern ;; applymbox) : ask gittus ;; applypatch) : ask gittus ;; archimport) : import ;; cat-file) : plumbing ;; check-attr) : plumbing ;; check-ignore) : plumbing ;; check-mailmap) : plumbing ;; check-ref-format) : plumbing ;; checkout-index) : plumbing ;; commit-tree) : plumbing ;; count-objects) : infrequent ;; credential-cache) : credentials helper ;; credential-store) : credentials helper ;; cvsexportcommit) : export ;; cvsimport) : import ;; cvsserver) : daemon ;; daemon) : daemon ;; diff-files) : plumbing ;; diff-index) : plumbing ;; diff-tree) : plumbing ;; fast-import) : import ;; fast-export) : export ;; fsck-objects) : plumbing ;; fetch-pack) : plumbing ;; fmt-merge-msg) : plumbing ;; for-each-ref) : plumbing ;; hash-object) : plumbing ;; http-*) : transport ;; index-pack) : plumbing ;; init-db) : deprecated ;; local-fetch) : plumbing ;; ls-files) : plumbing ;; ls-remote) : plumbing ;; ls-tree) : plumbing ;; mailinfo) : plumbing ;; mailsplit) : plumbing ;; merge-*) : plumbing ;; mktree) : plumbing ;; mktag) : plumbing ;; pack-objects) : plumbing ;; pack-redundant) : plumbing ;; pack-refs) : plumbing ;; parse-remote) : plumbing ;; patch-id) : plumbing ;; prune) : plumbing ;; prune-packed) : plumbing ;; quiltimport) : import ;; read-tree) : plumbing ;; receive-pack) : plumbing ;; remote-*) : transport ;; rerere) : plumbing ;; rev-list) : plumbing ;; rev-parse) : plumbing ;; runstatus) : plumbing ;; sh-setup) : internal ;; shell) : daemon ;; show-ref) : plumbing ;; send-pack) : plumbing ;; show-index) : plumbing ;; ssh-*) : transport ;; stripspace) : plumbing ;; symbolic-ref) : plumbing ;; unpack-file) : plumbing ;; unpack-objects) : plumbing ;; update-index) : plumbing ;; update-ref) : plumbing ;; update-server-info) : daemon ;; upload-archive) : plumbing ;; upload-pack) : plumbing ;; write-tree) : plumbing ;; var) : infrequent ;; verify-pack) : infrequent ;; verify-tag) : plumbing ;; *) echo $i ;; esac; done } __git_ls_files_helper () { ( test -n "${CDPATH+set}" && unset CDPATH; cd "$1"; if [ "$2" == "--committable" ]; then git diff-index --name-only --relative HEAD; else git ls-files --exclude-standard $2; fi ) 2> /dev/null } __git_main () { local i c=1 command __git_dir; while [ $c -lt $cword ]; do i="${words[c]}"; case "$i" in --git-dir=*) __git_dir="${i#--git-dir=}" ;; --git-dir) ((c++)); __git_dir="${words[c]}" ;; --bare) __git_dir="." ;; --help) command="help"; break ;; -c | --work-tree | --namespace) ((c++)) ;; -*) ;; *) command="$i"; break ;; esac; ((c++)); done; if [ -z "$command" ]; then case "$cur" in --*) __gitcomp " --paginate --no-pager --git-dir= --bare --version --exec-path --exec-path= --html-path --man-path --info-path --work-tree= --namespace= --no-replace-objects --help " ;; *) __git_compute_porcelain_commands; __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;; esac; return; fi; local completion_func="_git_${command//-/_}"; declare -f $completion_func > /dev/null && $completion_func && return; local expansion=$(__git_aliased_command "$command"); if [ -n "$expansion" ]; then words[1]=$expansion; completion_func="_git_${expansion//-/_}"; declare -f $completion_func > /dev/null && $completion_func; fi } __git_match_ctag () { awk "/^${1////\\/}/ { print \$1 }" "$2" } __git_pretty_aliases () { local i IFS=' '; for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do case "$i" in pretty.*) i="${i#pretty.}"; echo "${i/ */}" ;; esac; done } __git_reassemble_comp_words_by_ref () { local exclude i j first; exclude="${1//[^$COMP_WORDBREAKS]}"; cword_=$COMP_CWORD; if [ -z "$exclude" ]; then words_=("${COMP_WORDS[@]}"); return; fi; for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)) do first=t; while [ $i -gt 0 ] && [ -n "${COMP_WORDS[$i]}" ] && [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]; do if [ $j -ge 2 ] && [ -n "$first" ]; then ((j--)); fi; first=; words_[$j]=${words_[j]}${COMP_WORDS[i]}; if [ $i = $COMP_CWORD ]; then cword_=$j; fi; if (($i < ${#COMP_WORDS[@]} - 1)); then ((i++)); else return; fi; done; words_[$j]=${words_[j]}${COMP_WORDS[i]}; if [ $i = $COMP_CWORD ]; then cword_=$j; fi; done } __git_refs () { local i hash dir="$(__gitdir "${1-}")" track="${2-}"; local format refs; if [ -d "$dir" ]; then case "$cur" in refs | refs/*) format="refname"; refs="${cur%/*}"; track="" ;; *) for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do if [ -e "$dir/$i" ]; then echo $i; fi; done; format="refname:short"; refs="refs/tags refs/heads refs/remotes" ;; esac; git --git-dir="$dir" for-each-ref --format="%($format)" $refs; if [ -n "$track" ]; then local ref entry; git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" "refs/remotes/" | while read -r entry; do eval "$entry"; ref="${ref#*/}"; if [[ "$ref" == "$cur"* ]]; then echo "$ref"; fi; done | sort | uniq -u; fi; return; fi; case "$cur" in refs | refs/*) git ls-remote "$dir" "$cur*" 2> /dev/null | while read -r hash i; do case "$i" in *^{}) ;; *) echo "$i" ;; esac; done ;; *) echo "HEAD"; git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##" ;; esac } __git_refs2 () { local i; for i in $(__git_refs "$1"); do echo "$i:$i"; done } __git_refs_remotes () { local i hash; git ls-remote "$1" 'refs/heads/*' 2> /dev/null | while read -r hash i; do echo "$i:refs/remotes/$1/${i#refs/heads/}"; done } __git_remotes () { local i IFS=' ' d="$(__gitdir)"; test -d "$d/remotes" && ls -1 "$d/remotes"; for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do i="${i#remote.}"; echo "${i/.url*/}"; done } __git_tags () { local dir="$(__gitdir)"; if [ -d "$dir" ]; then git --git-dir="$dir" for-each-ref --format='%(refname:short)' refs/tags; return; fi } __git_wrap__git_main () { __git_func_wrap __git_main } __git_wrap__gitk_main () { __git_func_wrap __gitk_main } __gitcomp () { local cur_="${3-$cur}"; case "$cur_" in --*=) ;; *) local c i=0 IFS=' '; for c in $1; do c="$c${4-}"; if [[ $c == "$cur_"* ]]; then case $c in --*=* | *.) ;; *) c="$c " ;; esac; COMPREPLY[i++]="${2-}$c"; fi; done ;; esac } __gitcomp_file () { local IFS=' '; __gitcompadd "$1" "${2-}" "${3-$cur}" ""; compopt -o filenames +o nospace 2> /dev/null || compgen -f /non-existing-dir/ > /dev/null } __gitcomp_nl () { COMPREPLY=(); __gitcomp_nl_append "$@" } __gitcomp_nl_append () { local IFS=' '; __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }" } __gitcompadd () { COMPREPLY=(); __gitcompappend "$@" } __gitcompappend () { local i=${#COMPREPLY[@]}; for x in $1; do if [[ "$x" == "$3"* ]]; then COMPREPLY[i++]="$2$x$4"; fi; done } __gitdir () { if [ -z "${1-}" ]; then if [ -n "${__git_dir-}" ]; then echo "$__git_dir"; else if [ -n "${GIT_DIR-}" ]; then test -d "${GIT_DIR-}" || return 1; echo "$GIT_DIR"; else if [ -d .git ]; then echo .git; else git rev-parse --git-dir 2> /dev/null; fi; fi; fi; else if [ -d "$1/.git" ]; then echo "$1/.git"; else echo "$1"; fi; fi } __gitk_main () { __git_has_doubledash && return; local g="$(__gitdir)"; local merge=""; if [ -f "$g/MERGE_HEAD" ]; then merge="--merge"; fi; case "$cur" in --*) __gitcomp " $__git_log_common_options $__git_log_gitk_options $merge "; return ;; esac; __git_complete_revlist } __typex_isParentSupportedShell () { case "$(command basename -- "$(command ps -o comm= $PPID | command sed 's/^-//')")" in bash | ksh | zsh) return 0 ;; esac; return 1 } __typex_isSupportedShell () { [ -n "$BASH_VERSION" ] && return 0; [ -n "$KSH_VERSION" ] && return 0; [ -n "$ZSH_VERSION" ] && return 0; return 1 } _complete_edits () { local util utils; local token=${COMP_WORDS[$COMP_CWORD]}; local tokenLen=${#token}; if [[ $(uname) == 'Darwin' ]]; then IFS=' ' read -d '' -ra utils < <(find "$MK_UTIL_FOLDER" "$MK_UTIL_FOLDER/sourced.d" -type f -perm -a=x -exec basename -a {} +); else IFS=' ' read -d '' -ra utils < <(find "$MK_UTIL_FOLDER" "$MK_UTIL_FOLDER/sourced.d" -type f -perm -a=x -printf '%f\n'); fi; local nocasematchWasOff=0; shopt nocasematch > /dev/null || nocasematchWasOff=1; (( nocasematchWasOff )) && shopt -s nocasematch; COMPREPLY=(); for util in "${utils[@]}"; do if [[ ${util:0:$(( tokenLen ))} == "$token" ]]; then COMPREPLY+=("$(printf '%q' "$util")"); fi; done; (( nocasematchWasOff )) && shopt -u nocasematch } _complete_lx () { local localExeDir='.'; local token=${COMP_WORDS[$COMP_CWORD]}; local tokenLen=${#token}; if [[ $(uname) == 'Darwin' ]]; then IFS=' ' read -d '' -ra localExes < <(find "$localExeDir" -maxdepth 1 -type f -perm -a=x -exec basename -a {} +); else IFS=' ' read -d '' -ra localExes < <(find "$localExeDir" -maxdepth 1 -type f -executable -printf '%f\n'); fi; local nocasematchWasOff=0; shopt nocasematch > /dev/null || nocasematchWasOff=1; (( nocasematchWasOff )) && shopt -s nocasematch; COMPREPLY=(); for localExe in "${localExes[@]}"; do if [[ ${localExe:0:$(( tokenLen ))} == "$token" ]]; then COMPREPLY+=("$(printf '%q' "$localExe")"); fi; done; (( nocasematchWasOff )) && shopt -u nocasematch } _complete_make () { local token=${COMP_WORDS[$COMP_CWORD]}; local targets=$(make -pRrq : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($1 !~ "^[#.]") {print $1}}' | egrep -v '^[^[:alnum:]]' | sort | xargs); COMPREPLY=($(compgen -W "$targets" -- "$token")) } _complete_pf () { COMPREPLY=($(compgen -A function -- "${COMP_WORDS[$COMP_CWORD]}")) } _complete_pv () { local varNames=$(compgen -v); local token=${COMP_WORDS[$COMP_CWORD]}; local mustReset=$(shopt -q nocasematch; echo $?); shopt -s nocasematch; [[ "${token:0:1}" == '$' ]] && token=${token:1}; local matches w; matches=(); if [[ -n $token ]]; then for w in $varNames; do if [[ "$w" == "$token"* ]]; then matches+=("$w"); fi; done; else matches=($varNames); fi; (( mustReset )) && shopt -u nocasematch; COMPREPLY=("${matches[@]}") } _complete_unset () { local token=${COMP_WORDS[$COMP_CWORD]}; local funcAndVarNames=$(compgen -A function; compgen -A variable); local mustReset=$(shopt -q nocasematch; echo $?); shopt -s nocasematch; [[ "${token:0:1}" == '$' ]] && token=${token:1}; local matches w; matches=(); if [[ -n $token ]]; then for w in $funcAndVarNames; do if [[ "$w" == "$token"* ]]; then matches+=("$w"); fi; done; else matches=($funcAndVarNames); fi; (( mustReset )) && shopt -u nocasematch; COMPREPLY=("${matches[@]}") } _complete_up () { COMPREPLY=(); local curToken=${COMP_WORDS[COMP_CWORD]}; curToken=${curToken//'\'}; if [[ $curToken =~ ^/ ]]; then local IFS=' '; COMPREPLY=($(compgen -o dirnames -- "$curToken")); else if [[ $curToken =~ ^[0-9]+/? ]]; then local strpath=$( printf "%${curToken%%/*}s" ); local upDirSpec=${strpath// /../}; local dir=$(cd "$upDirSpec"; echo -n "$PWD/"); if [[ "$dir" == '//' ]]; then dir='/'; fi; COMPREPLY=("$dir"); else local caseInsensitive=0; bind -v | egrep -i '\bcompletion-ignore-case[[:space:]]+on\b' &> /dev/null && caseInsensitive=1; local nocasematchWasOff=0; if (( caseInsensitive )); then nocasematchWasOff=1; shopt nocasematch > /dev/null && nocasematchWasOff=0; (( nocasematchWasOff )) && shopt -s nocasematch > /dev/null; fi; local pathSoFar=''; local matchingPath=''; local parentPath=${PWD%/*}; local IFS='/'; local name; for name in ${parentPath:1}; do pathSoFar+=/$name; if [[ "$name" == "$curToken"* ]]; then matchingPath="$pathSoFar/"; fi; done; (( caseInsensitive && nocasematchWasOff )) && shopt -u nocasematch > /dev/null; [[ -n "$matchingPath" ]] && COMPREPLY=("$matchingPath"); fi; fi } _get_comp_words_by_ref () { local exclude cur_ words_ cword_; if [ "$1" = "-n" ]; then exclude=$2; shift 2; fi; __git_reassemble_comp_words_by_ref "$exclude"; cur_=${words_[cword_]}; while [ $# -gt 0 ]; do case "$1" in cur) cur=$cur_ ;; prev) prev=${words_[$cword_-1]} ;; words) words=("${words_[@]}") ;; cword) cword=$cword_ ;; esac; shift; done } _git () { __git_wrap__git_main } _git_add () { case "$cur" in --*) __gitcomp " --interactive --refresh --patch --update --dry-run --ignore-errors --intent-to-add "; return ;; esac; __git_complete_index_file "--others --modified --directory --no-empty-directory" } _git_am () { local dir="$(__gitdir)"; if [ -d "$dir"/rebase-apply ]; then __gitcomp "--skip --continue --resolved --abort"; return; fi; case "$cur" in --whitespace=*) __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"; return ;; --*) __gitcomp " --3way --committer-date-is-author-date --ignore-date --ignore-whitespace --ignore-space-change --interactive --keep --no-utf8 --signoff --utf8 --whitespace= --scissors "; return ;; esac } _git_apply () { case "$cur" in --whitespace=*) __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"; return ;; --*) __gitcomp " --stat --numstat --summary --check --index --cached --index-info --reverse --reject --unidiff-zero --apply --no-add --exclude= --ignore-whitespace --ignore-space-change --whitespace= --inaccurate-eof --verbose "; return ;; esac } _git_archive () { case "$cur" in --format=*) __gitcomp "$(git archive --list)" "" "${cur##--format=}"; return ;; --remote=*) __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"; return ;; --*) __gitcomp " --format= --list --verbose --prefix= --remote= --exec= "; return ;; esac; __git_complete_file } _git_bisect () { __git_has_doubledash && return; local subcommands="start bad good skip reset visualize replay log run"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then if [ -f "$(__gitdir)"/BISECT_START ]; then __gitcomp "$subcommands"; else __gitcomp "replay start"; fi; return; fi; case "$subcommand" in bad | good | reset | skip | start) __gitcomp_nl "$(__git_refs)" ;; *) ;; esac } _git_branch () { local i c=1 only_local_ref="n" has_r="n"; while [ $c -lt $cword ]; do i="${words[c]}"; case "$i" in -d | -m) only_local_ref="y" ;; -r) has_r="y" ;; esac; ((c++)); done; case "$cur" in --set-upstream-to=*) __gitcomp "$(__git_refs)" "" "${cur##--set-upstream-to=}" ;; --*) __gitcomp " --color --no-color --verbose --abbrev= --no-abbrev --track --no-track --contains --merged --no-merged --set-upstream-to= --edit-description --list --unset-upstream " ;; *) if [ $only_local_ref = "y" -a $has_r = "n" ]; then __gitcomp_nl "$(__git_heads)"; else __gitcomp_nl "$(__git_refs)"; fi ;; esac } _git_bundle () { local cmd="${words[2]}"; case "$cword" in 2) __gitcomp "create list-heads verify unbundle" ;; 3) ;; *) case "$cmd" in create) __git_complete_revlist ;; esac ;; esac } _git_checkout () { __git_has_doubledash && return; case "$cur" in --conflict=*) __gitcomp "diff3 merge" "" "${cur##--conflict=}" ;; --*) __gitcomp " --quiet --ours --theirs --track --no-track --merge --conflict= --orphan --patch " ;; *) local flags="--track --no-track --no-guess" track=1; if [ -n "$(__git_find_on_cmdline "$flags")" ]; then track=''; fi; __gitcomp_nl "$(__git_refs '' $track)" ;; esac } _git_cherry () { __gitcomp "$(__git_refs)" } _git_cherry_pick () { local dir="$(__gitdir)"; if [ -f "$dir"/CHERRY_PICK_HEAD ]; then __gitcomp "--continue --quit --abort"; return; fi; case "$cur" in --*) __gitcomp "--edit --no-commit --signoff --strategy= --mainline" ;; *) __gitcomp_nl "$(__git_refs)" ;; esac } _git_clean () { case "$cur" in --*) __gitcomp "--dry-run --quiet"; return ;; esac; __git_complete_index_file "--others --directory" } _git_clone () { case "$cur" in --*) __gitcomp " --local --no-hardlinks --shared --reference --quiet --no-checkout --bare --mirror --origin --upload-pack --template= --depth --single-branch --branch "; return ;; esac } _git_commit () { case "$prev" in -c | -C) __gitcomp_nl "$(__git_refs)" "" "${cur}"; return ;; esac; case "$cur" in --cleanup=*) __gitcomp "default strip verbatim whitespace " "" "${cur##--cleanup=}"; return ;; --reuse-message=* | --reedit-message=* | --fixup=* | --squash=*) __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"; return ;; --untracked-files=*) __gitcomp "all no normal" "" "${cur##--untracked-files=}"; return ;; --*) __gitcomp " --all --author= --signoff --verify --no-verify --edit --no-edit --amend --include --only --interactive --dry-run --reuse-message= --reedit-message= --reset-author --file= --message= --template= --cleanup= --untracked-files --untracked-files= --verbose --quiet --fixup= --squash= "; return ;; esac; if git rev-parse --verify --quiet HEAD > /dev/null; then __git_complete_index_file "--committable"; else __git_complete_index_file "--cached"; fi } _git_config () { case "$prev" in branch.*.remote | branch.*.pushremote) __gitcomp_nl "$(__git_remotes)"; return ;; branch.*.merge) __gitcomp_nl "$(__git_refs)"; return ;; branch.*.rebase) __gitcomp "false true"; return ;; remote.pushdefault) __gitcomp_nl "$(__git_remotes)"; return ;; remote.*.fetch) local remote="${prev#remote.}"; remote="${remote%.fetch}"; if [ -z "$cur" ]; then __gitcomp_nl "refs/heads/" "" "" ""; return; fi; __gitcomp_nl "$(__git_refs_remotes "$remote")"; return ;; remote.*.push) local remote="${prev#remote.}"; remote="${remote%.push}"; __gitcomp_nl "$(git --git-dir="$(__gitdir)" for-each-ref --format='%(refname):%(refname)' refs/heads)"; return ;; pull.twohead | pull.octopus) __git_compute_merge_strategies; __gitcomp "$__git_merge_strategies"; return ;; color.branch | color.diff | color.interactive | color.showbranch | color.status | color.ui) __gitcomp "always never auto"; return ;; color.pager) __gitcomp "false true"; return ;; color.*.*) __gitcomp " normal black red green yellow blue magenta cyan white bold dim ul blink reverse "; return ;; diff.submodule) __gitcomp "log short"; return ;; help.format) __gitcomp "man info web html"; return ;; log.date) __gitcomp "$__git_log_date_formats"; return ;; sendemail.aliasesfiletype) __gitcomp "mutt mailrc pine elm gnus"; return ;; sendemail.confirm) __gitcomp "$__git_send_email_confirm_options"; return ;; sendemail.suppresscc) __gitcomp "$__git_send_email_suppresscc_options"; return ;; --get | --get-all | --unset | --unset-all) __gitcomp_nl "$(__git_config_get_set_variables)"; return ;; *.*) return ;; esac; case "$cur" in --*) __gitcomp " --system --global --local --file= --list --replace-all --get --get-all --get-regexp --add --unset --unset-all --remove-section --rename-section "; return ;; branch.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_"; return ;; branch.*) local pfx="${cur%.*}." cur_="${cur#*.}"; __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."; __gitcomp_nl_append 'autosetupmerge autosetuprebase ' "$pfx" "$cur_"; return ;; guitool.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp " argprompt cmd confirm needsfile noconsole norescan prompt revprompt revunmerged title " "$pfx" "$cur_"; return ;; difftool.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "cmd path" "$pfx" "$cur_"; return ;; man.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "cmd path" "$pfx" "$cur_"; return ;; mergetool.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"; return ;; pager.*) local pfx="${cur%.*}." cur_="${cur#*.}"; __git_compute_all_commands; __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"; return ;; remote.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp " url proxy fetch push mirror skipDefaultUpdate receivepack uploadpack tagopt pushurl " "$pfx" "$cur_"; return ;; remote.*) local pfx="${cur%.*}." cur_="${cur#*.}"; __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."; __gitcomp_nl_append "pushdefault" "$pfx" "$cur_"; return ;; url.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"; return ;; esac; __gitcomp " add.ignoreErrors advice.commitBeforeMerge advice.detachedHead advice.implicitIdentity advice.pushNonFastForward advice.resolveConflict advice.statusHints alias. am.keepcr apply.ignorewhitespace apply.whitespace branch.autosetupmerge branch.autosetuprebase browser. clean.requireForce color.branch color.branch.current color.branch.local color.branch.plain color.branch.remote color.decorate.HEAD color.decorate.branch color.decorate.remoteBranch color.decorate.stash color.decorate.tag color.diff color.diff.commit color.diff.frag color.diff.func color.diff.meta color.diff.new color.diff.old color.diff.plain color.diff.whitespace color.grep color.grep.context color.grep.filename color.grep.function color.grep.linenumber color.grep.match color.grep.selected color.grep.separator color.interactive color.interactive.error color.interactive.header color.interactive.help color.interactive.prompt color.pager color.showbranch color.status color.status.added color.status.changed color.status.header color.status.nobranch color.status.untracked color.status.updated color.ui commit.status commit.template core.abbrev core.askpass core.attributesfile core.autocrlf core.bare core.bigFileThreshold core.compression core.createObject core.deltaBaseCacheLimit core.editor core.eol core.excludesfile core.fileMode core.fsyncobjectfiles core.gitProxy core.ignoreStat core.ignorecase core.logAllRefUpdates core.loosecompression core.notesRef core.packedGitLimit core.packedGitWindowSize core.pager core.preferSymlinkRefs core.preloadindex core.quotepath core.repositoryFormatVersion core.safecrlf core.sharedRepository core.sparseCheckout core.symlinks core.trustctime core.warnAmbiguousRefs core.whitespace core.worktree diff.autorefreshindex diff.external diff.ignoreSubmodules diff.mnemonicprefix diff.noprefix diff.renameLimit diff.renames diff.statGraphWidth diff.submodule diff.suppressBlankEmpty diff.tool diff.wordRegex diff.algorithm difftool. difftool.prompt fetch.recurseSubmodules fetch.unpackLimit format.attach format.cc format.coverLetter format.headers format.numbered format.pretty format.signature format.signoff format.subjectprefix format.suffix format.thread format.to gc. gc.aggressiveWindow gc.auto gc.autopacklimit gc.packrefs gc.pruneexpire gc.reflogexpire gc.reflogexpireunreachable gc.rerereresolved gc.rerereunresolved gitcvs.allbinary gitcvs.commitmsgannotation gitcvs.dbTableNamePrefix gitcvs.dbdriver gitcvs.dbname gitcvs.dbpass gitcvs.dbuser gitcvs.enabled gitcvs.logfile gitcvs.usecrlfattr guitool. gui.blamehistoryctx gui.commitmsgwidth gui.copyblamethreshold gui.diffcontext gui.encoding gui.fastcopyblame gui.matchtrackingbranch gui.newbranchtemplate gui.pruneduringfetch gui.spellingdictionary gui.trustmtime help.autocorrect help.browser help.format http.lowSpeedLimit http.lowSpeedTime http.maxRequests http.minSessions http.noEPSV http.postBuffer http.proxy http.sslCAInfo http.sslCAPath http.sslCert http.sslCertPasswordProtected http.sslKey http.sslVerify http.useragent i18n.commitEncoding i18n.logOutputEncoding imap.authMethod imap.folder imap.host imap.pass imap.port imap.preformattedHTML imap.sslverify imap.tunnel imap.user init.templatedir instaweb.browser instaweb.httpd instaweb.local instaweb.modulepath instaweb.port interactive.singlekey log.date log.decorate log.showroot mailmap.file man. man.viewer merge. merge.conflictstyle merge.log merge.renameLimit merge.renormalize merge.stat merge.tool merge.verbosity mergetool. mergetool.keepBackup mergetool.keepTemporaries mergetool.prompt notes.displayRef notes.rewrite. notes.rewrite.amend notes.rewrite.rebase notes.rewriteMode notes.rewriteRef pack.compression pack.deltaCacheLimit pack.deltaCacheSize pack.depth pack.indexVersion pack.packSizeLimit pack.threads pack.window pack.windowMemory pager. pretty. pull.octopus pull.twohead push.default rebase.autosquash rebase.stat receive.autogc receive.denyCurrentBranch receive.denyDeleteCurrent receive.denyDeletes receive.denyNonFastForwards receive.fsckObjects receive.unpackLimit receive.updateserverinfo remote.pushdefault remotes. repack.usedeltabaseoffset rerere.autoupdate rerere.enabled sendemail. sendemail.aliasesfile sendemail.aliasfiletype sendemail.bcc sendemail.cc sendemail.cccmd sendemail.chainreplyto sendemail.confirm sendemail.envelopesender sendemail.from sendemail.identity sendemail.multiedit sendemail.signedoffbycc sendemail.smtpdomain sendemail.smtpencryption sendemail.smtppass sendemail.smtpserver sendemail.smtpserveroption sendemail.smtpserverport sendemail.smtpuser sendemail.suppresscc sendemail.suppressfrom sendemail.thread sendemail.to sendemail.validate showbranch.default status.relativePaths status.showUntrackedFiles status.submodulesummary submodule. tar.umask transfer.unpackLimit url. user.email user.name user.signingkey web.browser branch. remote. " } _git_describe () { case "$cur" in --*) __gitcomp " --all --tags --contains --abbrev= --candidates= --exact-match --debug --long --match --always "; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_diff () { __git_has_doubledash && return; case "$cur" in --diff-algorithm=*) __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"; return ;; --*) __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex --base --ours --theirs --no-index $__git_diff_common_options "; return ;; esac; __git_complete_revlist_file } _git_difftool () { __git_has_doubledash && return; case "$cur" in --tool=*) __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"; return ;; --*) __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex --base --ours --theirs --no-renames --diff-filter= --find-copies-harder --relative --ignore-submodules --tool="; return ;; esac; __git_complete_revlist_file } _git_fetch () { case "$cur" in --recurse-submodules=*) __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"; return ;; --*) __gitcomp "$__git_fetch_options"; return ;; esac; __git_complete_remote_or_refspec } _git_flow () { local subcommands="init feature release hotfix support help version config finish delete publish rebase"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in init) __git_flow_init; return ;; feature) __git_flow_feature; return ;; release) __git_flow_release; return ;; hotfix) __git_flow_hotfix; return ;; support) __git_flow_support; return ;; config) __git_flow_config; return ;; *) COMPREPLY=() ;; esac } _git_format_patch () { case "$cur" in --thread=*) __gitcomp " deep shallow " "" "${cur##--thread=}"; return ;; --*) __gitcomp "$__git_format_patch_options"; return ;; esac; __git_complete_revlist } _git_fsck () { case "$cur" in --*) __gitcomp " --tags --root --unreachable --cache --no-reflogs --full --strict --verbose --lost-found "; return ;; esac } _git_gc () { case "$cur" in --*) __gitcomp "--prune --aggressive"; return ;; esac } _git_gitk () { _gitk } _git_grep () { __git_has_doubledash && return; case "$cur" in --*) __gitcomp " --cached --text --ignore-case --word-regexp --invert-match --full-name --line-number --extended-regexp --basic-regexp --fixed-strings --perl-regexp --files-with-matches --name-only --files-without-match --max-depth --count --and --or --not --all-match "; return ;; esac; case "$cword,$prev" in 2,* | *,-*) if test -r tags; then __gitcomp_nl "$(__git_match_ctag "$cur" tags)"; return; fi ;; esac; __gitcomp_nl "$(__git_refs)" } _git_help () { case "$cur" in --*) __gitcomp "--all --info --man --web"; return ;; esac; __git_compute_all_commands; __gitcomp "$__git_all_commands $(__git_aliases) attributes cli core-tutorial cvs-migration diffcore gitk glossary hooks ignore modules namespaces repository-layout tutorial tutorial-2 workflows " } _git_init () { case "$cur" in --shared=*) __gitcomp " false true umask group all world everybody " "" "${cur##--shared=}"; return ;; --*) __gitcomp "--quiet --bare --template= --shared --shared="; return ;; esac } _git_log () { __git_has_doubledash && return; local g="$(git rev-parse --git-dir 2>/dev/null)"; local merge=""; if [ -f "$g/MERGE_HEAD" ]; then merge="--merge"; fi; case "$cur" in --pretty=* | --format=*) __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) " "" "${cur#*=}"; return ;; --date=*) __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"; return ;; --decorate=*) __gitcomp "long short" "" "${cur##--decorate=}"; return ;; --*) __gitcomp " $__git_log_common_options $__git_log_shortlog_options $__git_log_gitk_options --root --topo-order --date-order --reverse --follow --full-diff --abbrev-commit --abbrev= --relative-date --date= --pretty= --format= --oneline --cherry-pick --graph --decorate --decorate= --walk-reflogs --parents --children $merge $__git_diff_common_options --pickaxe-all --pickaxe-regex "; return ;; esac; __git_complete_revlist } _git_ls_files () { case "$cur" in --*) __gitcomp "--cached --deleted --modified --others --ignored --stage --directory --no-empty-directory --unmerged --killed --exclude= --exclude-from= --exclude-per-directory= --exclude-standard --error-unmatch --with-tree= --full-name --abbrev --ignored --exclude-per-directory "; return ;; esac; __git_complete_index_file "--cached" } _git_ls_remote () { __gitcomp_nl "$(__git_remotes)" } _git_ls_tree () { __git_complete_file } _git_merge () { __git_complete_strategy && return; case "$cur" in --*) __gitcomp "$__git_merge_options --rerere-autoupdate --no-rerere-autoupdate --abort"; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_merge_base () { case "$cur" in --*) __gitcomp "--octopus --independent --is-ancestor --fork-point"; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_mergetool () { case "$cur" in --tool=*) __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"; return ;; --*) __gitcomp "--tool="; return ;; esac } _git_mv () { case "$cur" in --*) __gitcomp "--dry-run"; return ;; esac; if [ $(__git_count_arguments "mv") -gt 0 ]; then __git_complete_index_file "--cached --others --directory"; else __git_complete_index_file "--cached"; fi } _git_name_rev () { __gitcomp "--tags --all --stdin" } _git_notes () { local subcommands='add append copy edit list prune remove show'; local subcommand="$(__git_find_on_cmdline "$subcommands")"; case "$subcommand,$cur" in ,--*) __gitcomp '--ref' ;; ,*) case "$prev" in --ref) __gitcomp_nl "$(__git_refs)" ;; *) __gitcomp "$subcommands --ref" ;; esac ;; add,--reuse-message=* | append,--reuse-message=* | add,--reedit-message=* | append,--reedit-message=*) __gitcomp_nl "$(__git_refs)" "" "${cur#*=}" ;; add,--* | append,--*) __gitcomp '--file= --message= --reedit-message= --reuse-message=' ;; copy,--*) __gitcomp '--stdin' ;; prune,--*) __gitcomp '--dry-run --verbose' ;; prune,*) ;; *) case "$prev" in -m | -F) ;; *) __gitcomp_nl "$(__git_refs)" ;; esac ;; esac } _git_pull () { __git_complete_strategy && return; case "$cur" in --recurse-submodules=*) __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"; return ;; --*) __gitcomp " --rebase --no-rebase $__git_merge_options $__git_fetch_options "; return ;; esac; __git_complete_remote_or_refspec } _git_push () { case "$prev" in --repo) __gitcomp_nl "$(__git_remotes)"; return ;; --recurse-submodules) __gitcomp "$__git_push_recurse_submodules"; return ;; esac; case "$cur" in --repo=*) __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"; return ;; --recurse-submodules=*) __gitcomp "$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}"; return ;; --force-with-lease=*) __git_complete_force_with_lease "${cur##--force-with-lease=}"; return ;; --*) __gitcomp " --all --mirror --tags --dry-run --force --verbose --quiet --prune --delete --follow-tags --receive-pack= --repo= --set-upstream --force-with-lease --force-with-lease= --recurse-submodules= "; return ;; esac; __git_complete_remote_or_refspec } _git_rebase () { local dir="$(__gitdir)"; if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then __gitcomp "--continue --skip --abort"; return; fi; __git_complete_strategy && return; case "$cur" in --whitespace=*) __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"; return ;; --*) __gitcomp " --onto --merge --strategy --interactive --preserve-merges --stat --no-stat --committer-date-is-author-date --ignore-date --ignore-whitespace --whitespace= --autosquash --fork-point --no-fork-point "; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_reflog () { local subcommands="show delete expire"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; else __gitcomp_nl "$(__git_refs)"; fi } _git_remote () { local subcommands="add rename remove set-head set-branches set-url show prune update"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in rename | remove | set-url | show | prune) __gitcomp_nl "$(__git_remotes)" ;; set-head | set-branches) __git_complete_remote_or_refspec ;; update) local i c='' IFS=' '; for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do i="${i#remotes.}"; c="$c ${i/ */}"; done; __gitcomp "$c" ;; *) ;; esac } _git_replace () { __gitcomp_nl "$(__git_refs)" } _git_reset () { __git_has_doubledash && return; case "$cur" in --*) __gitcomp "--merge --mixed --hard --soft --patch"; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_revert () { case "$cur" in --*) __gitcomp "--edit --mainline --no-edit --no-commit --signoff"; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_rm () { case "$cur" in --*) __gitcomp "--cached --dry-run --ignore-unmatch --quiet"; return ;; esac; __git_complete_index_file "--cached" } _git_send_email () { case "$cur" in --confirm=*) __gitcomp " $__git_send_email_confirm_options " "" "${cur##--confirm=}"; return ;; --suppress-cc=*) __gitcomp " $__git_send_email_suppresscc_options " "" "${cur##--suppress-cc=}"; return ;; --smtp-encryption=*) __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"; return ;; --thread=*) __gitcomp " deep shallow " "" "${cur##--thread=}"; return ;; --*) __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to --compose --confirm= --dry-run --envelope-sender --from --identity --in-reply-to --no-chain-reply-to --no-signed-off-by-cc --no-suppress-from --no-thread --quiet --signed-off-by-cc --smtp-pass --smtp-server --smtp-server-port --smtp-encryption= --smtp-user --subject --suppress-cc= --suppress-from --thread --to --validate --no-validate $__git_format_patch_options"; return ;; esac; __git_complete_revlist } _git_shortlog () { __git_has_doubledash && return; case "$cur" in --*) __gitcomp " $__git_log_common_options $__git_log_shortlog_options --numbered --summary "; return ;; esac; __git_complete_revlist } _git_show () { __git_has_doubledash && return; case "$cur" in --pretty=* | --format=*) __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) " "" "${cur#*=}"; return ;; --diff-algorithm=*) __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"; return ;; --*) __gitcomp "--pretty= --format= --abbrev-commit --oneline $__git_diff_common_options "; return ;; esac; __git_complete_revlist_file } _git_show_branch () { case "$cur" in --*) __gitcomp " --all --remotes --topo-order --current --more= --list --independent --merge-base --no-name --color --no-color --sha1-name --sparse --topics --reflog "; return ;; esac; __git_complete_revlist } _git_stage () { _git_add } _git_stash () { local save_opts='--keep-index --no-keep-index --quiet --patch'; local subcommands='save list show apply clear drop pop create branch'; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then case "$cur" in --*) __gitcomp "$save_opts" ;; *) if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then __gitcomp "$subcommands"; fi ;; esac; else case "$subcommand,$cur" in save,--*) __gitcomp "$save_opts" ;; apply,--* | pop,--*) __gitcomp "--index --quiet" ;; show,--* | drop,--* | branch,--*) ;; show,* | apply,* | drop,* | pop,* | branch,*) __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list | sed -n -e 's/:.*//p')" ;; *) ;; esac; fi } _git_submodule () { __git_has_doubledash && return; local subcommands="add status init deinit update summary foreach sync"; if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then case "$cur" in --*) __gitcomp "--quiet --cached" ;; *) __gitcomp "$subcommands" ;; esac; return; fi } _git_svn () { local subcommands=" init fetch clone rebase dcommit log find-rev set-tree commit-diff info create-ignore propget proplist show-ignore show-externals branch tag blame migrate mkdirs reset gc "; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; else local remote_opts="--username= --config-dir= --no-auth-cache"; local fc_opts=" --follow-parent --authors-file= --repack= --no-metadata --use-svm-props --use-svnsync-props --log-window-size= --no-checkout --quiet --repack-flags --use-log-author --localtime --ignore-paths= --include-paths= $remote_opts "; local init_opts=" --template= --shared= --trunk= --tags= --branches= --stdlayout --minimize-url --no-metadata --use-svm-props --use-svnsync-props --rewrite-root= --prefix= --use-log-author --add-author-from $remote_opts "; local cmt_opts=" --edit --rmdir --find-copies-harder --copy-similarity= "; case "$subcommand,$cur" in fetch,--*) __gitcomp "--revision= --fetch-all $fc_opts" ;; clone,--*) __gitcomp "--revision= $fc_opts $init_opts" ;; init,--*) __gitcomp "$init_opts" ;; dcommit,--*) __gitcomp " --merge --strategy= --verbose --dry-run --fetch-all --no-rebase --commit-url --revision --interactive $cmt_opts $fc_opts " ;; set-tree,--*) __gitcomp "--stdin $cmt_opts $fc_opts" ;; create-ignore,--* | propget,--* | proplist,--* | show-ignore,--* | show-externals,--* | mkdirs,--*) __gitcomp "--revision=" ;; log,--*) __gitcomp " --limit= --revision= --verbose --incremental --oneline --show-commit --non-recursive --authors-file= --color " ;; rebase,--*) __gitcomp " --merge --verbose --strategy= --local --fetch-all --dry-run $fc_opts " ;; commit-diff,--*) __gitcomp "--message= --file= --revision= $cmt_opts" ;; info,--*) __gitcomp "--url" ;; branch,--*) __gitcomp "--dry-run --message --tag" ;; tag,--*) __gitcomp "--dry-run --message" ;; blame,--*) __gitcomp "--git-format" ;; migrate,--*) __gitcomp " --config-dir= --ignore-paths= --minimize --no-auth-cache --username= " ;; reset,--*) __gitcomp "--revision= --parent" ;; *) ;; esac; fi } _git_tag () { local i c=1 f=0; while [ $c -lt $cword ]; do i="${words[c]}"; case "$i" in -d | -v) __gitcomp_nl "$(__git_tags)"; return ;; -f) f=1 ;; esac; ((c++)); done; case "$prev" in -m | -F) ;; -* | tag) if [ $f = 1 ]; then __gitcomp_nl "$(__git_tags)"; fi ;; *) __gitcomp_nl "$(__git_refs)" ;; esac } _git_whatchanged () { _git_log } _gitk () { __git_wrap__gitk_main } _npm_completion () { local si="$IFS"; IFS=' ' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" COMP_LINE="$COMP_LINE" COMP_POINT="$COMP_POINT" npm completion -- "${COMP_WORDS[@]}" 2>/dev/null)) || return $?; IFS="$si" } _tobase () { local _outputBaseSpecChar=${outputBaseSpecChar:-d}; local n; for n in "$@"; do printf "%#${_outputBaseSpecChar}\n" $(( n )); done } af () { f "$@" } brm () { [[ $1 == '-h' || $1 == '--help' ]] && { echo 'Prints the contents of ${BASH_REMATCH[@]} in diagnostic form.'; return 0 }; (( $# )) && { echo 'ERROR: Unexpected parameter(s) specified. Use -h for help.' 1>&2; return 2 }; local i m; for m in "${BASH_REMATCH[@]}"; do echo "[$((i++))] = [$m]"; done } calc () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "usage: $FUNCNAME expression\n Evaluates the specified arithmetic expression using (( )) and prints the result.\n Useful for simple calculations and converting hex or oct numbers to decimals." && return 0; echo $(( $@ )) } cdp () { local CDPATH=~:~/Documents/Projects:~/Documents/Projects/OSS:~/Documents/Projects/AlfredWorkflows; builtin cd "$@" } de () { local a i=0; for a in "$@"; do printf '%s\n' "\$$((i+=1))=[$a]"; done } dfs () { df -hl | grep 'disk0s2' | awk '{print $4"/"$2" free ("$5" used)"}' } difs () { echo -n "$IFS" | od -a } doIt () { echo "$$: [$*]" } docker-start () { typeset vm=${1:-default} sts; case $vm in -h | --help) echo 'usage: docker-start [] Ensures that the specified/default Docker VM is started and the environment is initialized.'; return 0 ;; esac; sts=$(docker-machine status "$vm") || return; [[ $sts == 'Running' ]] && echo "(Docker VM '$vm' is already running.)" || { echo "-- Starting Docker VM '$vm' (\`docker-machine start "$vm"\`; this will take a while)..."; docker-machine start "$vm" || return }; echo "-- Setting DOCKER_* environment variables (\`eval \"\$(docker-machine env "$vm")\"\`)..."; eval "$(docker-machine env "$vm")" || return; export | grep -o 'DOCKER_.*'; echo "-- Docker VM '$vm' is running." } docker-stop () { typeset vm=${1:-default} sts envVarNames fndx; case $vm in -h | --help) echo 'usage: docker-stop [] Ensures that the specified/default Docker VM is stopped and the environment is cleaned up.'; return 0 ;; esac; sts=$(docker-machine status "$vm") || return; [[ $sts == 'Running' ]] && { echo "-- Stopping Docker VM '$vm' (\`docker-machine stop "$vm"\`)..."; docker-machine stop "$vm" || return } || echo "(Docker VM '$vm' is not running.)"; [[ -n $BASH_VERSION ]] && fndx=3 || fndx=1; envVarNames=($(export | awk -v fndx="$fndx" '$fndx ~ /^DOCKER_/ { sub(/=.*/,"", $fndx); print $fndx }')); if [[ -n $envVarNames ]]; then echo "-- Unsetting DOCKER_* environment variables ($(echo "${envVarNames[@]}" | sed 's/ /, /g'))..."; unset "${envVarNames[@]}"; else echo "(No DOCKER_* environment variables to unset.)"; fi; echo "-- Docker VM '$vm' is stopped." } dsh () { function die () { echo "${FUNCNAME[1]}(): ERROR: ${1:-"ABORTING due to unexpected error."}" 1>&2; return ${2:-1} }; function dieSyntax () { echo "${FUNCNAME[1]}(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h or --h for help." 1>&2; return 2 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; return $ecode } env_parallel () { local _grep_REGEXP="$( perl -e ' for(@ARGV){ /^_$/ and $next_is_env = 0; $next_is_env and push @envvar, split/,/, $_; $next_is_env = /^--env$/; } $vars = join "|",map { quotemeta $_ } @envvar; print $vars ? "($vars)" : "(.*)"; ' -- "$@" )"; local _ignore_UNDERSCORE="$( perl -e ' for(@ARGV){ $next_is_env and push @envvar, split/,/, $_; $next_is_env=/^--env$/; } if(grep { /^_$/ } @envvar) { if(not open(IN, "<", "$ENV{HOME}/.parallel/ignored_vars")) { print STDERR "parallel: Error: ", "Run \"parallel --record-env\" in a clean environment first.\n"; } else { chomp(@ignored_vars = ); $vars = join "|",map { quotemeta $_ } "env_parallel", @ignored_vars; print $vars ? "($vars)" : "(,,nO,,VaRs,,)"; } } ' -- "$@" )"; if ! perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then ( compgen -a; compgen -A function; compgen -A variable ) | cat > $HOME/.parallel/ignored_vars; return 0; fi; local _alias_NAMES="$(compgen -a | grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ )"; local _list_alias_BODIES="alias $_alias_NAMES"; if [[ "$_alias_NAMES" = "" ]]; then _list_alias_BODIES="true"; fi; unset _alias_NAMES; local _function_NAMES="$(compgen -A function | grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ )"; local _list_function_BODIES="typeset -f $_function_NAMES"; if [[ "$_function_NAMES" = "" ]]; then _list_function_BODIES="true"; fi; unset _function_NAMES; local _variable_NAMES="$(compgen -A variable | grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ | grep -vFf <(readonly) | grep -Ev '^(BASHOPTS|BASHPID|EUID|GROUPS|FUNCNAME|DIRSTACK|_|PIPESTATUS|PPID|SHELLOPTS|UID|USERNAME|BASH_[A-Z_]+)$')"; local _list_variable_VALUES="typeset -p $_variable_NAMES"; if [[ "$_variable_NAMES" = "" ]]; then _list_variable_VALUES="true"; fi; unset _variable_NAMES; export PARALLEL_ENV="$( shopt 2>/dev/null | perl -pe 's:\s+off:;: and s/^/shopt -u /; s:\s+on:;: and s/^/shopt -s /; s:;$:&>/dev/null;:'; echo 'shopt -s expand_aliases &>/dev/null'; $_list_alias_BODIES; $_list_variable_VALUES; $_list_function_BODIES)"; unset _list_alias_BODIES; unset _list_variable_VALUES; unset _list_function_BODIES; `which parallel` "$@"; _parallel_exit_CODE=$?; unset PARALLEL_ENV; return $_parallel_exit_CODE } f () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <] Description: Opens the specified folder in Finder, or, if invoked as "af", in Alfred 2's file browser. By default, the current folder is targeted. You can also specify a file, in which case its containing folder is opened. can also be the name of a quick-cd function defined in the current shell. Quick-cd functions by conventions start with 'f', and, for convenience, you may specify the function name without the initial 'f'. Examples: $FUNCNAME /Library $FUNCNAME fh # 'fh' is quick-cd function for home folder; 'h' would work, too. EOF return 0; fi (( ${#@} >= 2 )) && echo -e "$FUNCNAME: PARAMETER ERROR: Unexpected parameter(s) specified. Use -h or --h to get help." 1>&2 && return 3; local haveFolder=$(( ${#1} ? 1 : 0 )); if (( haveFolder )); then if [[ -f "$1" ]]; then pushd "$(dirname "$1")" > /dev/null || return 2; else if [[ -d "$1" ]]; then pushd "$1" > /dev/null || return 2; else if [[ ${1/\/} != $1 ]]; then echo "ERROR: '$1', assumed to be a folder path, does not exist." 1>&2; return 1; else quickCdFunc="$1"; if [[ ! "$quickCdFunc" =~ ^[fF] ]]; then quickCdFunc="f$quickCdFunc"; fi; declare -f "$quickCdFunc" > /dev/null || { echo "ERROR: '$1' is neither an existing file or folder nor the name of a quick-cd function." 1>&2; return 1 }; $quickCdFunc > /dev/null || return 2; fi; fi; fi; fi; if [[ ${FUNCNAME[1]} == 'af' ]]; then osascript -e 'tell application "Alfred 2" to search "'"$PWD"'"'; else echo Opening Finder to \"$PWD\"...; open .; fi; if (( haveFolder )); then popd > /dev/null; fi } fa () { pushdX /Applications "$@" } fag () { pushdX "$HOME/Projects/CreativeSmarts/AppGyver" "$@" } fas () { pushdX /Library/Application\ Support "$@" } fasu () { pushdX ~/Library/Application\ Support "$@" } fau () { pushdX ~/Applications "$@" } fawf () { pushdX "$HOME/Dropbox/Alfred.alfredpreferences/workflows" "$@" } fawfc () { pushdX "$HOME/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data" "$@" } fawfd () { pushdX "$HOME/Library/Application Support/Alfred 2/Workflow Data" "$@" } fawfp () { pushdX "$HOME/Projects/AlfredWorkflows" "$@" } fcfg () { pushdX ~/Documents/Config "$@" } fcu () { pushdX ~/Library/Caches "$@" } fd () { pushdX ~/Documents "$@" } fdb () { pushdX ~/Dropbox "$@" } fdbp () { pushdX ~/Dropbox/Public "$@" } fdl () { pushdX ~/Downloads "$@" } fdla () { pushdX ~/Documents/DownloadArchive "$@" } fdt () { pushdX ~/Desktop "$@" } feb () { pushdX ~/Documents/eBooks "$@" } febi () { pushdX ~/Documents/eBooks/IT "$@" } febo () { pushdX ~/Calibre\ Library/ "$@" } ff () { local isFunc=1; [[ -z "$FUNCNAME" ]] && isFunc=0; local thisName=$FUNCNAME; (( isFunc )) || thisName=$(basename "$BASH_SOURCE"); if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2 && { (( isFunc )) && return 3 || exit 3 }; find . -iname "*$@*" } fh () { pushdX ~ "$@" } fhomer () { pushdX "/Volumes/jdoe" "$@" } fic () { pushdX "$HOME/Documents/Config/Icons" "$@" } fif () { local isFunc=1; [[ -z "$FUNCNAME" ]] && isFunc=0; local thisName=$FUNCNAME; (( isFunc )) || thisName=$(basename "$BASH_SOURCE"); if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2 && { (( isFunc )) && return 3 || exit 3 }; egrep -lr "$@" . } findexes () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "Synopsis:\n $FUNCNAME [dir]\n\nDescription:\n Finds all executable files in the specified subtree. Uses \`find\` with the \`-type\` and \`-perm\` primaries." && return 0; find "${1:-.}" -type f -perm "-u=x" } findq () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "Synopsis:\n $FUNCNAME {params for \`find\`}\n\nDescription:\n Same as \`find\` with the (implied) \`print\` primary (for listing matching paths),\n except that paths whose names contain reserved chars. are quoted (escaped);\n\n e.g.: 'a name with spaces' -> 'a\ name \ with\ spaces'\n\n Therefore it's safe to pass the output of this function to \`xargs\`.\n e.g.: \`$FUNCNAME . | xargs file\` lists the file type of every file in the current folder's subtree.\n\n CAVEAT: Do not specify a \`find\` primary - \`print\` is implied.\n" && return 0; find "$@" -print0 | while IFS='' read -r -d '' f; do printf '%q\n' "$f"; done } fkkac () { pushdX "$HOME/Projects/CreativeSmarts/AppGyver/Kakooma" "$@" } fkkai () { pushdX "$HOME/Projects/CreativeSmarts/Kakooma iOS Apps/src" "$@" } fl () { pushdX /Library "$@" } fla () { pushdX /Library/LaunchAgents "$@" } flau () { pushdX ~/Library/LaunchAgents "$@" } flsys () { pushdX /System/Library "$@" } flu () { pushdX ~/Library "$@" } fngb () { pushdX "$(npm bin -g)" "$@" } fngm () { pushdX "$(npm prefix -g)"/lib/node_modules "$@" } fobt () { pushdX "/Volumes/C/Users/jdoe/Documents/Projects/ta/onboarding-termination" "$@" } foldIndent () { local width=${1:-80} indent=${2- }; (( width-=${#indent} )); while IFS= read -r line; do fold -s -w $width <<< "$line" | awk 'NR>1 { print "'"$indent"'" $0; next } 1'; done } foss () { pushdX "$HOME/Projects/OSS" "$@" } fpg () { pushdX "$HOME/Desktop/pg" "$@" } fpgw () { pushdX "/Volumes/C/Users/jdoe/Desktop/pg" "$@" } fph () { pushdX ~/Pictures/ "$@" } fppg () { pushdX ~/Projects/pg "$@" } fpr () { pushdX ~/Projects "$@" } fpref () { pushdX /Library/Preferences "$@" } fprefu () { pushdX ~/Library/Preferences "$@" } fql () { pushdX /Library/QuickLook "$@" } fqlu () { pushdX ~/Library/QuickLook "$@" } fs () { pushdX /Library/Services "$@" } fsba () { pushdX ~/Library/Containers "$@" } fsd () { pushdX "/Volumes/data" "$@" } fsl () { pushdX /Library/'Script Libraries' "$@" } fslu () { pushdX ~/Library/'Script Libraries' "$@" } fsn () { pushdX "/Volumes/C/Users/jdoe/Documents/Projects/ta/sponsored-renewal/PsScripts" "$@" } fsph () { pushdX "/Volumes/media/Photos" "$@" } fss () { pushdX ~/Library/'Saved Searches' "$@" } fstp () { d=$([[ $(uname) == 'Darwin' ]] && printf "$HOME/Library/Application Support/Sublime Text 3/Packages" || printf "$HOME/.config/sublime-text-2/Packages"); pushdX "$d" "$@" } fstpu () { d=$([[ $(uname) == 'Darwin' ]] && printf "$HOME/Library/Application Support/Sublime Text 3/Packages/User" || printf "$HOME/.config/sublime-text-2/Packages/User"); pushdX "$d" "$@" } fsu () { pushdX ~/Library/Services "$@" } fsv () { pushdX "/Volumes/media/Videos" "$@" } fsvms () { pushdX '/Volumes/data/VMs/VMware Fusion/Virtual Machines' "$@" } ft () { pushdX '/tmp' "$@" } ftr () { pushdX "/Volumes/data/Transfer" "$@" } ftu () { pushdX "$TMPDIR" "$@" } fu () { pushdX "$MK_UTIL_FOLDER" "$@" } fub () { pushdX ~/bin "$@" } fuc () { pushdX "$MK_UTIL_FOLDER/sourced.d/bash_completion.d" "$@" } fulb () { pushdX '/usr/local/bin' "$@" } fullpath () { [[ "$1" == '--help' || "$1" == '-h' ]] && { echo -e "usage: $FUNCNAME [-ep] [path]\n Prints the absolute version of the specified path; defaults to \$PWD.\n The path is normalized, i.e, '.' and '..' components are resolved, if present.\n If only a filename is given and the file doesn't exist in the current folder, -p will search for it in the \$PATH, too.\n -e reports an error if the resulting path doesn't exist."; return 0 }; local params=() decompressed=0 argsReached=0 p=''; for p in "$@"; do if [[ $argsReached -eq 0 && $p == -[a-z,A-Z,0-9]?* ]]; then decompressed=1; params+=(${p:0:2}); for ((i = 2; i < ${#p}; i++ )) do params+=("-${p:$i:1}"); done; else [[ $p == '--' ]] && argsReached=1; params+=("$p"); fi; done; if (( decompressed )); then set -- "${params[@]}"; fi; unset params decompressed argsReached p; local fp searchInPath mustExist; while (( $# )); do case "$1" in -p) searchInPath=1 ;; -e) mustExist=1 ;; --) shift; break ;; -*) echo "PARAMETER ERROR: Unrecognized option: '$1'. To force interpretation as non-option, precede with '--'." 1>&2; return 2 ;; *) break ;; esac; shift; done; [[ -z $2 ]] || { echo "PARAMETER ERROR: Too many parameters specified. Use -h for help." 1>&2; return 2 }; if [[ -z $1 ]]; then fp=$PWD; else if [[ "${1:0:1}" == '/' ]]; then fp=$1; else fp="$PWD/$1"; if [[ -n $searchInPath && ! -e "$fp" && "${1/\//}" == "$1" ]]; then fp=$(which "$1" 2>/dev/null) || fp="$1"; fi; fi; fi; if [[ $fp =~ (/|^)(\.\.?)(/|$) && ( -e "$fp" || -d "$(dirname "$fp")" ) ]]; then local fld; [[ -d "$fp" ]] && fld=$fp || fld=$(dirname "$fp"); local fldResolved=$(cd "$fld"; pwd); [[ -d "$fp" ]] && fp=$fldResolved || fp=$fldResolved/$(basename "$fp"); fi; [[ -n $mustExist && ! -e "$fp" ]] && { echo "ERROR: Path '$fp' does not exist." 1>&2; return 1 }; echo "$fp" } fus () { pushdX "$MK_UTIL_FOLDER/sourced.d" "$@" } fuw () { pushdX "$MK_UTIL_FOLDER.Win" "$@" } fvms () { dirs=(~/'Documents/Virtual Machines.localized' ~/'Documents/Virtual Machines'); for dir in "${dirs[@]}"; do [[ -d "$dir" ]] && { pushdX "$dir" "$@"; return }; done } fwac () { pushdX "/Volumes/C/Users/jdoe/Documents/Projects/ta/workday-ad-consistency" "$@" } getip () { [[ "$1" == '--help' || "$1" == '-h' ]] && { echo -e "usage: $FUNCNAME\n Prints the IPv4 address of the first *bound* Ethernet interface (e.g., en0); cf. getips()."; return 0 }; if [[ $(uname) == 'Darwin' ]]; then for ifName in $(ifconfig -l | egrep -o "\ben[0-9]+"); do local protName='inet'; local addrFragment=$(ifconfig "$ifName" | egrep -o "\b$protName \S+"); if [[ -n $addrFragment ]]; then echo "$addrFragment" | egrep -o '[0-9].*'; return 0; fi; done; return 1; else local addr; addr=$(ip route get 10.0.0.1 | awk '{print $NF; exit}'); [[ -n $addr ]] || return 1; echo "$addr"; fi } getips () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "usage: $FUNCNAME [-b] [interface-type]\n Prints all this machine's IPv4 addresses of the specified interface *type* (Ethernet by default); cf. getip()\n Use \`ifconfig\` directly to get a specific interface's address.\n -b prints addresses only (suppresses the interface-name prefix) and skips interfaces without address." && return 0; local bare=0; [[ $1 == -b ]] && { bare=1; shift }; local ifType=${1:-en}; for ifName in $(ifconfig -l | egrep -o "\b${ifType}\d+"); do local protName='inet'; local addrFragment=$(ifconfig "$ifName" | egrep -o "\b$protName \S+"); local addr=${addrFragment#$protName }; if (( bare )); then [[ -n $addr ]] && echo "$addr"; else echo "$ifName: $addr"; fi; done; return 0 } installnode () { local THIS_NAME=$FUNCNAME; function _installnode_die () { echo "$THIS_NAME(): ERROR: ${1:-"ABORTING due to unexpected error."}" 1>&2; return ${2:-1} }; function _installnode_dieSyntax () { echo "$THIS_NAME(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h for help." 1>&2; return 2 }; function _installnode_indexOf () { local e ndx=-1; for e in "${@:2}"; do (( ++ndx )); [[ "$e" == "$1" ]] && echo $ndx && return 0; done; echo '-1'; return 1 }; function _installnode_isIn () { _installnode_indexOf "$@" > /dev/null }; function _installnode_pruneToMajorMinor () { printf '%s' | cut -d '.' -f 1-2 <<< "$1" }; function _installnode_resolveInstalledVersion () { local verSpec=$1 verInstalled; [[ ${verSpec:0:1} == 'v' ]] && verSpec=${verSpec:1}; read -r verInstalled <<< "$(nvm ls "$verSpec" | tail -1)"; [[ $verInstalled =~ \ *(v[[:digit:]]+[.[:digit:]]+) ]] && verInstalled=${BASH_REMATCH[1]} || verInstalled=''; printf '%s' "$verInstalled" }; function _installnode_resolveRemoteVersion () { local verSpec=$1; nvm ls-remote "$verSpec" | tail -1 | egrep -o 'v[[:digit:]]+[.[:digit:]]+' }; function _installnode_getLatestUnstableVersion () { _installnode_resolveRemoteVersion }; function _installnode_getLatestProductionVersion () { local latestOverall major minor; latestOverall=$(nvm ls-remote | tail -1 | egrep -o 'v[[:digit:]]+[.[:digit:]]+'); major=$(cut -d '.' -f 1 <<<"$latestOverall"); minor=$(cut -d '.' -f 2 <<<"$latestOverall"); minor=$(( minor - minor % 2 )); _installnode_resolveRemoteVersion "${major}.${minor}" }; function _installnode_isInstalled () { local verSpec=$1; [[ ${verSpec:0:1} == 'v' ]] || verSpec="v${verSpec}"; nvm ls | egrep -v '(:|->)' | egrep "$verSpec" > /dev/null; return $? }; function _installnode_getDefaultVerSpec () { nvm alias default | cut -d ' ' -f 3 }; function _installnode_getDefaultVer () { nvm alias default | awk -F '->' '{print $3}' | tr -d ' )' }; function _installnode_vercomp () { [[ $1 == $2 ]] && return 0; local i v1=$1 v2=$2; [[ ${v1:0:1} == 'v' ]] && v1=${v1:1}; [[ ${v2:0:1} == 'v' ]] && v2=${v2:1}; local IFS='.'; local i vna1=($v1) vna2=($v2); for ((i=${#vna1[@]}; i<${#vna2[@]}; i++)) do vna1[i]=0; done; for ((i=0; i<${#vna1[@]}; i++)) do [[ -z ${vna2[i]} ]] && vna2[i]=0; (( 10#${vna1[i]} > 10#${vna2[i]} )) && return 1; (( 10#${vna1[i]} < 10#${vna2[i]} )) && return 2; done; return 0 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat < /dev/null; then argsReached=1; fi; fi; params+=("$p"); fi; done; (( decompressed )) && set -- "${params[@]}"; unset params decompressed argsReached p; local showStatus=0 installFresh=0 upgrade=0 installAndCopy=0; local useUnstableVersion=0 skipPrompt=0 force=0; while (( $# )); do case "$1" in status) showStatus=1 ;; fresh) installFresh=1 ;; copy) installAndCopy=1 ;; upgrade) upgrade=1 ;; --) shift; break ;; -d | --unstable) useUnstableVersion=1 ;; -y | --yes) skipPrompt=1 ;; -f | --force) force=1 ;; -?) return $(_installnode_dieSyntax "Unrecognized option: '$1'. To force interpretation as non-option, precede with '--'.") ;; *) break ;; esac; shift; done; local newVerSpec oldVerSpec majorMinorSpec haveNewVerSpec haveOldVerSpec downgrading defaultVerHint defaultVerSpec suggestedNewDefaultVerSpec qualifier otherOptCount descr; newVerSpec=$1; shift; oldVerSpec=$1; shift; [[ -z $1 ]] || return $(_installnode_dieSyntax "Too many parameters specified."); local cmdCount=$(( showStatus + installFresh + installAndCopy + upgrade )); (( cmdCount <= 1 )) || return $(_installnode_dieSyntax "Only 1 command may be specified."); (( cmdCount == 1 )) || showStatus=1; if [[ -n $oldVerSpec ]]; then (( upgrade || installAndCopy )) || return $(_installnode_dieSyntax "An old version number can only be specified with the 'upgrade' and 'copy' commands."); fi; if [[ -n $newVerSpec ]]; then (( ! useUnstableVersion )) || return $(_installnode_dieSyntax "-d implies the latest unstable version, do not also supply an explicit version spec."); fi; haveNewVerSpec=0; if [[ -n $newVerSpec ]]; then haveNewVerSpec=1; [[ ${newVerSpec:0:1} == 'v' ]] || newVerSpec=v${newVerSpec}; fi; haveOldVerSpec=0; if [[ -n $oldVerSpec ]]; then haveOldVerSpec=1; [[ ${oldVerSpec:0:1} == 'v' ]] || oldVerSpec=v${oldVerSpec}; fi; [[ "$(type -t nvm)" != 'function' && -s ~/.nvm/nvm.sh ]] && . ~/.nvm/nvm.sh; [[ "$(type -t nvm)" == 'function' ]] || return $(_installnode_die "nvm (node.js version manager) not found."); if (( haveNewVerSpec )); then resolvedNewVersion=$(_installnode_resolveRemoteVersion "$newVerSpec") || return $(_installnode_die "No available version matching '$newVerSpec' found."); else if (( useUnstableVersion )); then resolvedNewVersion=$(_installnode_getLatestUnstableVersion); else resolvedNewVersion=$(_installnode_getLatestProductionVersion); fi; [[ -n $resolvedNewVersion ]] || return $(_installnode_die "Failed to determine latest available version."); fi; resolvedOldVersion=''; if (( haveOldVerSpec )); then resolvedOldVersion=$(_installnode_resolveInstalledVersion "$oldVerSpec"); [[ -n $resolvedOldVersion ]] || return $(_installnode_die "Old version spec. does not match any installed versions: '$oldVerSpec'"); else if (( haveNewVerSpec )); then majorMinorSpec=$(_installnode_pruneToMajorMinor "$newVerSpec"); else majorMinorSpec=$(_installnode_pruneToMajorMinor "$resolvedNewVersion"); fi; resolvedOldVersion=$(_installnode_resolveInstalledVersion "$majorMinorSpec"); fi; if (( showStatus )); then otherOptCount=$(( skipPrompt + force )); (( otherOptCount == 0 )) || return $(_installnode_dieSyntax "The 'status' command cannot be combined with these options."); descr=''; if (( haveNewVerSpec )); then descr="'$newVerSpec' version"; else if (( useUnstableVersion )); then descr="UNSTABLE version"; else descr="PRODUCTION version"; fi; fi; cat <&2 ;; esac; else if _installnode_isInstalled $resolvedNewVersion; then (( force )) || return $(_installnode_die "Version $resolvedNewVersion is already installed. To force reinstallation, use --force."); echo "WARNING: As requested, REINSTALLING $resolvedNewVersion." 1>&2; fi; fi; if (( installFresh )); then echo "Will INSTALL FRESH: $resolvedNewVersion"; else if (( installAndCopy )); then echo "Will INSTALL: $resolvedNewVersion"; echo "And COPY GLOBAL PACKAGES FROM: $resolvedOldVersion"; else if (( upgrade )); then echo "Will INSTALL: $resolvedNewVersion"; echo "And UPGRADE FROM (copy global packages, then DELETE): $resolvedOldVersion"; fi; fi; fi; while (( ! skipPrompt )); do read -p "CONTINUE? (y/N) " promptInput; [[ $promptInput =~ ^[yY]$ ]] && break; ( [[ $promptInput =~ ^[nN]$ || -z $promptInput ]] ) && { echo "Aborted." 1>&2; return 1 }; echo "Invalid input; please try again (^C to abort)." 1>&2; done; if (( force )) && _installnode_isInstalled "$resolvedNewVersion"; then echo "-- UNinstalling $resolvedOldVersion..."; nvm deactivate > /dev/null; nvm uninstall "$resolvedNewVersion" || return $(_installnode_die); fi; echo "-- INSTALLING $resolvedNewVersion..."; nvm install "$resolvedNewVersion" || return $(_installnode_die); if (( installAndCopy || upgrade )); then echo "-- COPYING global packages from $resolvedOldVersion..."; echo " Note: This CAN TAKE A WHILE, as packages are being rebuilt."; npm_config_loglevel='error' nvm copy-packages "$resolvedOldVersion" > /dev/null || return $(_installnode_die); fi; if (( upgrade )); then echo "-- DELETING old version $resolvedOldVersion..."; nvm uninstall "$resolvedOldVersion" || return $(_installnode_die); fi; if [[ "$resolvedNewVersion" != "$(_installnode_getDefaultVer)" ]]; then suggestedNewDefaultVerSpec=$(_installnode_pruneToMajorMinor "$resolvedNewVersion"); defaultVerSpec=$(_installnode_getDefaultVerSpec); qualifier="the latest $suggestedNewDefaultVerSpec.x version - and therefore now $resolvedNewVersion - "; if [[ "$suggestedNewDefaultVerSpec" == "$(_installnode_getDefaultVerSpec)" ]]; then qualifier="$resolvedNewVersion SPECIFICALLY"; suggestedNewDefaultVerSpec=$resolvedNewVersion; fi; defaultVerHint=" NOTE: The DEFAULT VERSION (spec.) is currently: $(_installnode_getDefaultVerSpec) To make $qualifier the NEW default version, run: nvm alias default $suggestedNewDefaultVerSpec "; fi; if (( SHLVL > 1 )); then echo " -- WARNING: $resolvedNewVersion was SUCCESSFULLY INSTALLED, *but* to MAKE IT TAKE EFFECT, do the following: - open a NEW Terminal tab or window. - and execute the following: nvm use $resolvedNewVersion In the future, consider loading this script - '$BASH_SOURCE' - from your shell profile to avoid having to do this. " 1>&2; else echo "-- Done. ACTIVE VERSION is now $resolvedNewVersion."; fi; if [[ -n $defaultVerHint ]]; then echo "$defaultVerHint"; else echo " $resolvedNewVersion is also the NEW DEFAULT."; fi } iterm2_begin_osc () { printf "\033]" } iterm2_end_osc () { printf "\007" } iterm2_preexec_install () { if ( [ x"${PROMPT_COMMAND:-}" = x ] ); then PROMPT_COMMAND="iterm2_preexec_invoke_cmd"; else PROMPT_COMMAND="$(echo -n $PROMPT_COMMAND | sed -e 's/; *$//'); iterm2_preexec_invoke_cmd"; fi; trap 'iterm2_preexec_invoke_exec "$_"' DEBUG } iterm2_preexec_invoke_cmd () { set -o functrace > /dev/null 2>&1; shopt -s extdebug > /dev/null 2>&1; \local s=$?; last_hist_ent="$(HISTTIMEFORMAT= builtin history 1)"; precmd; if [ -z "${ITERM_ORIG_PS1+xxx}" ]; then export ITERM_ORIG_PS1="$PS1"; fi; if [[ "$PS1" != "$ITERM_PREV_PS1" ]]; then export ITERM_ORIG_PS1="$PS1"; fi; \local iterm2_prompt_prefix_value="$(iterm2_prompt_prefix)"; if [[ $ITERM_ORIG_PS1 != *'$(iterm2_prompt_mark)'* ]]; then iterm2_prompt_prefix_value="$iterm2_prompt_prefix_value$(iterm2_prompt_mark)"; fi; sh -c "exit $s"; export PS1="\[$iterm2_prompt_prefix_value\]$ITERM_ORIG_PS1\[$(iterm2_prompt_suffix)\]"; export ITERM_PREV_PS1="$PS1"; sh -c "exit $s"; ITERM_PREEXEC_INTERACTIVE_MODE="yes" } iterm2_preexec_invoke_exec () { if [ ! -t 1 ]; then return; fi; if [[ -n "${COMP_LINE:-}" ]]; then return; fi; if [[ -z "$ITERM_PREEXEC_INTERACTIVE_MODE" ]]; then return; else if [[ 0 -eq "$BASH_SUBSHELL" ]]; then ITERM_PREEXEC_INTERACTIVE_MODE=""; fi; fi; if [[ "iterm2_preexec_invoke_cmd" == "$BASH_COMMAND" ]]; then ITERM_PREEXEC_INTERACTIVE_MODE=""; return; fi; hist_ent="$(HISTTIMEFORMAT= builtin history 1)"; \local prev_hist_ent="${last_hist_ent}"; last_hist_ent="${hist_ent}"; if [[ "${prev_hist_ent}" != "${hist_ent}" ]]; then \local this_command="$(echo "${hist_ent}" | sed -e "s/^[ ]*[0-9]*[ ]*//g")"; else \local this_command=""; fi; preexec "$this_command" } iterm2_print_state_data () { iterm2_begin_osc; printf "1337;RemoteHost=%s@%s" "$USER" "$iterm2_hostname"; iterm2_end_osc; iterm2_begin_osc; printf "1337;CurrentDir=%s" "$PWD"; iterm2_end_osc; iterm2_print_user_vars } iterm2_print_user_vars () { true } iterm2_print_version_number () { iterm2_begin_osc; printf "1337;ShellIntegrationVersion=4;shell=bash"; iterm2_end_osc } iterm2_prompt_mark () { iterm2_begin_osc; printf "133;A"; iterm2_end_osc } iterm2_prompt_prefix () { iterm2_begin_osc; printf "133;D;\$?"; iterm2_end_osc; iterm2_print_state_data } iterm2_prompt_suffix () { iterm2_begin_osc; printf "133;B"; iterm2_end_osc } iterm2_set_user_var () { iterm2_begin_osc; printf "1337;SetUserVar=%s=%s" "$1" $(printf "%s" "$2" | base64 | tr -d '\n'); iterm2_end_osc } kill-script () { [[ -z $1 || $1 == '-h' || $1 == '--help' ]] && { echo "Usage: $FUNCNAME scriptFileName ..."' '"Kills the specified bash/sh script(s)."; return $(( ${#1} == 0 )) }; local ec=0; for p in "$@"; do pkill -nf '/?(bash|sh)[ ]+(.*/)?'"$p"'( |$)' && echo "'$1' killed." || { ec=$?; echo "ERROR: bash/sh script process not found: '$p'" 1>&2 }; done; return $ec } list-available-locales () { case $(uname) in 'Darwin') locale -a ;; 'Linux') [[ -f /usr/share/i18n/SUPPORTED ]] && { cat /usr/share/i18n/SUPPORTED; return }; which localectl &> /dev/null && { localectl list-locales; return }; { echo "Don't know how to determine available locales for $(uname -a)." 1>&2; return 1 } ;; *) { echo "Don't know how to determine available locales for $(uname)." 1>&2; return 1 } ;; esac } lock () { '/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession' -suspend } lsp () { local isFunc=1; [[ -z "$FUNCNAME" ]] && isFunc=0; local thisName=$FUNCNAME; (( isFunc )) || thisName=$(basename "$BASH_SOURCE"); if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat < Save Project As... CAVEAT: As of ST2 v2.0.1, if a project file is opene and the project happens to be open in ST2 already, a new, *blank* window will open. EOF (( isFunc )) && return 0 || exit 0; fi local projSwitch='--project'; local projFile="$@"; if [[ -z $projFile ]]; then local EXT=.sublime-project; local projFiles=($(shopt -s nullglob; echo *$EXT)); projFile=${projFiles[0]}; if [[ -z $projFile ]]; then projSwitch=''; projFile='.'; echo "Opening folder '$PWD' as implicit, transient ST2 project..."; else echo "Opening project '$projFile'..."; fi; else ls "$projFile" > /dev/null 2>&1 || { echo "ERROR: ST2 project file(s) '$projFile' not found." 1>&2; return 1 }; echo "Opening project(s) '$projFile'..."; fi; subl $projSwitch "$projFile" } mang () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat </dev/null | cut -d= -f2 | xargs); [[ -n $expandedAlias ]] && name=$expandedAlias; if (( $# > 1 )); then man "$@"; else { help -s "$name" | grep -E "^$name:" } &> /dev/null && isBuiltIn=1; if [[ $isBuiltIn -ne 0 && $name != 'printf' ]]; then echo "(\"$name\" is a BUILTIN; using 'help'...)"; help "$name"; return $?; else man "$name" 2> /dev/null && return; fi; echo "(No 'man' page found, trying --help, then -h...)" 1>&2; [[ $(echo $name | tr [:upper:] [:lower:]) == 'setfile' ]] && { $name -h; return 0 }; [[ $(echo $name | tr [:upper:] [:lower:]) == 'plistbuddy' || $name == 'plb' ]] && { local exePath="/usr/libexec/PlistBuddy"; echo "IMPORTANT: 'PlistBuddy' is NOT in the PATH - lives at '$exePath'."' '; $exePath; $exePath -h; return 0 }; local ht=$($name --help 2> /dev/null || $name -h) || return; if [[ -z $ht ]]; then ht=$($name --help 2>&1) || ht=$($name -h 2>&1); fi; echo -E "$ht"; fi } manxg () { local targetCmd=${FUNCNAME%g}; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; return ${2:-1} }; function dieSyntax () { echo "${FUNCNAME[1]}(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h or --h for help." 1>&2; return 2 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; else [[ -n $firstDirCreated ]] || firstDirCreated="$dir"; argsForMkDir+=("$dir"); (( ++createCount )); fi; done; (( createCount )) && { mkdir "${argsForMkDir[@]}" || return $(die) }; cd "$firstDir" || return $(die); msgCreation=''; case $createCount in 0) msgCreation='C' ;; 1) if [[ $firstDirCreated == $firstDir ]]; then msgCreation='Created and c'; else msgCreation='1 dir. created; c'; fi ;; *) msgCreation="$createCount dirs. created; c" ;; esac; echo "${msgCreation}hanged to '$firstDir' [$PWD]." } mktempfile () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "usage: $FUNCNAME [ext]\n Creates a unique temporary file or folder and returns its full path.\n Acts as a simple wrapper around \`mktemp -t tmp\`; i.e., file is created in \$TMPDIR (or /tmp, in its absence);\n optionally specify additional \`mktemp\` options, such as -u to delete the file right away,\n or -d to create a directory instead.\n If you specify EXT, the temporary file is given the specified filename extension." && return 0; local ext; local isDir=0; local dontCreate=0; for p in "$@"; do if [[ "${p:0:1}" != "-" ]]; then [[ -n "$ext" ]] && { echo "$FUNCNAME: PARAMETER ERROR: You can only specify ONE filename extension." 1>&2; return 1 }; ext=$p; else if [[ "$p" == "-d" ]]; then isDir=1; else if [[ "$p" == "-u" ]]; then dontCreate=1; fi; fi; fi; done; [[ isDir -eq 1 && -n $ext ]] && { echo "$FUNCNAME: PARAMETER ERROR: You can only specify a filename extension when you create a file (not a directory)." 1>&2; return 1 }; local passThru=${@/$ext}; local outPath=$(mktemp $passThru -t 'tmp'); [[ -z "$outPath" ]] && return 1; if [[ -n "$ext" ]]; then local oldOutPath=$outPath; [[ "${ext:0:1}" != '.' ]] && ext=".$ext"; outPath+=$ext; if (( ! dontCreate )); then mv "$oldOutPath" "$outPath" || return 1; fi; fi; echo "$outPath" } npmf () { function die () { echo "${FUNCNAME[1]}(): ERROR: ${1:-"ABORTING due to unexpected error."}" 1>&2; return ${2:-1} }; function dieSyntax () { echo "${FUNCNAME[1]}(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h or --h for help." 1>&2; return 2 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat < /dev/null || return $(die) } npml () { function die () { echo "${FUNCNAME[1]}(): ERROR: ${1:-"ABORTING due to unexpected error."}" 1>&2; return ${2:-1} }; function dieSyntax () { echo "${FUNCNAME[1]}(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h for help." 1>&2; return 2 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat </dev/null | perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))'`; if [[ -z $data ]]; then echo ERROR: No HTML data found on clipboard. 1>&2; return 1; fi; echo "$data" } pbpaste_rtf () { local data; data=`osascript -e 'class RTF of (the clipboard as record)' 2>/dev/null | perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))'`; if [[ -z $data ]]; then echo ERROR: No RTF data found on clipboard. 1>&2; return 1; fi; echo "$data" } pifs () { set | egrep '^IFS=' } precmd () { if [[ -z "${iterm2_ran_preexec:-}" ]]; then preexec ""; fi; iterm2_ran_preexec="" } preexec () { iterm2_begin_osc; printf "133;C;"; iterm2_end_osc; if [ -n "${ITERM_ORIG_PS1+xxx}" -a "$PS1" = "$ITERM_PREV_PS1" ]; then export PS1="$ITERM_ORIG_PS1"; fi; iterm2_ran_preexec="yes" } pushdX () { pushd "$1" > /dev/null || return $?; [[ -t 1 ]] && echo "${PWD/#$HOME/~}" || echo "${PWD}"; shift; if (( $# )); then "$@"; fi } pv () { local pipeStatus=(${PIPESTATUS[@]}); local bashReMatch=("${BASH_REMATCH[@]}"); [[ "$1" == '-h' || "$1" == '--help' ]] && { cat < e.g., 'HOME="/Users/jdoe" # -x' $FUNCNAME 'histf*' # -> e.g., $'HISTFILE="/Users/jdoe/.bash_history"\nHISTFILESIZE="500"' EOF return 0 } function __pv_encodeCtrlChars () { local v=$1; v=${v//' '/\\t}; v=${v//' '/\\n}; '/\\r}; v=${v//''/\\v}; local/l=$(( ${#v} - 2 )); printf '%s' "\$'${v:1:$l}'" }; local vname vnamePattern vnames=("$@") allVnames=() matchPatterns=0 countOk=0 patternMatched=0 warnBashVars=0; for vname in "${vnames[@]}"; do if [[ $vname == *[][*?]* ]]; then matchPatterns=1; break; fi; done; if (( $# == 0 || matchPatterns )); then if [[ $BASH_VERSINFO -lt 4 ]]; then local allVnames=($(declare -p | LC_ALL=C sed -n -E -e '1,/^[^=]+\(\)/p' | LC_ALL=C sed -E -n -e '/^[[:alnum:]_]+=/p' | LC_ALL=C awk -F '=' '{ print $1 }')); else local allVnames=($(declare -p | LC_ALL=C egrep '^declare -' | cut -d ' ' -f 3- | cut -d '=' -f 1)); fi; allVnames+=('-'); if (( $# == 0 )); then vnames=("${allVnames[@]}"); else vnamesWithPatterns=("${vnames[@]}"); vnames=(); local mustReset=$(shopt -q nocasematch; echo $?); shopt -s nocasematch; for vnamePattern in "${vnamesWithPatterns[@]}"; do if [[ $vnamePattern == *[][*?]* ]]; then patternMatched=0; for vname in "${allVnames[@]}"; do [[ "$vname" == $vnamePattern ]] && { vnames+=("$vname"); patternMatched=1 }; done; (( patternMatched )) || { echo "WARNING: No variables match pattern: $vnamePattern" 1>&2 }; else vnames+=("$vnamePattern"); fi; done; (( mustReset )) && shopt -u nocasematch; fi; fi; for vname in "${vnames[@]}"; do if [[ $vname == '-' ]]; then echo "-=$- # -r"; else [[ $vname == 'BASH_'* && ! ( $vname == 'BASH_REMATCH' || $vname == 'BASH_VERSION' || $vname == 'BASH_VERSINFO' ) || $vname == '_' ]] && { warnBashVars=1; continue }; local vdef=$(declare -p "$vname" 2> /dev/null); if [[ -z $vdef ]]; then if (( $# )); then echo "WARNING: Variable '$vname' is not defined." 1>&2; fi; else local vdef=${vdef#declare }; local attrs vval; IFS=' =' read -d '' -r attrs vname vval <<< "$vdef"; if [[ $vname == 'PIPESTATUS' ]]; then vval=$(declare -p pipeStatus | cut -d= -f2-); else if [[ $vname == 'BASH_REMATCH' ]]; then vval=$(declare -p bashReMatch | cut -d= -f2-); else vval=$(printf '%s' "$vval"); fi; fi; [[ $vname == 'IFS' ]] && vval=$(__pv_encodeCtrlChars "$vval"); printf '%s' "$vname=$vval"; attrs=${attrs/a/}; [[ -n $attrs && $attrs != '--' && $attrs != '-' ]] && printf " # $attrs"; printf '\n'; (( ++countOk )); fi; fi; done; (( warnBashVars )) && echo "WARNING: Cannot report true value of \$_ and some \$BASH_* variables due to technical limitations."' '"Use \`echo \"\$BASH_...\"\` instead; e.g., \`echo \"\${BASH_SOURCE[@]}\"\`." 1>&2; return $(( countOk == 0 )) } ql () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat < /dev/null } resetcolors () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; return 2 }; printf '\e[0m' } resume-script () { [[ -z $1 || $1 == '-h' || $1 == '--help' ]] && { echo "Usage: $FUNCNAME scriptFileName ..."' '"Resumes the specified bash/sh script(s)."; return $(( ${#1} == 0 )) }; local ec=0; for p in "$@"; do pkill -CONT -nf '/?(bash|sh)[ ]+(.*/)?'"$p"'( |$)' && echo "'$1' resumed." || { ec=$?; echo "ERROR: bash/sh script process not found: '$p'" 1>&2 }; done; return $ec } sl () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2 && return 1 ;; *) break ;; esac; shift; done; [[ -z "$1" ]] && echo -e "$FUNCNAME: PARAMETER ERROR: Too few parameters specified. Use -h or --h to get help." 1>&2 && return 1; local allTokens; if (( !optNoTotal && ${#@} >=2 )); then local allTokens=$*; fi; local totalLen=0; local result=''; while (( ${#@} )); do local len=${#1}; (( totalLen+=len )); result="${result}'$1': $len"' '; shift; done; if [[ -n "$allTokens" ]]; then echo "Total: ${#allTokens}/$totalLen (with/without interior spaces)"; fi; echo -n "$result" } stripColors () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; return 2 }; LC_ALL=C sed -E 's/'''\[([0-9]{1,2})?(;[0-9]{1,2})*m//g' } stripFormatting () { if [[ $(uname) == 'Linux' ]]; then stripColors | col -b; else stripColors | LC_ALL=C col -b; fi } suspend-script () { [[ -z $1 || $1 == '-h' || $1 == '--help' ]] && { echo "Usage: $FUNCNAME scriptFileName ..."' '"Suspends the specified bash/sh script(s)."; return $(( ${#1} == 0 )) }; local ec=0; for p in "$@"; do pkill -STOP -nf '/?(bash|sh)[ ]+(.*/)?'"$p"'( |$)' && echo "'$1' suspended." || { ec=$?; echo "ERROR: bash/sh script process not found: '$p'" 1>&2 }; done; return $ec } tc () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&1 | $FUNCNAME' instead of just '| $FUNCNAME'. - With COMMAND specified, executes it, and copies its stdout output to the clipboard using 'pbcopy'. To capture commands involving pipes and stdout/err redirection, use the postpositional form instead. If COMMAND returns an error, it is reported, and nothing is copied to the clipboard. No stdout output is displayed by default. Pass -p (--passthru) as the 1st argument to also echo what was captured. A nonzero exitcode, possibly accompanied by an error message, indicates failure. Examples: ls | $FUNCNAME $FUNCNAME ls EOF return 0; fi [[ $1 == '-p' || $1 =~ ^--?[Pp][Aa][Ss][Ss][Tt][Hh][Rr][Uu]$ ]] && { local passThru=1; shift }; if (( $# )); then local ftemp=$(mktemp -t "$FUNCNAME"); ( eval "$@" > "$ftemp" ); local ec=$?; (( ec != 0 )) && rm "$ftemp" && echo '(Nothing was copied to clipboard.)' 1>&2 && return $ec; echo -En "$( < "$ftemp" )" | pbcopy; rm "$ftemp"; else pbcopy || return; fi; (( passThru )) && pbpaste } tobin () { local n; for n in "$@"; do bc <<< "obase=2;$(( n ))"; done } todec () { local outputBaseSpecChar='d'; _tobase "$@" } tohex () { local outputBaseSpecChar='x'; _tobase "$@" } tooct () { local outputBaseSpecChar='o'; _tobase "$@" } trim () { var=$1; var="${var#"${var%%[![:space:]]*}"}"; var="${var%"${var##*[![:space:]]}"}"; echo -n "$var" } typex () { case $1 in -h | --help | --version | --man | --man-source | --home) "$__typex_scriptpath" "$@"; return ;; esac; function __typex_rreadlinkchain () { ( command typeset target="$1" targetDir= targetName= CDPATH=; unalias cd pwd readlink dirname basename printf 2> /dev/null; unset -f cd pwd readlink dirname basename printf 2> /dev/null; while :; do [[ -L $target || -e $target ]] || { printf '%s\n' "typex: WARNING: '$target' does not exist." 1>&2; return 1 }; cd "$(dirname -- "$target")"; targetDir=$PWD; targetName=$(basename -- "$target"); [[ $targetName == '/' ]] && targetName=''; done=0; if [[ ! -L $targetName ]]; then targetDir=$(pwd -P); done=1; fi; printf '%s\n' "${targetDir%/}/$targetName"; (( done )) && break; target=$(readlink -- "$targetName"); done ) }; function __typex_getFileTimestamp () { command typeset file="$1" kind="${2:-m}" outFmt="$3" fmtOptChar= fmtChar= osNdx=; osNdx=0; [[ $(command uname) == 'Linux' ]] && osNdx=1; fmtOptChar='fc'; case "$kind" in m) fmtChar='mY' ;; a) fmtChar='aX' ;; b) fmtChar='BW' ;; c) fmtChar='cZ' ;; *) return 1 ;; esac; ts=$(command stat -${fmtOptChar:$osNdx:1} "%${fmtChar:$osNdx:1}" "$file") || return; if [[ -n $outFmt ]]; then case $osNdx in 0) command date -j -f '%s' "$ts" +"$outFmt" || return ;; 1) command date -d @"$ts" +"$outFmt" || return ;; esac; else command printf '%s\n' "$ts"; fi }; function __typex_reMatch () { command typeset ec= outVar="${3:-__typex_reMatch}"; unset -v "$outVar"; [[ $1 =~ $2 ]]; ec=$?; if [[ $ec -eq 0 ]]; then [[ -n $BASH_VERSION ]] && eval "$outVar"'=( "${BASH_REMATCH[@]}" )'; [[ -n $KSH_VERSION ]] && eval "$outVar"'=( "${.sh.match[@]}" )'; [[ -n $ZSH_VERSION ]] && eval "$outVar"'=( "$MATCH" "${match[@]}" )'; fi; return $ec }; function __typex_reQuote () { command sed 's/[^^]/[&]/g; s/\^/\\^/g' <<< "$*" }; function __typex_install () { command typeset targetShellFilename=$1 install=$2 runningStandalone=$3 scriptFileAbsPath=$4; command typeset verbose=1 scriptFileAbsPathQ= initFile= instLineRegEx= found=0 cmd= cmt= ec= newContents=; command typeset dir=${TYPEX_TEST_INITFILE_DIR:-~}; case "$targetShellFilename" in 'bash') [[ $(uname) == 'Darwin' ]] && initFile="$dir/.bash_profile" || initFile="$dir/.bashrc" ;; 'ksh') initFile="$dir/.kshrc" ;; 'zsh') initFile="$dir/.zshrc" ;; *) printf '%s\n' "ERROR: ${scriptFileAbsPath##*/} can only be sourced in bash, ksh, or zsh -- $targetShell is not supported." 1>&2; return 2 ;; esac; scriptFileAbsPathQ=$(command printf '%q' "$scriptFileAbsPath"); cmd="[[ -f $scriptFileAbsPathQ ]] && . $scriptFileAbsPathQ"; cmt="# Added by ${scriptFileAbsPath##*/} -i; ${scriptFileAbsPath##*/} -u to remove."; instLineRegEx='^[[:space:]]*'"$(__typex_reQuote "$cmd")"'([[:space:]]|$)'; [[ -f $initFile ]] && command grep -Eq "$instLineRegEx" "$initFile" && found=1; ec=0; if (( install )); then if (( found )); then (( verbose )) && command printf '%s\n' "(Sourcing command for '$scriptFileAbsPath' already present in '$initFile'; nothing to do.)"; else printf '\n%s %s\n' "$cmd" "$cmt" >> "$initFile"; ec=$?; fi; else if (( ! found )); then (( verbose )) && command printf '%s\n' "(Sourcing command for '$scriptFileAbsPath' not present in '$initFile'; nothing to do.)"; else newContents=$(command grep -Ev "$instLineRegEx" "$initFile") && command printf '%s\n' "$newContents" > "$initFile"; ec=$?; unset -f ${scriptFileAbsPath##*/} 2> /dev/null; fi; fi; if (( install )); then if (( ec == 0 )); then command printf '%s\n' "Sourcing of '$scriptFileAbsPath' installed in '$initFile'."; else command printf '%s\n' "ERROR: Failed to install sourcing of '$scriptFileAbsPath' in '$initFile'; please manually add line '. $scriptFileAbsPath'." 1>&2; fi; else if (( ec == 0 )); then command printf '%s\n' "Sourcing of '$scriptFileAbsPath' uninstalled from '$initFile'."; else command printf '%s\n' "ERROR: Failed to uninstall sourcing of '$scriptFileAbsPath' from '$initFile'; please manually remove the line containing '. $scriptFileAbsPath'." 1>&2; fi; fi; return $ec }; function __typex_init () { [[ -n $ZSH_VERSION ]] && { __typex_prevPosixBuiltinsOptState=${options[posixbuiltins]}; options[POSIX_BUILTINS]=on; __typex_prevKshArrayEmulationOptState=${options[ksharrays]}; options[ksharrays]=on } || unset __typex_prevPosixBuiltinsOptState __typex_prevKshArrayEmulationSOpttate }; function __typex_restore () { [[ -n $__typex_prevPosixBuiltinsOptState ]] && options[posixbuiltins]=$__typex_prevPosixBuiltinsOptState; [[ -n $__typex_prevKshArrayEmulationOptState ]] && options[ksharrays]=$__typex_prevKshArrayEmulationOptState }; __typex_init; command typeset thisFuncName=$([[ -n $BASH_VERSION ]] && command printf %s "$FUNCNAME" || command printf %s "$0"); command typeset notSourced=0; [[ $1 == '--not-sourced' ]] && { shift; notSourced=1 }; command typeset all=1; command typeset CDPATH= numNotFound=0 name= names= isExplicitPath=0 isKeyword=0 keywordOutput= def= found=0 isBuiltIn=0 specialFileType= brokenSymlink=0 extraOpt= files= file= thisfile= fileCategory= fileType= scriptType= ver= fileLinkChain= trueFile= errMsgSuffix= shell=; command typeset fileSystemOnly=0 noVersion=0 verbose=0 install=0 uninstall=0; command typeset allowOptsAfterOperands=1 i=0 optName= isLong=0 prefix= optArg= haveOptArgAttached=0 haveOptArgAsNextArg=0 acceptOptArg=0 needOptArg=0; command typeset -a operands; __typex_reMatch=; while (( $# )); do if __typex_reMatch "$1" '^(-)[a-zA-Z0-9]+.*$' || __typex_reMatch "$1" '^(--)[a-zA-Z0-9]+.*$'; then prefix=${__typex_reMatch[1]}; [[ $prefix == '--' ]] && isLong=1 || isLong=0; for ((i = 1; i < (isLong ? 2 : ${#1}); i++ )) do command typeset acceptOptArg=0 needOptArg=0 haveOptArgAttached=0 haveOptArgAsNextArg=0 optArgAttached= optArgOpt= optArgReq=; if (( isLong )); then optName=${1:2}; __typex_reMatch "$optName" '^([^=]+)=(.*)$' && { optName=${__typex_reMatch[1]}; optArgAttached=${__typex_reMatch[2]}; haveOptArgAttached=1 }; else optName=${1:$i:1}; optArgAttached=${1:$i+1}; (( ${#optArgAttached} >= 1 )) && haveOptArgAttached=1; fi; (( haveOptArgAttached )) && optArgOpt=$optArgAttached optArgReq=$optArgAttached || { (( $# > 1 )) && { optArgReq=$2; haveOptArgAsNextArg=1 } }; case $optName in p | files-only) fileSystemOnly=1 ;; v | verbose) verbose=1 ;; V | skip-version) noVersion=1 ;; i | install-sourcing) install=1 ;; u | uninstall-sourcing) uninstall=1 ;; *) { echo "$thisFuncName: ARGUMENT ERROR: Unknown option: ${prefix}${optName}" 1>&2; __typex_restore; return 2 } ;; esac; (( needOptArg )) && { (( ! haveOptArgAttached && ! haveOptArgAsNextArg )) && { echo "$thisFuncName: ARGUMENT ERROR: Option ${prefix}${optName} is missing its argument." 1>&2; __typex_restore; return 2 } || (( haveOptArgAsNextArg )) && shift }; (( acceptOptArg || needOptArg )) && break; done; else if [[ $1 == '--' ]]; then shift; operands+=("$@"); break; else if (( allowOptsAfterOperands )); then operands+=("$1"); else operands=("$@"); break; fi; fi; fi; shift; done; (( ${#operands[@]} > 0 )) && set -- "${operands[@]}"; unset allowOptsAfterOperands operands i optName isLong prefix optArgAttached haveOptArgAttached haveOptArgAsNextArg acceptOptArg needOptArg; if (( install || uninstall )); then (( !fileSystemOnly && !noVersion && !(install && uninstall) && $# == 0 )) || { echo "$thisFuncName: ARGUMENT ERROR: Incompatible options specified." 1>&2; __typex_restore; return 2 }; (( uninstall )) && install=0; command typeset shellCount=0 okCount=0; for shell in bash ksh zsh; do (( ++shellCount )); if [[ $TYPEX_TEST_ALL_INITFILES != '1' ]]; then if [[ -n $ZSH_VERSION ]]; then command which -p $shell > /dev/null 2>&1 || continue; else command which $shell > /dev/null 2>&1 || continue; fi; fi; __typex_install $shell $install $notSourced "$__typex_scriptpath" && (( ++okCount )); done; (( install && okCount )) && command printf '%s\n' 'Open a new shell tab or window for sourcing to take effect.'; if (( okCount == shellCount )); then __typex_restore; return 0; else __typex_restore; return $(( shellCount - okCount )); fi; fi; if (( $# == 0 )); then names=($(f=$(command ps -o comm= $( (( notSourced )) && command printf $PPID || command printf $$ )); [[ $f =~ ^- ]] && command printf %s "$SHELL" || command printf %s "$f")); fileSystemOnly=1; else names=("$@"); fi; if (( ! fileSystemOnly )); then fileSystemOnly=1; for name in "${names[@]}"; do [[ $name == */* ]] || { fileSystemOnly=0; break }; done; fi; if (( ! fileSystemOnly && notSourced )); then fileSystemOnly=1; if __typex_isParentSupportedShell; then command cat 1>&2 <\` To install sourcing persistently for interactive shells, run \`${__typex_scriptpath##*/} -i\`. Use \`-p\` to suppress this warning if you're only looking for executable *files*. EOF else command cat 1>&2 < /dev/null | command egrep -q ' keyword$' && isKeyword=1; else if [[ -n $ZSH_VERSION ]]; then command type -wa "$name" 2> /dev/null | command egrep -q ' reserved$' && isKeyword=1; else command type -ta "$name" 2> /dev/null | command fgrep -qx 'keyword' && isKeyword=1; fi; fi; if (( isKeyword )); then found=1; keywordOutput=$(command printf '%-10s %s' 'KEYWORD:' "$name"); fi; if [[ -n $keywordOutput && -n $KSH_VERSION ]]; then command printf '%s\n' "$keywordOutput"; fi; def=$(command alias "$name" 2>/dev/null); if [[ -n $def ]]; then found=1; command printf '%-10s %s\n' 'ALIAS:' "${def#alias }"; (( all )) || { __typex_restore; return 0 }; def=$(cut -d= -f2- <<<"$def" | tr -d \'\" | cut -d' ' -f1); typex -- "$def" 2> /dev/null | sed 's/^/ /'; fi; if [[ -n $keywordOutput && -z $KSH_VERSION ]]; then command printf '%s\n' "$keywordOutput"; fi; def=$(command typeset -f "$name" 2>/dev/null); if [[ -n $def ]]; then found=1; command printf '%-10s %s' 'FUNCTION:' "$name()"; if [[ -n $BASH_VERSION ]]; then command declare -F | command egrep -q -- "-fx $name\$" && command printf ' # -x'; fi; command printf '\n'; (( verbose )) && command sed 's/^/ /' <<< "$def"; (( all )) || { __typex_restore; return 0 }; fi; if [[ -n $KSH_VERSION ]]; then command builtin | command fgrep -qx -- "$name" && isBuiltIn=1; else if [[ -n $ZSH_VERSION ]]; then command type -wa -- "$name" 2> /dev/null | command egrep -q ':\s+builtin$' && isBuiltIn=1; else command type -ta -- "$name" 2> /dev/null | command fgrep -qx 'builtin' && isBuiltIn=1; fi; fi; if (( isBuiltIn )); then command printf '%-10s %s\n' 'BUILTIN:' "$name"; (( all )) || { __typex_restore; return 0 }; found=1; fi; fi; files=; if (( isExplicitPath )) || [[ $name == '.' ]]; then if [[ -d $name ]]; then files=$(command cd "$name" && command echo "$PWD"); else if [[ -e $name || -L $name ]]; then [[ ! -e $name ]] && brokenSymlink=1; [[ -n $KSH_VERSION && $name =~ ^'../.' ]] && name="${PWD%/}/$name"; files=$(command cd -- "$(command dirname -- "$name")" && command echo "${PWD%/}/")$(command basename -- "$name"); [[ $files =~ / ]] || { __typex_restore; return 1 }; else :; fi; fi; else if [[ -n $ZSH_VERSION ]]; then files=$(command which -ap -- "$name" 2>/dev/null) || files=''; else files=$(command which -a -- "$name" 2>/dev/null) || files=''; fi; fi; if [[ -n $files ]]; then found=1; while command read -r file; do (( brokenSymlink )) || extraOpt='-L'; fileType=$(command file -b $extraOpt -- "$file"); if [[ -d $file ]]; then fileCategory='DIRECTORY:'; else if [[ -x $file ]]; then scriptType=$(command egrep -o '(POSIX )?(\w+ )script' <<<"$fileType"); [[ -z $scriptType ]] && command egrep -q '\' <<< "$fileType" && scriptType='script w/o shebang line'; [[ -n $scriptType ]] && fileCategory='SCRIPT:' || fileCategory='BINARY:'; else fileCategory='FILE:'; fi; fi; fileLinkChain=$(__typex_rreadlinkchain "$file"); if [[ ! $fileLinkChain =~ ' ' ]]; then trueFile=$fileLinkChain; if [[ "$file" != "$trueFile" ]]; then command printf '%-10s %s -> %s' "$fileCategory" "$file" "$fileLinkChain"; else command printf '%-10s %s' "$fileCategory" "$file"; fi; else trueFile=$(command tail -n 1 <<<"$fileLinkChain"); command printf '%-10s %s' "$fileCategory" "$(command awk -v RS= -v sep=' -> ' '{ gsub("\n$", ""); gsub("\n", "@" sep); printf "%s", $0 }' <<<"$fileLinkChain")"; fi; if [[ -d $file ]]; then :; else if [[ -x $file ]]; then [[ -n $scriptType ]] && printf ' (%s)' "$scriptType"; ver=; if (( ! noVersion )); then ver=$("$file" --version &1 | command sed '/^$/d; q' | command fgrep -v -- '--version' | command fgrep -vi -- 'unknown invalid illegal unrecognized not recognized' | command egrep -i -e '[0-9]\.' -e 'version' -e 'build' ); fi; [[ -z $ver ]] && ver=$(__typex_getFileTimestamp "$trueFile" m '%Y-%m-%d'); printf ' [%s]' "$ver"; else printf ' (%s)' "$fileType"; fi; fi; if (( verbose )); then while command read -r thisfile; do command printf '\n %s' "$(command ls -dFAhl -- "$thisfile" | command cut -d/ -f1)"; done <<< "${fileLinkChain:-$file}"; if [[ ! -d $file ]]; then if [[ -n $scriptType ]]; then command printf '\n %s' "$(command head -n 1 "$file")"; else if [[ -x $file ]]; then command printf '\n %s' "$(sed '1! s/^/ /' <<<"$fileType")"; fi; fi; fi; fi; command printf '\n'; (( all )) || break; done <<< "$files"; fi; if (( ! found )); then (( ++numNotFound )); if (( isExplicitPath )); then errMsgSuffix=": No such file or directory, or insufficient permissions for inspection."; else (( fileSystemOnly )) && errMsgSuffix=' is not an executable in the PATH.' || errMsgSuffix=' is neither an alias, keyword, function, builtin, nor an executable in the PATH.'; [[ -e $name ]] && errMsgSuffix+=' However, it does exist as a filesystem item in the current directory. To target that, prefix with "./"'; fi; command printf '%s\n' "$thisFuncName: \"${name}\"${errMsgSuffix}" 1>&2; fi; done; __typex_restore; return $numNotFound } up () { local dir='../'; [[ "$1" == '-h' || "$1" == '--help' ]] && { echo -e "usage:\n\t$FUNCNAME [n]\n\t$FUNCNAME dirname\n Moves up N levels in the path to the current working directory, 1 by default.\n If DIRNAME is given, it must be the full name of an ancestral directory (case does not matter).\n If there are multiple matches, the one *lowest* in the hierarchy is changed to." && return 0 }; if [[ -n "$1" ]]; then if [[ $1 =~ ^[0-9]+$ ]]; then local strpath=$( printf "%${1}s" ); dir=${strpath// /$dir}; else if [[ $1 =~ ^/ ]]; then dir=$1; else local wdLower=$(echo -n "$PWD" | tr '[:upper:]' '[:lower:]'); local tokenLower=$(echo -n "$1" | tr '[:upper:]' '[:lower:]'); local newParentDirLower=${wdLower%/$tokenLower/*}; [[ "$newParentDirLower" == "$wdLower" ]] && { echo "$FUNCNAME: No ancestral directory named '$1' found." 1>&2; return 1 }; local targetDirPathLength=$(( ${#newParentDirLower} + 1 + ${#tokenLower} )); dir=${PWD:0:$targetDirPathLength}; fi; fi; fi; pushd "$dir" > /dev/null } vmrun () { "/Applications/VMware Fusion.app/Contents/Library/vmrun" "$@" } vo () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&1 | $FUNCNAME' instead of just '| $FUNCNAME'. - With COMMAND specified, executes it, and captures both its stdout and stderr output. If COMMAND returns a nonzero exit code, a warning is printed to stderr. This utility itself, however, always returns exit code 0. If the output captured contains ANSI color escape sequences or troff formatting such as from `man` output, such formatting is automatically removed. Examples: $FUNCNAME ls *.txt nosuch ls *.txt nosuch | $FUNCNAME ls *.txt nosuch 2>&1 | $FUNCNAME EOF return 0; fi local ph=''; [[ $(uname) == 'Darwin' ]] || ph='.XXXXXXXXXX'; local ftemp=$(mktemp -t "$FUNCNAME$ph"); if (( $# )); then ( shopt -s expand_aliases; eval "$@" 2>&1 | stripFormatting > "$ftemp"; [[ ${PIPESTATUS[0]} -eq 0 ]] || echo "$FUNCNAME: WARNING: Command returned nonzero exit code: ${PIPESTATUS[0]}" 1>&2 ); else cat | stripFormatting > "$ftemp"; fi; local editor=$(which -a subl code | fgrep -v -x "$MK_UTIL_FOLDER/subl" | head -n 1); [[ -n $editor ]] || { echo "ERROR: Neither \`code\` nor \`subl\` are in your PATH." 2> /dev/null; exit 1 }; local newWin=1; (( newWin )) && newWinOpt=--new-window; ( { "$editor" --wait $newWinOpt "$ftemp"; rm -f "$ftemp" } & ) } doIt too * The command line being run * The files being read (put the files on a webserver if they are big) If you get the error on smaller/fewer files, please include those instead. parallel: This should not happen. You have found a bug. Please contact and include: * The version number: 20170322 * The bugid: open3-GLOB(0x7fec073144a0) shopt -u autocd&>/dev/null; shopt -u cdable_vars&>/dev/null; shopt -u cdspell&>/dev/null; shopt -u checkhash&>/dev/null; shopt -u checkjobs&>/dev/null; shopt -u checkwinsize&>/dev/null; shopt -s cmdhist&>/dev/null; shopt -u compat31&>/dev/null; shopt -u compat32&>/dev/null; shopt -u compat40&>/dev/null; shopt -u compat41&>/dev/null; shopt -u compat42&>/dev/null; shopt -u compat43&>/dev/null; shopt -s complete_fullquote&>/dev/null; shopt -u direxpand&>/dev/null; shopt -u dirspell&>/dev/null; shopt -u dotglob&>/dev/null; shopt -u execfail&>/dev/null; shopt -s expand_aliases&>/dev/null; shopt -s extdebug&>/dev/null; shopt -u extglob&>/dev/null; shopt -s extquote&>/dev/null; shopt -u failglob&>/dev/null; shopt -s force_fignore&>/dev/null; shopt -u globasciiranges&>/dev/null; shopt -u globstar&>/dev/null; shopt -u gnu_errfmt&>/dev/null; shopt -u histappend&>/dev/null; shopt -u histreedit&>/dev/null; shopt -u histverify&>/dev/null; shopt -s hostcomplete&>/dev/null; shopt -u huponexit&>/dev/null; shopt -u inherit_errexit&>/dev/null; shopt -s interactive_comments&>/dev/null; shopt -u lastpipe&>/dev/null; shopt -u lithist&>/dev/null; shopt -u login_shell&>/dev/null; shopt -u mailwarn&>/dev/null; shopt -s no_empty_cmd_completion&>/dev/null; shopt -s nocaseglob&>/dev/null; shopt -u nocasematch&>/dev/null; shopt -u nullglob&>/dev/null; shopt -s progcomp&>/dev/null; shopt -s promptvars&>/dev/null; shopt -u restricted_shell&>/dev/null; shopt -u shift_verbose&>/dev/null; shopt -s sourcepath&>/dev/null; shopt -u xpg_echo&>/dev/null; shopt -s expand_aliases &>/dev/null alias ash='(f=$(ps -o comm= $$); [[ $f =~ ^- ]] && echo $SHELL || which "$f")' alias bi='bundleid' alias bv='echo $BASH_VERSION' alias cdb='cd "$OLDPWD"' alias cpg='"$HOME/Desktop/pg"/cpg' alias dec='de "$@"' alias dn='/dev/null' alias dpg='"$HOME/Desktop/pg"/dpg' alias dt='cat -et' alias e='/Users/jdoe/MkUtil/editf' alias ecc='editf $MK_UTIL_FOLDER/sourced.d/bash_completion.d/custom-completions' alias ecpg='editf "$HOME/Desktop/pg"/cpg' alias edpg='editf "$HOME/Desktop/pg"/dpg' alias eh='enc --html' alias ei='editf ~/.bashrc' alias ejaypg='editf "$HOME/Desktop/pg"/jaypg' alias ekpg='editf "$HOME/Desktop/pg"/kpg' alias enp='editf ~/.nesh_profile.coffee' alias enpg='editf "$HOME/Desktop/pg"/npg' alias ep='editf ~/.bash_profile' alias epg='editf "$HOME/Desktop/pg"/pg' alias epg.cpp='editf "$HOME/Desktop/pg"/pg.cpp' alias epg.cs='editf "$HOME/Desktop/pg"/pg.cs' alias epg.html='editf "$HOME/Desktop/pg"/pg.html' alias epg.md='editf "$HOME/Desktop/pg"/pg.md' alias epg.ts='editf "$HOME/Desktop/pg"/pg.ts' alias epg2='editf "$HOME/Desktop/pg"/pg2' alias epg4='editf "$HOME/Desktop/pg"/pg4' alias epgjxa.scpt='editf "$HOME/Desktop/pg"/pgjxa.scpt' alias ephpg='editf "$HOME/Desktop/pg"/phpg' alias epi='editf ~/.perli_rc' alias eplpg='editf "$HOME/Desktop/pg"/plpg' alias epy3pg='editf "$HOME/Desktop/pg"/py3pg' alias epypg='editf "$HOME/Desktop/pg"/pypg' alias eqcd='editf $MK_UTIL_FOLDER/sourced.d/quickCdDefs' alias erpg='editf "$HOME/Desktop/pg"/rpg' alias es='edits' alias eshallpg='editf "$HOME/Desktop/pg"/shallpg' alias eshpg='editf "$HOME/Desktop/pg"/shpg' alias etclpg='editf "$HOME/Desktop/pg"/tclpg' alias eu='enc --uri' alias ex='enc --xml' alias exppg='editf "$HOME/Desktop/pg"/xppg' alias ezpg='editf "$HOME/Desktop/pg"/zpg' alias fhx='od -t x1' alias fp='fullpath' alias fq='findq' alias fx='findexes' alias gc='git checkout' alias gcb='pbpaste' alias gcm='typex' alias gfs='getFinderSel' alias gl='git log --pretty=oneline' alias gs='git status -b --short' alias gt='git describe --abbrev=0 --tags' alias gvr='git remote -v | awk '\''{ print $2; exit }'\'' | xargs open' alias hd='hexdump' alias hg='echo "(Using MacHg binary via an alias.)"; "/Applications/MacHg.app/Contents/Resources/localhg"' alias imgcat='/Users/jdoe/.iterm2/imgcat' alias imgls='/Users/jdoe/.iterm2/imgls' alias it2attention='/Users/jdoe/.iterm2/it2attention' alias it2check='/Users/jdoe/.iterm2/it2check' alias it2copy='/Users/jdoe/.iterm2/it2copy' alias it2dl='/Users/jdoe/.iterm2/it2dl' alias it2getvar='/Users/jdoe/.iterm2/it2getvar' alias it2setcolor='/Users/jdoe/.iterm2/it2setcolor' alias it2setkeylabel='/Users/jdoe/.iterm2/it2setkeylabel' alias it2ul='/Users/jdoe/.iterm2/it2ul' alias it2universion='/Users/jdoe/.iterm2/it2universion' alias jaypg='"$HOME/Desktop/pg"/jaypg' alias josa='osascript -l JavaScript' alias kbs='keyboardspec' alias kpg='"$HOME/Desktop/pg"/kpg' alias lf='declare -F | awk '\''{ print $3 }'\''' alias lfe='declare -Fx | awk -F'\''[ =]'\'' '\''{ print $3 }'\''' alias lsregister='/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister' alias lsx='fls -FAhl' alias lv='(shopt -so posix; declare | awk -F= '\''{ print $1 }'\'')' alias lve='export -p | awk -F'\''[ =]'\'' '\''{ print $3 }'\''' alias lx='PATH=".:$PATH"' alias m='manx' alias md='mkdir' alias mdp='markdown.pl' alias mg='manxg' alias mmdp='multimarkdown' alias mo='manopt' alias mu='markup-js' alias mw='manw' alias ne='node -e' alias np='node -p' alias npg='"$HOME/Desktop/pg"/npg' alias npmenv='echo "ENTERING CHILD SHELL with npm ENVIRONMENT for $PWD..." && npm run env -- $SHELL || echo "ERROR: You must call this function from an npm package directory; child shell NOT entered." >&2' alias npmh='npm home' alias nr='npm run' alias ns='newscript' alias nsh='nesh -e <(coffee -bp ~/.nesh_profile.coffee)' alias nshc='nesh -c -e ~/.nesh_profile.coffee' alias nt='newtab' alias nw='newwin' alias nx='npm run-script env --' alias o='open' alias oa='open -a' alias oda='od -a' alias odx='od -t x1' alias omd='open -a '\''Marked 2'\''' alias osa='osascript' alias ou='openurl' alias oud='openurl -d' alias p='printf "%s\n"' alias p1='ping -c 1 -t 1' alias pd='perldoc' alias pf='declare -f' alias pg='"$HOME/Desktop/pg"/pg' alias pg.cpp='g++ -o "$HOME/Desktop/pg"/pgb "$HOME/Desktop/pg"/pg.cpp && "$HOME/Desktop/pg"/pgb' alias pg.cs='pushd "$HOME/Desktop/pg"/pg.cs >/dev/null && echo === NOTE: cwd is temporarily ./pg.cs === && dotnet run; popd >/dev/null' alias pg.html='"$HOME/Desktop/pg"/pg.html' alias pg.md='open -a Marked.app -- "$HOME/Desktop/pg"/pg.md' alias pg.ts='printf "Compiling to "$HOME/Desktop/pg"/pg.js (tsc) and invoking (node)..." && tsc "$HOME/Desktop/pg"/pg.ts && printf "\r%*s\r" 79 && node "$HOME/Desktop/pg"/pg.js' alias pg2='"$HOME/Desktop/pg"/pg2' alias pg4='"$HOME/Desktop/pg"/pg4' alias pgjxa.scpt='osascript -l JavaScript "$HOME/Desktop/pg"/pgjxa.scpt' alias phpg='"$HOME/Desktop/pg"/phpg' alias plb='/usr/libexec/PlistBuddy' alias plpg='"$HOME/Desktop/pg"/plpg' alias posh='powershell' alias ptc='pathToClipboard' alias py='python' alias py2='python' alias py3='python3' alias py3pg='"$HOME/Desktop/pg"/py3pg' alias pypg='"$HOME/Desktop/pg"/pypg' alias q='quote' alias rbn='shutdownnow -r' alias ri='{ echo "Reloading the initialization file (~/.bashrc)..."; . ~/.bashrc; }' alias rp='{ echo "Reloading the profile file (~/.bash_profile)..."; . ~/.bash_profile; }' alias rpg='"$HOME/Desktop/pg"/rpg' alias rsi='resizeimages' alias scb='tc' alias sdn='shutdownnow' alias shallpg='"$HOME/Desktop/pg"/shallpg' alias sho='vo' alias shpg='"$HOME/Desktop/pg"/shpg' alias sln='shutdownnow -s' alias st='steroids' alias tcl='rlwrap tclsh' alias tclpg='"$HOME/Desktop/pg"/tclpg' alias tkc='(tkcon &) && osascript <<<$'\''repeat while true\n delay 0.1\n if application "Wish" is running then\n try\n activate application "Wish"\n return\n end try\n end if\nend repeat'\''' alias toascii='iconv -f utf8 -t ascii -c' alias topc='top -l 2 -n 10 -o cpu -stats cpu,command | fgrep -v " top" | tail -n 10' alias tp='typex' alias ts='timestamps' alias ueh='enc -u --html' alias ueu='enc -u --uri' alias uex='enc -u --xml' alias uti='mdls -name kMDItemContentType' alias utis='mdls -name kMDItemContentTypeTree' alias vman='marked-man | cat >/tmp/vman$$ && man /tmp/vman$$' alias vmd='cat >/tmp/vmd$$ && open -a "Marked 2" /tmp/vmd$$' alias wh='which' alias wha='whichapp' alias xppg='"$HOME/Desktop/pg"/xppg' alias zpg='"$HOME/Desktop/pg"/zpg' declare -x Apple_PubSub_Socket_Render="/private/tmp/com.apple.launchd.ZSsLeK3KyX/Render" declare -- BASH="/usr/local/bin/bash4" declare -x CLICOLOR="" declare -x COLORFGBG="0;15" declare -x COLORTERM="truecolor" declare -- COLUMNS="220" declare -x COMP_WORDBREAKS="@ \"'><;|&(:" declare -x DISPLAY="/private/tmp/com.apple.launchd.WdrYFjwfT0/org.macosforge.xquartz:0" declare -x EDITOR="sublwait" declare -x FCEDIT="sublwait" declare -x GEM_HOME="/Users/jdoe/.rvm/gems/ruby-2.4.0" declare -x GEM_PATH="/Users/jdoe/.rvm/gems/ruby-2.4.0:/Users/jdoe/.rvm/gems/ruby-2.4.0@global" declare -i HISTCMD="1" declare -- HISTCONTROL="ignoredups" declare -- HISTFILE="/Users/jdoe/.bash_history" declare -- HISTFILESIZE="500" declare -- HISTSIZE="500" declare -x HOME="/Users/jdoe" declare -- HOSTNAME="MkiMac.home" declare -- HOSTTYPE="x86_64" declare -- IFS=" " declare -x IRBRC="/Users/jdoe/.rvm/rubies/ruby-2.4.0/.irbrc" declare -x ITERM_ORIG_PS1="\$( [ \"\$USER\" = 'root' ] && printf %s \\u:\\w || # sudo { { [ \"\$0\" = 'bash' ] || [ \"\$0\" = '/bin/bash' ] || [ \"\$0\" = '-bash' ]; } && { # bash _PS1 30 # cwd-shortening function if [[ -d .git ]]; then # git repos: show the branch name and, if there are uncommitted changes, append an asterisk printf ' [%s%s]' \"\$(git symbolic-ref --short HEAD 2>/dev/null || echo '(NO HEAD)')\" \"\$([[ -n \$(git status --porcelain) ]] && printf '\\[\\e[0;31m\\]*\\[\\e[0m\\]')\" fi } || printf \"[\$0] \$PWD\" # other shells; note that we can't use coloring in a cross-shell-compatible fashion } printf '\$ ' )" declare -- ITERM_PREEXEC_INTERACTIVE_MODE="" declare -x ITERM_PREV_PS1="\\[133;D;\$?1337;RemoteHost=jdoe@MkiMac.home1337;CurrentDir=/Users/jdoe/Desktop/pg133;A\\]\$( [ \"\$USER\" = 'root' ] && printf %s \\u:\\w || # sudo { { [ \"\$0\" = 'bash' ] || [ \"\$0\" = '/bin/bash' ] || [ \"\$0\" = '-bash' ]; } && { # bash _PS1 30 # cwd-shortening function if [[ -d .git ]]; then # git repos: show the branch name and, if there are uncommitted changes, append an asterisk printf ' [%s%s]' \"\$(git symbolic-ref --short HEAD 2>/dev/null || echo '(NO HEAD)')\" \"\$([[ -n \$(git status --porcelain) ]] && printf '\\[\\e[0;31m\\]*\\[\\e[0m\\]')\" fi } || printf \"[\$0] \$PWD\" # other shells; note that we can't use coloring in a cross-shell-compatible fashion } printf '\$ ' )\\[133;B\\]" declare -x ITERM_PROFILE="Default" declare -x ITERM_SESSION_ID="w0t0p0:F3C22F95-3FCF-4888-A3A1-D57093BD9C50" declare -- ITERM_SHELL_INTEGRATION_INSTALLED="Yes" declare -x LANG="en_US.UTF-8" declare -i LINENO="70" declare -- LINES="75" declare -x LOGNAME="jdoe" declare -- MACHTYPE="x86_64-apple-darwin16.3.0" declare -i MAILCHECK="60" declare -x MK_PLAYGROUND_FOLDER="/Users/jdoe/Desktop/pg" declare -x MK_UTIL_FOLDER="/Users/jdoe/MkUtil" declare -x MK_UTIL_FOLDER_PERSONAL="/Users/jdoe/MkUtil.Win/Users/jdoe" declare -x MY_RUBY_HOME="/Users/jdoe/.rvm/rubies/ruby-2.4.0" declare -x N_PREFIX="/Users/jdoe/n" declare -x OLDPWD="/Users/jdoe" declare -- OPTERR="1" declare -i OPTIND="1" declare -- OSTYPE="darwin16.3.0" declare -x PATH="/Users/jdoe/.rvm/gems/ruby-2.4.0/bin:/Users/jdoe/.rvm/gems/ruby-2.4.0@global/bin:/Users/jdoe/.rvm/rubies/ruby-2.4.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/jdoe/bin:/Users/jdoe/MkUtil:/Users/jdoe/.dotnet:/Users/jdoe/n/bin:/Users/jdoe/.rvm/bin" declare -- PROMPT_COMMAND="iterm2_preexec_invoke_cmd" declare -x PS1="\$( [ \"\$USER\" = 'root' ] && printf %s \\u:\\w || # sudo { { [ \"\$0\" = 'bash' ] || [ \"\$0\" = '/bin/bash' ] || [ \"\$0\" = '-bash' ]; } && { # bash _PS1 30 # cwd-shortening function if [[ -d .git ]]; then # git repos: show the branch name and, if there are uncommitted changes, append an asterisk printf ' [%s%s]' \"\$(git symbolic-ref --short HEAD 2>/dev/null || echo '(NO HEAD)')\" \"\$([[ -n \$(git status --porcelain) ]] && printf '\\[\\e[0;31m\\]*\\[\\e[0m\\]')\" fi } || printf \"[\$0] \$PWD\" # other shells; note that we can't use coloring in a cross-shell-compatible fashion } printf '\$ ' )" declare -- PS2="> " declare -- PS4="+ " declare -x PWD="/Users/jdoe/Desktop/pg" declare -i RANDOM="13804" declare -x RUBY_VERSION="ruby-2.4.0" declare -i SECONDS="91" declare -x SECURITYSESSIONID="186a7" declare -x SHELL="/bin/bash" declare -x SHLVL="2" declare -x SSH_AUTH_SOCK="/private/tmp/com.apple.launchd.QpR2TVefkw/Listeners" declare -x TERM="xterm" declare -x TERM_PROGRAM="iTerm.app" declare -x TERM_PROGRAM_VERSION="3.1.beta.3" declare -x TERM_SESSION_ID="w0t0p0:F3C22F95-3FCF-4888-A3A1-D57093BD9C50" declare -x TMPDIR="/var/folders/19/0lxcl7hd63d6fqd813glqppc0000gn/T/" declare -x USER="jdoe" declare -x XPC_FLAGS="0x0" declare -x XPC_SERVICE_NAME="0" declare -x __CF_USER_TEXT_ENCODING="0x1F5:0x0:0x0" declare -- __git_all_commands="" declare -- __git_diff_algorithms="myers minimal patience histogram" declare -- __git_diff_common_options="--stat --numstat --shortstat --summary --patch-with-stat --name-only --name-status --color --no-color --color-words --no-renames --check --full-index --binary --abbrev --diff-filter= --find-copies-harder --text --ignore-space-at-eol --ignore-space-change --ignore-all-space --ignore-blank-lines --exit-code --quiet --ext-diff --no-ext-diff --no-prefix --src-prefix= --dst-prefix= --inter-hunk-context= --patience --histogram --minimal --raw --word-diff --dirstat --dirstat= --dirstat-by-file --dirstat-by-file= --cumulative --diff-algorithm= " declare -- __git_fetch_options=" --quiet --verbose --append --upload-pack --force --keep --depth= --tags --no-tags --all --prune --dry-run --recurse-submodules= " declare -- __git_fetch_recurse_submodules="yes on-demand no" declare -- __git_flow_config_file_options=" --local --global --system --file= " declare -- __git_format_patch_options=" --stdout --attach --no-attach --thread --thread= --no-thread --numbered --start-number --numbered-files --keep-subject --signoff --signature --no-signature --in-reply-to= --cc= --full-index --binary --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix= --inline --suffix= --ignore-if-in-upstream --subject-prefix= --output-directory --reroll-count --to= --quiet --notes " declare -- __git_log_common_options=" --not --all --branches --tags --remotes --first-parent --merges --no-merges --max-count= --max-age= --since= --after= --min-age= --until= --before= --min-parents= --max-parents= --no-min-parents --no-max-parents " declare -- __git_log_date_formats="relative iso8601 rfc2822 short local default raw" declare -- __git_log_gitk_options=" --dense --sparse --full-history --simplify-merges --simplify-by-decoration --left-right --notes --no-notes " declare -- __git_log_pretty_formats="oneline short medium full fuller email raw format:" declare -- __git_log_shortlog_options=" --author= --committer= --grep= --all-match " declare -- __git_merge_options=" --no-commit --no-stat --log --no-log --squash --strategy --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit --verify-signatures --no-verify-signatures --gpg-sign --quiet --verbose --progress --no-progress " declare -- __git_merge_strategies="" declare -- __git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc3 codecompare " declare -- __git_porcelain_commands="" declare -- __git_push_recurse_submodules="check on-demand" declare -- __git_send_email_confirm_options="always never auto cc compose" declare -- __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all" declare -- __git_whitespacelist="nowarn warn error error-all fix" declare -- __typex_scriptpath="/Users/jdoe/n/bin/typex" declare -- _grep_REGEXP="(.*)" declare -- _ignore_UNDERSCORE="" declare -- _list_alias_BODIES="alias ash bi bv cdb cpg dec dn dpg dt e ecc ecpg edpg eh ei ejaypg ekpg enp enpg ep epg epg.cpp epg.cs epg.html epg.md epg.ts epg2 epg4 epgjxa.scpt ephpg epi eplpg epy3pg epypg eqcd erpg es eshallpg eshpg etclpg eu ex exppg ezpg fhx fp fq fx gc gcb gcm gfs gl gs gt gvr hd hg imgcat imgls it2attention it2check it2copy it2dl it2getvar it2setcolor it2setkeylabel it2ul it2universion jaypg josa kbs kpg lf lfe lsregister lsx lv lve lx m md mdp mg mmdp mo mu mw ne np npg npmenv npmh nr ns nsh nshc nt nw nx o oa oda odx omd osa ou oud p p1 pd pf pg pg.cpp pg.cs pg.html pg.md pg.ts pg2 pg4 pgjxa.scpt phpg plb plpg posh ptc py py2 py3 py3pg pypg q rbn ri rp rpg rsi scb sdn shallpg sho shpg sln st tcl tclpg tkc toascii topc tp ts ueh ueu uex uti utis vman vmd wh wha xppg zpg" declare -- _list_function_BODIES="typeset -f = =awk =gawk =mawk =perl _PS1 __git_aliased_command __git_aliases __git_commands __git_complete __git_complete_file __git_complete_force_with_lease __git_complete_index_file __git_complete_remote_or_refspec __git_complete_revlist __git_complete_revlist_file __git_complete_strategy __git_compute_all_commands __git_compute_merge_strategies __git_compute_porcelain_commands __git_config_get_set_variables __git_count_arguments __git_find_on_cmdline __git_flow_config __git_flow_feature __git_flow_hotfix __git_flow_init __git_flow_list_branches __git_flow_list_local_branches __git_flow_list_remote_branches __git_flow_prefix __git_flow_release __git_flow_support __git_func_wrap __git_has_doubledash __git_heads __git_index_files __git_list_all_commands __git_list_merge_strategies __git_list_porcelain_commands __git_ls_files_helper __git_main __git_match_ctag __git_pretty_aliases __git_reassemble_comp_words_by_ref __git_refs __git_refs2 __git_refs_remotes __git_remotes __git_tags __git_wrap__git_main __git_wrap__gitk_main __gitcomp __gitcomp_file __gitcomp_nl __gitcomp_nl_append __gitcompadd __gitcompappend __gitdir __gitk_main __typex_isParentSupportedShell __typex_isSupportedShell _complete_edits _complete_lx _complete_make _complete_pf _complete_pv _complete_unset _complete_up _get_comp_words_by_ref _git _git_add _git_am _git_apply _git_archive _git_bisect _git_branch _git_bundle _git_checkout _git_cherry _git_cherry_pick _git_clean _git_clone _git_commit _git_config _git_describe _git_diff _git_difftool _git_fetch _git_flow _git_format_patch _git_fsck _git_gc _git_gitk _git_grep _git_help _git_init _git_log _git_ls_files _git_ls_remote _git_ls_tree _git_merge _git_merge_base _git_mergetool _git_mv _git_name_rev _git_notes _git_pull _git_push _git_rebase _git_reflog _git_remote _git_replace _git_reset _git_revert _git_rm _git_send_email _git_shortlog _git_show _git_show_branch _git_stage _git_stash _git_submodule _git_svn _git_tag _git_whatchanged _gitk _npm_completion _tobase af brm calc cdp de dfs difs doIt docker-start docker-stop dsh ec env_parallel f fa fag fas fasu fau fawf fawfc fawfd fawfp fcfg fcu fd fdb fdbp fdl fdla fdt feb febi febo ff fh fhomer fic fif findexes findq fkkac fkkai fl fla flau flsys flu fngb fngm fobt foldIndent foss fpg fpgw fph fppg fpr fpref fprefu fql fqlu fs fsba fsd fsl fslu fsn fsph fss fstp fstpu fsu fsv fsvms ft ftr ftu fu fub fuc fulb fullpath fus fuw fvms fwac getip getips installnode iterm2_begin_osc iterm2_end_osc iterm2_preexec_install iterm2_preexec_invoke_cmd iterm2_preexec_invoke_exec iterm2_print_state_data iterm2_print_user_vars iterm2_print_version_number iterm2_prompt_mark iterm2_prompt_prefix iterm2_prompt_suffix iterm2_set_user_var kill-script list-available-locales lock lsp mang manx manxg mkcd mktempfile npmf npml pathToClipboard pbpaste_html pbpaste_rtf pifs precmd preexec pushdX pv ql resetcolors resume-script sl stripColors stripFormatting suspend-script tc tobin todec tohex tooct trim typex up vmrun vo" declare -x _system_arch="x86_64" declare -x _system_name="OSX" declare -x _system_type="Darwin" declare -x _system_version="10.12" declare -- hist_ent=" 502 . pg; doIt() { echo \"\$\$: [\$*]\"; }; { echo hi; echo there; echo you; echo too; } | env_parallel -n 1 -j 12 doIt {} 2>&1 | vo" declare -- iterm2_hostname="MkiMac.home" declare -- iterm2_ran_preexec="yes" declare -- last_hist_ent=" 502 . pg; doIt() { echo \"\$\$: [\$*]\"; }; { echo hi; echo there; echo you; echo too; } | env_parallel -n 1 -j 12 doIt {} 2>&1 | vo" declare -x rvm_bin_path="/Users/jdoe/.rvm/bin" declare -x rvm_path="/Users/jdoe/.rvm" declare -x rvm_prefix="/Users/jdoe" declare -x rvm_version="1.29.1 (latest)" = () { =perl "$@" } =awk () { local awkBin=${FUNCNAME[1]}; awkBin=${awkBin:-$FUNCNAME}; awkBin=${awkBin#=}; $awkBin "BEGIN { print $* }" } =gawk () { =awk "$@" } =mawk () { =awk "$@" } =perl () { [[ $1 == '-h' || $1 == '--help' ]] && { echo 'Simple command-line calcuations using Perl - the expression specfied is passed as-is to Perl'\''s `print`. Examples: =perl 0x41 =perl 2**10'; return 0 }; perl -le "print $*" } _PS1 () { local pre= name="$PWD" length="$1"; if (( length > 0 )); then [[ "$name" != "${name#$HOME/}" || -z "${name#$HOME}" ]] && pre+='~' name="${name#$HOME}" length=$[length-1]; ((${#name}>$length)) && name="/...${name:$[${#name}-length+4]}"; fi; printf '%s' "$pre$name" } __git_aliased_command () { local word cmdline=$(git --git-dir="$(__gitdir)" config --get "alias.$1"); for word in $cmdline; do case "$word" in \!gitk | gitk) echo "gitk"; return ;; \!*) : shell command alias ;; -*) : option ;; *=*) : setting env ;; git) : git itself ;; \(\)) : skip parens of shell function definition ;; {) : skip start of shell helper function ;; :) : skip null command ;; \'*) : skip opening quote after sh -c ;; *) echo "$word"; return ;; esac; done } __git_aliases () { local i IFS=' '; for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do case "$i" in alias.*) i="${i#alias.}"; echo "${i/ */}" ;; esac; done } __git_commands () { if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}"; then printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"; else git help -a | egrep '^ [a-zA-Z0-9]'; fi } __git_complete () { local wrapper="__git_wrap${2}"; eval "$wrapper () { __git_func_wrap $2 ; }"; complete -o bashdefault -o default -o nospace -F $wrapper $1 2> /dev/null || complete -o default -o nospace -F $wrapper $1 } __git_complete_file () { __git_complete_revlist_file } __git_complete_force_with_lease () { local cur_=$1; case "$cur_" in --*=) ;; *:*) __gitcomp_nl "$(__git_refs)" "" "${cur_#*:}" ;; *) __gitcomp_nl "$(__git_refs)" "" "$cur_" ;; esac } __git_complete_index_file () { local pfx="" cur_="$cur"; case "$cur_" in ?*/*) pfx="${cur_%/*}"; cur_="${cur_##*/}"; pfx="${pfx}/" ;; esac; __gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_" } __git_complete_remote_or_refspec () { local cur_="$cur" cmd="${words[1]}"; local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0; if [ "$cmd" = "remote" ]; then ((c++)); fi; while [ $c -lt $cword ]; do i="${words[c]}"; case "$i" in --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;; --all) case "$cmd" in push) no_complete_refspec=1 ;; fetch) return ;; *) ;; esac ;; -*) ;; *) remote="$i"; break ;; esac; ((c++)); done; if [ -z "$remote" ]; then __gitcomp_nl "$(__git_remotes)"; return; fi; if [ $no_complete_refspec = 1 ]; then return; fi; [ "$remote" = "." ] && remote=; case "$cur_" in *:*) case "$COMP_WORDBREAKS" in *:*) : great ;; *) pfx="${cur_%%:*}:" ;; esac; cur_="${cur_#*:}"; lhs=0 ;; +*) pfx="+"; cur_="${cur_#+}" ;; esac; case "$cmd" in fetch) if [ $lhs = 1 ]; then __gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"; else __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"; fi ;; pull | remote) if [ $lhs = 1 ]; then __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"; else __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"; fi ;; push) if [ $lhs = 1 ]; then __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"; else __gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"; fi ;; esac } __git_complete_revlist () { __git_complete_revlist_file } __git_complete_revlist_file () { local pfx ls ref cur_="$cur"; case "$cur_" in *..?*:*) return ;; ?*:*) ref="${cur_%%:*}"; cur_="${cur_#*:}"; case "$cur_" in ?*/*) pfx="${cur_%/*}"; cur_="${cur_##*/}"; ls="$ref:$pfx"; pfx="$pfx/" ;; *) ls="$ref" ;; esac; case "$COMP_WORDBREAKS" in *:*) : great ;; *) pfx="$ref:$pfx" ;; esac; __gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" 2>/dev/null | sed '/^100... blob /{ s,^.* ,, s,$, , } /^120000 blob /{ s,^.* ,, s,$, , } /^040000 tree /{ s,^.* ,, s,$,/, } s/^.* //')" "$pfx" "$cur_" "" ;; *...*) pfx="${cur_%...*}..."; cur_="${cur_#*...}"; __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" ;; *..*) pfx="${cur_%..*}.."; cur_="${cur_#*..}"; __gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" ;; *) __gitcomp_nl "$(__git_refs)" ;; esac } __git_complete_strategy () { __git_compute_merge_strategies; case "$prev" in -s | --strategy) __gitcomp "$__git_merge_strategies"; return 0 ;; esac; case "$cur" in --strategy=*) __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"; return 0 ;; esac; return 1 } __git_compute_all_commands () { test -n "$__git_all_commands" || __git_all_commands=$(__git_list_all_commands) } __git_compute_merge_strategies () { test -n "$__git_merge_strategies" || __git_merge_strategies=$(__git_list_merge_strategies) } __git_compute_porcelain_commands () { __git_compute_all_commands; test -n "$__git_porcelain_commands" || __git_porcelain_commands=$(__git_list_porcelain_commands) } __git_config_get_set_variables () { local prevword word config_file= c=$cword; while [ $c -gt 1 ]; do word="${words[c]}"; case "$word" in --system | --global | --local | --file=*) config_file="$word"; break ;; -f | --file) config_file="$word $prevword"; break ;; esac; prevword=$word; c=$((--c)); done; git --git-dir="$(__gitdir)" config $config_file --list 2> /dev/null | while read -r line; do case "$line" in *.*=*) echo "${line/=*/}" ;; esac; done } __git_count_arguments () { local word i c=0; for ((i=1; i < ${#words[@]}; i++)) do word="${words[i]}"; case "$word" in --) ((c = 0)) ;; "$1") ((c = 0)) ;; ?*) ((c++)) ;; esac; done; printf "%d" $c } __git_find_on_cmdline () { local word subcommand c=1; while [ $c -lt $cword ]; do word="${words[c]}"; for subcommand in $1; do if [ "$subcommand" = "$word" ]; then echo "$subcommand"; return; fi; done; ((c++)); done } __git_flow_config () { local subcommands="list set base"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in set) case "$cur" in --*) __gitcomp " $__git_flow_config_file_options "; return ;; esac; __gitcomp " master develop feature hotfix release support versiontagprefix "; return ;; base) case "$cur" in --*) __gitcomp " set get "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches)"; return ;; *) COMPREPLY=() ;; esac } __git_flow_feature () { local subcommands="list start finish publish track diff rebase checkout pull help delete"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in pull) __gitcomp_nl "$(__git_remotes)"; return ;; checkout) __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; delete) case "$cur" in --*) __gitcomp " --noforce --force --noremote --remote "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; finish) case "$cur" in --*) __gitcomp " --nofetch --fetch --norebase --rebase --nopreserve-merges --preserve-merges --nokeep --keep --keepremote --keeplocal --noforce_delete --force_delete --nosquash --squash --no-ff "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; diff) __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'feature')"; return ;; publish) __gitcomp_nl "$(__git_flow_list_branches 'feature')"; return ;; track) __gitcomp_nl "$(__git_flow_list_branches 'feature')"; return ;; *) COMPREPLY=() ;; esac } __git_flow_hotfix () { local subcommands="list start finish track publish help delete"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in finish) case "$cur" in --*) __gitcomp " --nofetch --fetch --sign --signingkey --message --nomessagefile --messagefile= --nopush --push --nokeep --keep --keepremote --keeplocal --noforce_delete --force_delete --notag --tag --nonobackmerge --nobackmerge "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"; return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"; return ;; delete) case "$cur" in --*) __gitcomp " --noforce --force --noremote --remote "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"; return ;; publish) __gitcomp_nl "$(__git_flow_list_branches 'hotfix')"; return ;; track) __gitcomp_nl "$(__git_flow_list_branches 'hotfix')"; return ;; start) case "$cur" in --*) __gitcomp " --nofetch --fetch "; return ;; esac; return ;; *) COMPREPLY=() ;; esac } __git_flow_init () { local subcommands="help"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; fi; case "$cur" in --*) __gitcomp " --nodefaults --defaults --noforce --force $__git_flow_config_file_options "; return ;; esac } __git_flow_list_branches () { local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"; if [ -n "$1" ]; then local prefix="$(__git_flow_prefix $1)"; git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix | while read -r entry; do eval "$entry"; ref="${ref##$prefix}"; echo "$ref"; done | sort; else git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort; fi } __git_flow_list_local_branches () { if [ -n "$1" ]; then local prefix="$(__git_flow_prefix $1)"; git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix | while read -r entry; do eval "$entry"; ref="${ref#$prefix}"; echo "$ref"; done | sort; else git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort; fi } __git_flow_list_remote_branches () { local prefix="$(__git_flow_prefix $1)"; local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"; git for-each-ref --shell --format='%(refname:short)' refs/remotes/$origin/$prefix | while read -r entry; do eval "$entry"; ref="${ref##$prefix}"; echo "$ref"; done | sort } __git_flow_prefix () { case "$1" in feature | release | hotfix | support) git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/"; return ;; esac } __git_flow_release () { local subcommands="list start finish track publish help delete"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in finish) case "$cur" in --*) __gitcomp " --nofetch --fetch --sign --signingkey --message --nomessagefile --messagefile= --nopush --push --nokeep --keep --keepremote --keeplocal --noforce_delete --force_delete --notag --tag --nonobackmerge --nobackmerge --nosquash --squash "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'release')"; return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'release')"; return ;; delete) case "$cur" in --*) __gitcomp " --noforce --force --noremote --remote "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'release')"; return ;; publish) __gitcomp_nl "$(__git_flow_list_branches 'release')"; return ;; track) __gitcomp_nl "$(__git_flow_list_branches 'release')"; return ;; start) case "$cur" in --*) __gitcomp " --nofetch --fetch "; return ;; esac; return ;; *) COMPREPLY=() ;; esac } __git_flow_support () { local subcommands="list start help"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in start) case "$cur" in --*) __gitcomp " --nofetch --fetch "; return ;; esac; return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges "; return ;; esac; __gitcomp_nl "$(__git_flow_list_local_branches 'support')"; return ;; *) COMPREPLY=() ;; esac } __git_func_wrap () { local cur words cword prev; _get_comp_words_by_ref -n =: cur words cword prev; $1 } __git_has_doubledash () { local c=1; while [ $c -lt $cword ]; do if [ "--" = "${words[c]}" ]; then return 0; fi; ((c++)); done; return 1 } __git_heads () { local dir="$(__gitdir)"; if [ -d "$dir" ]; then git --git-dir="$dir" for-each-ref --format='%(refname:short)' refs/heads; return; fi } __git_index_files () { local dir="$(__gitdir)" root="${2-.}" file; if [ -d "$dir" ]; then __git_ls_files_helper "$root" "$1" | while read -r file; do case "$file" in ?*/*) echo "${file%%/*}" ;; *) echo "$file" ;; esac; done | sort | uniq; fi } __git_list_all_commands () { local i IFS=" "' '; for i in $(__git_commands); do case $i in *--*) : helper pattern ;; *) echo $i ;; esac; done } __git_list_merge_strategies () { git merge -s help 2>&1 | sed -n -e '/[Aa]vailable strategies are: /,/^$/{ s/\.$// s/.*:// s/^[ ]*// s/[ ]*$// p }' } __git_list_porcelain_commands () { local i IFS=" "' '; __git_compute_all_commands; for i in $__git_all_commands; do case $i in *--*) : helper pattern ;; applymbox) : ask gittus ;; applypatch) : ask gittus ;; archimport) : import ;; cat-file) : plumbing ;; check-attr) : plumbing ;; check-ignore) : plumbing ;; check-mailmap) : plumbing ;; check-ref-format) : plumbing ;; checkout-index) : plumbing ;; commit-tree) : plumbing ;; count-objects) : infrequent ;; credential-cache) : credentials helper ;; credential-store) : credentials helper ;; cvsexportcommit) : export ;; cvsimport) : import ;; cvsserver) : daemon ;; daemon) : daemon ;; diff-files) : plumbing ;; diff-index) : plumbing ;; diff-tree) : plumbing ;; fast-import) : import ;; fast-export) : export ;; fsck-objects) : plumbing ;; fetch-pack) : plumbing ;; fmt-merge-msg) : plumbing ;; for-each-ref) : plumbing ;; hash-object) : plumbing ;; http-*) : transport ;; index-pack) : plumbing ;; init-db) : deprecated ;; local-fetch) : plumbing ;; ls-files) : plumbing ;; ls-remote) : plumbing ;; ls-tree) : plumbing ;; mailinfo) : plumbing ;; mailsplit) : plumbing ;; merge-*) : plumbing ;; mktree) : plumbing ;; mktag) : plumbing ;; pack-objects) : plumbing ;; pack-redundant) : plumbing ;; pack-refs) : plumbing ;; parse-remote) : plumbing ;; patch-id) : plumbing ;; prune) : plumbing ;; prune-packed) : plumbing ;; quiltimport) : import ;; read-tree) : plumbing ;; receive-pack) : plumbing ;; remote-*) : transport ;; rerere) : plumbing ;; rev-list) : plumbing ;; rev-parse) : plumbing ;; runstatus) : plumbing ;; sh-setup) : internal ;; shell) : daemon ;; show-ref) : plumbing ;; send-pack) : plumbing ;; show-index) : plumbing ;; ssh-*) : transport ;; stripspace) : plumbing ;; symbolic-ref) : plumbing ;; unpack-file) : plumbing ;; unpack-objects) : plumbing ;; update-index) : plumbing ;; update-ref) : plumbing ;; update-server-info) : daemon ;; upload-archive) : plumbing ;; upload-pack) : plumbing ;; write-tree) : plumbing ;; var) : infrequent ;; verify-pack) : infrequent ;; verify-tag) : plumbing ;; *) echo $i ;; esac; done } __git_ls_files_helper () { ( test -n "${CDPATH+set}" && unset CDPATH; cd "$1"; if [ "$2" == "--committable" ]; then git diff-index --name-only --relative HEAD; else git ls-files --exclude-standard $2; fi ) 2> /dev/null } __git_main () { local i c=1 command __git_dir; while [ $c -lt $cword ]; do i="${words[c]}"; case "$i" in --git-dir=*) __git_dir="${i#--git-dir=}" ;; --git-dir) ((c++)); __git_dir="${words[c]}" ;; --bare) __git_dir="." ;; --help) command="help"; break ;; -c | --work-tree | --namespace) ((c++)) ;; -*) ;; *) command="$i"; break ;; esac; ((c++)); done; if [ -z "$command" ]; then case "$cur" in --*) __gitcomp " --paginate --no-pager --git-dir= --bare --version --exec-path --exec-path= --html-path --man-path --info-path --work-tree= --namespace= --no-replace-objects --help " ;; *) __git_compute_porcelain_commands; __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;; esac; return; fi; local completion_func="_git_${command//-/_}"; declare -f $completion_func > /dev/null && $completion_func && return; local expansion=$(__git_aliased_command "$command"); if [ -n "$expansion" ]; then words[1]=$expansion; completion_func="_git_${expansion//-/_}"; declare -f $completion_func > /dev/null && $completion_func; fi } __git_match_ctag () { awk "/^${1////\\/}/ { print \$1 }" "$2" } __git_pretty_aliases () { local i IFS=' '; for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do case "$i" in pretty.*) i="${i#pretty.}"; echo "${i/ */}" ;; esac; done } __git_reassemble_comp_words_by_ref () { local exclude i j first; exclude="${1//[^$COMP_WORDBREAKS]}"; cword_=$COMP_CWORD; if [ -z "$exclude" ]; then words_=("${COMP_WORDS[@]}"); return; fi; for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)) do first=t; while [ $i -gt 0 ] && [ -n "${COMP_WORDS[$i]}" ] && [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]; do if [ $j -ge 2 ] && [ -n "$first" ]; then ((j--)); fi; first=; words_[$j]=${words_[j]}${COMP_WORDS[i]}; if [ $i = $COMP_CWORD ]; then cword_=$j; fi; if (($i < ${#COMP_WORDS[@]} - 1)); then ((i++)); else return; fi; done; words_[$j]=${words_[j]}${COMP_WORDS[i]}; if [ $i = $COMP_CWORD ]; then cword_=$j; fi; done } __git_refs () { local i hash dir="$(__gitdir "${1-}")" track="${2-}"; local format refs; if [ -d "$dir" ]; then case "$cur" in refs | refs/*) format="refname"; refs="${cur%/*}"; track="" ;; *) for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do if [ -e "$dir/$i" ]; then echo $i; fi; done; format="refname:short"; refs="refs/tags refs/heads refs/remotes" ;; esac; git --git-dir="$dir" for-each-ref --format="%($format)" $refs; if [ -n "$track" ]; then local ref entry; git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" "refs/remotes/" | while read -r entry; do eval "$entry"; ref="${ref#*/}"; if [[ "$ref" == "$cur"* ]]; then echo "$ref"; fi; done | sort | uniq -u; fi; return; fi; case "$cur" in refs | refs/*) git ls-remote "$dir" "$cur*" 2> /dev/null | while read -r hash i; do case "$i" in *^{}) ;; *) echo "$i" ;; esac; done ;; *) echo "HEAD"; git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##" ;; esac } __git_refs2 () { local i; for i in $(__git_refs "$1"); do echo "$i:$i"; done } __git_refs_remotes () { local i hash; git ls-remote "$1" 'refs/heads/*' 2> /dev/null | while read -r hash i; do echo "$i:refs/remotes/$1/${i#refs/heads/}"; done } __git_remotes () { local i IFS=' ' d="$(__gitdir)"; test -d "$d/remotes" && ls -1 "$d/remotes"; for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do i="${i#remote.}"; echo "${i/.url*/}"; done } __git_tags () { local dir="$(__gitdir)"; if [ -d "$dir" ]; then git --git-dir="$dir" for-each-ref --format='%(refname:short)' refs/tags; return; fi } __git_wrap__git_main () { __git_func_wrap __git_main } __git_wrap__gitk_main () { __git_func_wrap __gitk_main } __gitcomp () { local cur_="${3-$cur}"; case "$cur_" in --*=) ;; *) local c i=0 IFS=' '; for c in $1; do c="$c${4-}"; if [[ $c == "$cur_"* ]]; then case $c in --*=* | *.) ;; *) c="$c " ;; esac; COMPREPLY[i++]="${2-}$c"; fi; done ;; esac } __gitcomp_file () { local IFS=' '; __gitcompadd "$1" "${2-}" "${3-$cur}" ""; compopt -o filenames +o nospace 2> /dev/null || compgen -f /non-existing-dir/ > /dev/null } __gitcomp_nl () { COMPREPLY=(); __gitcomp_nl_append "$@" } __gitcomp_nl_append () { local IFS=' '; __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }" } __gitcompadd () { COMPREPLY=(); __gitcompappend "$@" } __gitcompappend () { local i=${#COMPREPLY[@]}; for x in $1; do if [[ "$x" == "$3"* ]]; then COMPREPLY[i++]="$2$x$4"; fi; done } __gitdir () { if [ -z "${1-}" ]; then if [ -n "${__git_dir-}" ]; then echo "$__git_dir"; else if [ -n "${GIT_DIR-}" ]; then test -d "${GIT_DIR-}" || return 1; echo "$GIT_DIR"; else if [ -d .git ]; then echo .git; else git rev-parse --git-dir 2> /dev/null; fi; fi; fi; else if [ -d "$1/.git" ]; then echo "$1/.git"; else echo "$1"; fi; fi } __gitk_main () { __git_has_doubledash && return; local g="$(__gitdir)"; local merge=""; if [ -f "$g/MERGE_HEAD" ]; then merge="--merge"; fi; case "$cur" in --*) __gitcomp " $__git_log_common_options $__git_log_gitk_options $merge "; return ;; esac; __git_complete_revlist } __typex_isParentSupportedShell () { case "$(command basename -- "$(command ps -o comm= $PPID | command sed 's/^-//')")" in bash | ksh | zsh) return 0 ;; esac; return 1 } __typex_isSupportedShell () { [ -n "$BASH_VERSION" ] && return 0; [ -n "$KSH_VERSION" ] && return 0; [ -n "$ZSH_VERSION" ] && return 0; return 1 } _complete_edits () { local util utils; local token=${COMP_WORDS[$COMP_CWORD]}; local tokenLen=${#token}; if [[ $(uname) == 'Darwin' ]]; then IFS=' ' read -d '' -ra utils < <(find "$MK_UTIL_FOLDER" "$MK_UTIL_FOLDER/sourced.d" -type f -perm -a=x -exec basename -a {} +); else IFS=' ' read -d '' -ra utils < <(find "$MK_UTIL_FOLDER" "$MK_UTIL_FOLDER/sourced.d" -type f -perm -a=x -printf '%f\n'); fi; local nocasematchWasOff=0; shopt nocasematch > /dev/null || nocasematchWasOff=1; (( nocasematchWasOff )) && shopt -s nocasematch; COMPREPLY=(); for util in "${utils[@]}"; do if [[ ${util:0:$(( tokenLen ))} == "$token" ]]; then COMPREPLY+=("$(printf '%q' "$util")"); fi; done; (( nocasematchWasOff )) && shopt -u nocasematch } _complete_lx () { local localExeDir='.'; local token=${COMP_WORDS[$COMP_CWORD]}; local tokenLen=${#token}; if [[ $(uname) == 'Darwin' ]]; then IFS=' ' read -d '' -ra localExes < <(find "$localExeDir" -maxdepth 1 -type f -perm -a=x -exec basename -a {} +); else IFS=' ' read -d '' -ra localExes < <(find "$localExeDir" -maxdepth 1 -type f -executable -printf '%f\n'); fi; local nocasematchWasOff=0; shopt nocasematch > /dev/null || nocasematchWasOff=1; (( nocasematchWasOff )) && shopt -s nocasematch; COMPREPLY=(); for localExe in "${localExes[@]}"; do if [[ ${localExe:0:$(( tokenLen ))} == "$token" ]]; then COMPREPLY+=("$(printf '%q' "$localExe")"); fi; done; (( nocasematchWasOff )) && shopt -u nocasematch } _complete_make () { local token=${COMP_WORDS[$COMP_CWORD]}; local targets=$(make -pRrq : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($1 !~ "^[#.]") {print $1}}' | egrep -v '^[^[:alnum:]]' | sort | xargs); COMPREPLY=($(compgen -W "$targets" -- "$token")) } _complete_pf () { COMPREPLY=($(compgen -A function -- "${COMP_WORDS[$COMP_CWORD]}")) } _complete_pv () { local varNames=$(compgen -v); local token=${COMP_WORDS[$COMP_CWORD]}; local mustReset=$(shopt -q nocasematch; echo $?); shopt -s nocasematch; [[ "${token:0:1}" == '$' ]] && token=${token:1}; local matches w; matches=(); if [[ -n $token ]]; then for w in $varNames; do if [[ "$w" == "$token"* ]]; then matches+=("$w"); fi; done; else matches=($varNames); fi; (( mustReset )) && shopt -u nocasematch; COMPREPLY=("${matches[@]}") } _complete_unset () { local token=${COMP_WORDS[$COMP_CWORD]}; local funcAndVarNames=$(compgen -A function; compgen -A variable); local mustReset=$(shopt -q nocasematch; echo $?); shopt -s nocasematch; [[ "${token:0:1}" == '$' ]] && token=${token:1}; local matches w; matches=(); if [[ -n $token ]]; then for w in $funcAndVarNames; do if [[ "$w" == "$token"* ]]; then matches+=("$w"); fi; done; else matches=($funcAndVarNames); fi; (( mustReset )) && shopt -u nocasematch; COMPREPLY=("${matches[@]}") } _complete_up () { COMPREPLY=(); local curToken=${COMP_WORDS[COMP_CWORD]}; curToken=${curToken//'\'}; if [[ $curToken =~ ^/ ]]; then local IFS=' '; COMPREPLY=($(compgen -o dirnames -- "$curToken")); else if [[ $curToken =~ ^[0-9]+/? ]]; then local strpath=$( printf "%${curToken%%/*}s" ); local upDirSpec=${strpath// /../}; local dir=$(cd "$upDirSpec"; echo -n "$PWD/"); if [[ "$dir" == '//' ]]; then dir='/'; fi; COMPREPLY=("$dir"); else local caseInsensitive=0; bind -v | egrep -i '\bcompletion-ignore-case[[:space:]]+on\b' &> /dev/null && caseInsensitive=1; local nocasematchWasOff=0; if (( caseInsensitive )); then nocasematchWasOff=1; shopt nocasematch > /dev/null && nocasematchWasOff=0; (( nocasematchWasOff )) && shopt -s nocasematch > /dev/null; fi; local pathSoFar=''; local matchingPath=''; local parentPath=${PWD%/*}; local IFS='/'; local name; for name in ${parentPath:1}; do pathSoFar+=/$name; if [[ "$name" == "$curToken"* ]]; then matchingPath="$pathSoFar/"; fi; done; (( caseInsensitive && nocasematchWasOff )) && shopt -u nocasematch > /dev/null; [[ -n "$matchingPath" ]] && COMPREPLY=("$matchingPath"); fi; fi } _get_comp_words_by_ref () { local exclude cur_ words_ cword_; if [ "$1" = "-n" ]; then exclude=$2; shift 2; fi; __git_reassemble_comp_words_by_ref "$exclude"; cur_=${words_[cword_]}; while [ $# -gt 0 ]; do case "$1" in cur) cur=$cur_ ;; prev) prev=${words_[$cword_-1]} ;; words) words=("${words_[@]}") ;; cword) cword=$cword_ ;; esac; shift; done } _git () { __git_wrap__git_main } _git_add () { case "$cur" in --*) __gitcomp " --interactive --refresh --patch --update --dry-run --ignore-errors --intent-to-add "; return ;; esac; __git_complete_index_file "--others --modified --directory --no-empty-directory" } _git_am () { local dir="$(__gitdir)"; if [ -d "$dir"/rebase-apply ]; then __gitcomp "--skip --continue --resolved --abort"; return; fi; case "$cur" in --whitespace=*) __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"; return ;; --*) __gitcomp " --3way --committer-date-is-author-date --ignore-date --ignore-whitespace --ignore-space-change --interactive --keep --no-utf8 --signoff --utf8 --whitespace= --scissors "; return ;; esac } _git_apply () { case "$cur" in --whitespace=*) __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"; return ;; --*) __gitcomp " --stat --numstat --summary --check --index --cached --index-info --reverse --reject --unidiff-zero --apply --no-add --exclude= --ignore-whitespace --ignore-space-change --whitespace= --inaccurate-eof --verbose "; return ;; esac } _git_archive () { case "$cur" in --format=*) __gitcomp "$(git archive --list)" "" "${cur##--format=}"; return ;; --remote=*) __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"; return ;; --*) __gitcomp " --format= --list --verbose --prefix= --remote= --exec= "; return ;; esac; __git_complete_file } _git_bisect () { __git_has_doubledash && return; local subcommands="start bad good skip reset visualize replay log run"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then if [ -f "$(__gitdir)"/BISECT_START ]; then __gitcomp "$subcommands"; else __gitcomp "replay start"; fi; return; fi; case "$subcommand" in bad | good | reset | skip | start) __gitcomp_nl "$(__git_refs)" ;; *) ;; esac } _git_branch () { local i c=1 only_local_ref="n" has_r="n"; while [ $c -lt $cword ]; do i="${words[c]}"; case "$i" in -d | -m) only_local_ref="y" ;; -r) has_r="y" ;; esac; ((c++)); done; case "$cur" in --set-upstream-to=*) __gitcomp "$(__git_refs)" "" "${cur##--set-upstream-to=}" ;; --*) __gitcomp " --color --no-color --verbose --abbrev= --no-abbrev --track --no-track --contains --merged --no-merged --set-upstream-to= --edit-description --list --unset-upstream " ;; *) if [ $only_local_ref = "y" -a $has_r = "n" ]; then __gitcomp_nl "$(__git_heads)"; else __gitcomp_nl "$(__git_refs)"; fi ;; esac } _git_bundle () { local cmd="${words[2]}"; case "$cword" in 2) __gitcomp "create list-heads verify unbundle" ;; 3) ;; *) case "$cmd" in create) __git_complete_revlist ;; esac ;; esac } _git_checkout () { __git_has_doubledash && return; case "$cur" in --conflict=*) __gitcomp "diff3 merge" "" "${cur##--conflict=}" ;; --*) __gitcomp " --quiet --ours --theirs --track --no-track --merge --conflict= --orphan --patch " ;; *) local flags="--track --no-track --no-guess" track=1; if [ -n "$(__git_find_on_cmdline "$flags")" ]; then track=''; fi; __gitcomp_nl "$(__git_refs '' $track)" ;; esac } _git_cherry () { __gitcomp "$(__git_refs)" } _git_cherry_pick () { local dir="$(__gitdir)"; if [ -f "$dir"/CHERRY_PICK_HEAD ]; then __gitcomp "--continue --quit --abort"; return; fi; case "$cur" in --*) __gitcomp "--edit --no-commit --signoff --strategy= --mainline" ;; *) __gitcomp_nl "$(__git_refs)" ;; esac } _git_clean () { case "$cur" in --*) __gitcomp "--dry-run --quiet"; return ;; esac; __git_complete_index_file "--others --directory" } _git_clone () { case "$cur" in --*) __gitcomp " --local --no-hardlinks --shared --reference --quiet --no-checkout --bare --mirror --origin --upload-pack --template= --depth --single-branch --branch "; return ;; esac } _git_commit () { case "$prev" in -c | -C) __gitcomp_nl "$(__git_refs)" "" "${cur}"; return ;; esac; case "$cur" in --cleanup=*) __gitcomp "default strip verbatim whitespace " "" "${cur##--cleanup=}"; return ;; --reuse-message=* | --reedit-message=* | --fixup=* | --squash=*) __gitcomp_nl "$(__git_refs)" "" "${cur#*=}"; return ;; --untracked-files=*) __gitcomp "all no normal" "" "${cur##--untracked-files=}"; return ;; --*) __gitcomp " --all --author= --signoff --verify --no-verify --edit --no-edit --amend --include --only --interactive --dry-run --reuse-message= --reedit-message= --reset-author --file= --message= --template= --cleanup= --untracked-files --untracked-files= --verbose --quiet --fixup= --squash= "; return ;; esac; if git rev-parse --verify --quiet HEAD > /dev/null; then __git_complete_index_file "--committable"; else __git_complete_index_file "--cached"; fi } _git_config () { case "$prev" in branch.*.remote | branch.*.pushremote) __gitcomp_nl "$(__git_remotes)"; return ;; branch.*.merge) __gitcomp_nl "$(__git_refs)"; return ;; branch.*.rebase) __gitcomp "false true"; return ;; remote.pushdefault) __gitcomp_nl "$(__git_remotes)"; return ;; remote.*.fetch) local remote="${prev#remote.}"; remote="${remote%.fetch}"; if [ -z "$cur" ]; then __gitcomp_nl "refs/heads/" "" "" ""; return; fi; __gitcomp_nl "$(__git_refs_remotes "$remote")"; return ;; remote.*.push) local remote="${prev#remote.}"; remote="${remote%.push}"; __gitcomp_nl "$(git --git-dir="$(__gitdir)" for-each-ref --format='%(refname):%(refname)' refs/heads)"; return ;; pull.twohead | pull.octopus) __git_compute_merge_strategies; __gitcomp "$__git_merge_strategies"; return ;; color.branch | color.diff | color.interactive | color.showbranch | color.status | color.ui) __gitcomp "always never auto"; return ;; color.pager) __gitcomp "false true"; return ;; color.*.*) __gitcomp " normal black red green yellow blue magenta cyan white bold dim ul blink reverse "; return ;; diff.submodule) __gitcomp "log short"; return ;; help.format) __gitcomp "man info web html"; return ;; log.date) __gitcomp "$__git_log_date_formats"; return ;; sendemail.aliasesfiletype) __gitcomp "mutt mailrc pine elm gnus"; return ;; sendemail.confirm) __gitcomp "$__git_send_email_confirm_options"; return ;; sendemail.suppresscc) __gitcomp "$__git_send_email_suppresscc_options"; return ;; --get | --get-all | --unset | --unset-all) __gitcomp_nl "$(__git_config_get_set_variables)"; return ;; *.*) return ;; esac; case "$cur" in --*) __gitcomp " --system --global --local --file= --list --replace-all --get --get-all --get-regexp --add --unset --unset-all --remove-section --rename-section "; return ;; branch.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_"; return ;; branch.*) local pfx="${cur%.*}." cur_="${cur#*.}"; __gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."; __gitcomp_nl_append 'autosetupmerge autosetuprebase ' "$pfx" "$cur_"; return ;; guitool.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp " argprompt cmd confirm needsfile noconsole norescan prompt revprompt revunmerged title " "$pfx" "$cur_"; return ;; difftool.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "cmd path" "$pfx" "$cur_"; return ;; man.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "cmd path" "$pfx" "$cur_"; return ;; mergetool.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"; return ;; pager.*) local pfx="${cur%.*}." cur_="${cur#*.}"; __git_compute_all_commands; __gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"; return ;; remote.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp " url proxy fetch push mirror skipDefaultUpdate receivepack uploadpack tagopt pushurl " "$pfx" "$cur_"; return ;; remote.*) local pfx="${cur%.*}." cur_="${cur#*.}"; __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."; __gitcomp_nl_append "pushdefault" "$pfx" "$cur_"; return ;; url.*.*) local pfx="${cur%.*}." cur_="${cur##*.}"; __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"; return ;; esac; __gitcomp " add.ignoreErrors advice.commitBeforeMerge advice.detachedHead advice.implicitIdentity advice.pushNonFastForward advice.resolveConflict advice.statusHints alias. am.keepcr apply.ignorewhitespace apply.whitespace branch.autosetupmerge branch.autosetuprebase browser. clean.requireForce color.branch color.branch.current color.branch.local color.branch.plain color.branch.remote color.decorate.HEAD color.decorate.branch color.decorate.remoteBranch color.decorate.stash color.decorate.tag color.diff color.diff.commit color.diff.frag color.diff.func color.diff.meta color.diff.new color.diff.old color.diff.plain color.diff.whitespace color.grep color.grep.context color.grep.filename color.grep.function color.grep.linenumber color.grep.match color.grep.selected color.grep.separator color.interactive color.interactive.error color.interactive.header color.interactive.help color.interactive.prompt color.pager color.showbranch color.status color.status.added color.status.changed color.status.header color.status.nobranch color.status.untracked color.status.updated color.ui commit.status commit.template core.abbrev core.askpass core.attributesfile core.autocrlf core.bare core.bigFileThreshold core.compression core.createObject core.deltaBaseCacheLimit core.editor core.eol core.excludesfile core.fileMode core.fsyncobjectfiles core.gitProxy core.ignoreStat core.ignorecase core.logAllRefUpdates core.loosecompression core.notesRef core.packedGitLimit core.packedGitWindowSize core.pager core.preferSymlinkRefs core.preloadindex core.quotepath core.repositoryFormatVersion core.safecrlf core.sharedRepository core.sparseCheckout core.symlinks core.trustctime core.warnAmbiguousRefs core.whitespace core.worktree diff.autorefreshindex diff.external diff.ignoreSubmodules diff.mnemonicprefix diff.noprefix diff.renameLimit diff.renames diff.statGraphWidth diff.submodule diff.suppressBlankEmpty diff.tool diff.wordRegex diff.algorithm difftool. difftool.prompt fetch.recurseSubmodules fetch.unpackLimit format.attach format.cc format.coverLetter format.headers format.numbered format.pretty format.signature format.signoff format.subjectprefix format.suffix format.thread format.to gc. gc.aggressiveWindow gc.auto gc.autopacklimit gc.packrefs gc.pruneexpire gc.reflogexpire gc.reflogexpireunreachable gc.rerereresolved gc.rerereunresolved gitcvs.allbinary gitcvs.commitmsgannotation gitcvs.dbTableNamePrefix gitcvs.dbdriver gitcvs.dbname gitcvs.dbpass gitcvs.dbuser gitcvs.enabled gitcvs.logfile gitcvs.usecrlfattr guitool. gui.blamehistoryctx gui.commitmsgwidth gui.copyblamethreshold gui.diffcontext gui.encoding gui.fastcopyblame gui.matchtrackingbranch gui.newbranchtemplate gui.pruneduringfetch gui.spellingdictionary gui.trustmtime help.autocorrect help.browser help.format http.lowSpeedLimit http.lowSpeedTime http.maxRequests http.minSessions http.noEPSV http.postBuffer http.proxy http.sslCAInfo http.sslCAPath http.sslCert http.sslCertPasswordProtected http.sslKey http.sslVerify http.useragent i18n.commitEncoding i18n.logOutputEncoding imap.authMethod imap.folder imap.host imap.pass imap.port imap.preformattedHTML imap.sslverify imap.tunnel imap.user init.templatedir instaweb.browser instaweb.httpd instaweb.local instaweb.modulepath instaweb.port interactive.singlekey log.date log.decorate log.showroot mailmap.file man. man.viewer merge. merge.conflictstyle merge.log merge.renameLimit merge.renormalize merge.stat merge.tool merge.verbosity mergetool. mergetool.keepBackup mergetool.keepTemporaries mergetool.prompt notes.displayRef notes.rewrite. notes.rewrite.amend notes.rewrite.rebase notes.rewriteMode notes.rewriteRef pack.compression pack.deltaCacheLimit pack.deltaCacheSize pack.depth pack.indexVersion pack.packSizeLimit pack.threads pack.window pack.windowMemory pager. pretty. pull.octopus pull.twohead push.default rebase.autosquash rebase.stat receive.autogc receive.denyCurrentBranch receive.denyDeleteCurrent receive.denyDeletes receive.denyNonFastForwards receive.fsckObjects receive.unpackLimit receive.updateserverinfo remote.pushdefault remotes. repack.usedeltabaseoffset rerere.autoupdate rerere.enabled sendemail. sendemail.aliasesfile sendemail.aliasfiletype sendemail.bcc sendemail.cc sendemail.cccmd sendemail.chainreplyto sendemail.confirm sendemail.envelopesender sendemail.from sendemail.identity sendemail.multiedit sendemail.signedoffbycc sendemail.smtpdomain sendemail.smtpencryption sendemail.smtppass sendemail.smtpserver sendemail.smtpserveroption sendemail.smtpserverport sendemail.smtpuser sendemail.suppresscc sendemail.suppressfrom sendemail.thread sendemail.to sendemail.validate showbranch.default status.relativePaths status.showUntrackedFiles status.submodulesummary submodule. tar.umask transfer.unpackLimit url. user.email user.name user.signingkey web.browser branch. remote. " } _git_describe () { case "$cur" in --*) __gitcomp " --all --tags --contains --abbrev= --candidates= --exact-match --debug --long --match --always "; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_diff () { __git_has_doubledash && return; case "$cur" in --diff-algorithm=*) __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"; return ;; --*) __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex --base --ours --theirs --no-index $__git_diff_common_options "; return ;; esac; __git_complete_revlist_file } _git_difftool () { __git_has_doubledash && return; case "$cur" in --tool=*) __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"; return ;; --*) __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex --base --ours --theirs --no-renames --diff-filter= --find-copies-harder --relative --ignore-submodules --tool="; return ;; esac; __git_complete_revlist_file } _git_fetch () { case "$cur" in --recurse-submodules=*) __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"; return ;; --*) __gitcomp "$__git_fetch_options"; return ;; esac; __git_complete_remote_or_refspec } _git_flow () { local subcommands="init feature release hotfix support help version config finish delete publish rebase"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in init) __git_flow_init; return ;; feature) __git_flow_feature; return ;; release) __git_flow_release; return ;; hotfix) __git_flow_hotfix; return ;; support) __git_flow_support; return ;; config) __git_flow_config; return ;; *) COMPREPLY=() ;; esac } _git_format_patch () { case "$cur" in --thread=*) __gitcomp " deep shallow " "" "${cur##--thread=}"; return ;; --*) __gitcomp "$__git_format_patch_options"; return ;; esac; __git_complete_revlist } _git_fsck () { case "$cur" in --*) __gitcomp " --tags --root --unreachable --cache --no-reflogs --full --strict --verbose --lost-found "; return ;; esac } _git_gc () { case "$cur" in --*) __gitcomp "--prune --aggressive"; return ;; esac } _git_gitk () { _gitk } _git_grep () { __git_has_doubledash && return; case "$cur" in --*) __gitcomp " --cached --text --ignore-case --word-regexp --invert-match --full-name --line-number --extended-regexp --basic-regexp --fixed-strings --perl-regexp --files-with-matches --name-only --files-without-match --max-depth --count --and --or --not --all-match "; return ;; esac; case "$cword,$prev" in 2,* | *,-*) if test -r tags; then __gitcomp_nl "$(__git_match_ctag "$cur" tags)"; return; fi ;; esac; __gitcomp_nl "$(__git_refs)" } _git_help () { case "$cur" in --*) __gitcomp "--all --info --man --web"; return ;; esac; __git_compute_all_commands; __gitcomp "$__git_all_commands $(__git_aliases) attributes cli core-tutorial cvs-migration diffcore gitk glossary hooks ignore modules namespaces repository-layout tutorial tutorial-2 workflows " } _git_init () { case "$cur" in --shared=*) __gitcomp " false true umask group all world everybody " "" "${cur##--shared=}"; return ;; --*) __gitcomp "--quiet --bare --template= --shared --shared="; return ;; esac } _git_log () { __git_has_doubledash && return; local g="$(git rev-parse --git-dir 2>/dev/null)"; local merge=""; if [ -f "$g/MERGE_HEAD" ]; then merge="--merge"; fi; case "$cur" in --pretty=* | --format=*) __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) " "" "${cur#*=}"; return ;; --date=*) __gitcomp "$__git_log_date_formats" "" "${cur##--date=}"; return ;; --decorate=*) __gitcomp "long short" "" "${cur##--decorate=}"; return ;; --*) __gitcomp " $__git_log_common_options $__git_log_shortlog_options $__git_log_gitk_options --root --topo-order --date-order --reverse --follow --full-diff --abbrev-commit --abbrev= --relative-date --date= --pretty= --format= --oneline --cherry-pick --graph --decorate --decorate= --walk-reflogs --parents --children $merge $__git_diff_common_options --pickaxe-all --pickaxe-regex "; return ;; esac; __git_complete_revlist } _git_ls_files () { case "$cur" in --*) __gitcomp "--cached --deleted --modified --others --ignored --stage --directory --no-empty-directory --unmerged --killed --exclude= --exclude-from= --exclude-per-directory= --exclude-standard --error-unmatch --with-tree= --full-name --abbrev --ignored --exclude-per-directory "; return ;; esac; __git_complete_index_file "--cached" } _git_ls_remote () { __gitcomp_nl "$(__git_remotes)" } _git_ls_tree () { __git_complete_file } _git_merge () { __git_complete_strategy && return; case "$cur" in --*) __gitcomp "$__git_merge_options --rerere-autoupdate --no-rerere-autoupdate --abort"; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_merge_base () { case "$cur" in --*) __gitcomp "--octopus --independent --is-ancestor --fork-point"; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_mergetool () { case "$cur" in --tool=*) __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"; return ;; --*) __gitcomp "--tool="; return ;; esac } _git_mv () { case "$cur" in --*) __gitcomp "--dry-run"; return ;; esac; if [ $(__git_count_arguments "mv") -gt 0 ]; then __git_complete_index_file "--cached --others --directory"; else __git_complete_index_file "--cached"; fi } _git_name_rev () { __gitcomp "--tags --all --stdin" } _git_notes () { local subcommands='add append copy edit list prune remove show'; local subcommand="$(__git_find_on_cmdline "$subcommands")"; case "$subcommand,$cur" in ,--*) __gitcomp '--ref' ;; ,*) case "$prev" in --ref) __gitcomp_nl "$(__git_refs)" ;; *) __gitcomp "$subcommands --ref" ;; esac ;; add,--reuse-message=* | append,--reuse-message=* | add,--reedit-message=* | append,--reedit-message=*) __gitcomp_nl "$(__git_refs)" "" "${cur#*=}" ;; add,--* | append,--*) __gitcomp '--file= --message= --reedit-message= --reuse-message=' ;; copy,--*) __gitcomp '--stdin' ;; prune,--*) __gitcomp '--dry-run --verbose' ;; prune,*) ;; *) case "$prev" in -m | -F) ;; *) __gitcomp_nl "$(__git_refs)" ;; esac ;; esac } _git_pull () { __git_complete_strategy && return; case "$cur" in --recurse-submodules=*) __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"; return ;; --*) __gitcomp " --rebase --no-rebase $__git_merge_options $__git_fetch_options "; return ;; esac; __git_complete_remote_or_refspec } _git_push () { case "$prev" in --repo) __gitcomp_nl "$(__git_remotes)"; return ;; --recurse-submodules) __gitcomp "$__git_push_recurse_submodules"; return ;; esac; case "$cur" in --repo=*) __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"; return ;; --recurse-submodules=*) __gitcomp "$__git_push_recurse_submodules" "" "${cur##--recurse-submodules=}"; return ;; --force-with-lease=*) __git_complete_force_with_lease "${cur##--force-with-lease=}"; return ;; --*) __gitcomp " --all --mirror --tags --dry-run --force --verbose --quiet --prune --delete --follow-tags --receive-pack= --repo= --set-upstream --force-with-lease --force-with-lease= --recurse-submodules= "; return ;; esac; __git_complete_remote_or_refspec } _git_rebase () { local dir="$(__gitdir)"; if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then __gitcomp "--continue --skip --abort"; return; fi; __git_complete_strategy && return; case "$cur" in --whitespace=*) __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"; return ;; --*) __gitcomp " --onto --merge --strategy --interactive --preserve-merges --stat --no-stat --committer-date-is-author-date --ignore-date --ignore-whitespace --whitespace= --autosquash --fork-point --no-fork-point "; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_reflog () { local subcommands="show delete expire"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; else __gitcomp_nl "$(__git_refs)"; fi } _git_remote () { local subcommands="add rename remove set-head set-branches set-url show prune update"; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; return; fi; case "$subcommand" in rename | remove | set-url | show | prune) __gitcomp_nl "$(__git_remotes)" ;; set-head | set-branches) __git_complete_remote_or_refspec ;; update) local i c='' IFS=' '; for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do i="${i#remotes.}"; c="$c ${i/ */}"; done; __gitcomp "$c" ;; *) ;; esac } _git_replace () { __gitcomp_nl "$(__git_refs)" } _git_reset () { __git_has_doubledash && return; case "$cur" in --*) __gitcomp "--merge --mixed --hard --soft --patch"; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_revert () { case "$cur" in --*) __gitcomp "--edit --mainline --no-edit --no-commit --signoff"; return ;; esac; __gitcomp_nl "$(__git_refs)" } _git_rm () { case "$cur" in --*) __gitcomp "--cached --dry-run --ignore-unmatch --quiet"; return ;; esac; __git_complete_index_file "--cached" } _git_send_email () { case "$cur" in --confirm=*) __gitcomp " $__git_send_email_confirm_options " "" "${cur##--confirm=}"; return ;; --suppress-cc=*) __gitcomp " $__git_send_email_suppresscc_options " "" "${cur##--suppress-cc=}"; return ;; --smtp-encryption=*) __gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"; return ;; --thread=*) __gitcomp " deep shallow " "" "${cur##--thread=}"; return ;; --*) __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to --compose --confirm= --dry-run --envelope-sender --from --identity --in-reply-to --no-chain-reply-to --no-signed-off-by-cc --no-suppress-from --no-thread --quiet --signed-off-by-cc --smtp-pass --smtp-server --smtp-server-port --smtp-encryption= --smtp-user --subject --suppress-cc= --suppress-from --thread --to --validate --no-validate $__git_format_patch_options"; return ;; esac; __git_complete_revlist } _git_shortlog () { __git_has_doubledash && return; case "$cur" in --*) __gitcomp " $__git_log_common_options $__git_log_shortlog_options --numbered --summary "; return ;; esac; __git_complete_revlist } _git_show () { __git_has_doubledash && return; case "$cur" in --pretty=* | --format=*) __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) " "" "${cur#*=}"; return ;; --diff-algorithm=*) __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"; return ;; --*) __gitcomp "--pretty= --format= --abbrev-commit --oneline $__git_diff_common_options "; return ;; esac; __git_complete_revlist_file } _git_show_branch () { case "$cur" in --*) __gitcomp " --all --remotes --topo-order --current --more= --list --independent --merge-base --no-name --color --no-color --sha1-name --sparse --topics --reflog "; return ;; esac; __git_complete_revlist } _git_stage () { _git_add } _git_stash () { local save_opts='--keep-index --no-keep-index --quiet --patch'; local subcommands='save list show apply clear drop pop create branch'; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then case "$cur" in --*) __gitcomp "$save_opts" ;; *) if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then __gitcomp "$subcommands"; fi ;; esac; else case "$subcommand,$cur" in save,--*) __gitcomp "$save_opts" ;; apply,--* | pop,--*) __gitcomp "--index --quiet" ;; show,--* | drop,--* | branch,--*) ;; show,* | apply,* | drop,* | pop,* | branch,*) __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list | sed -n -e 's/:.*//p')" ;; *) ;; esac; fi } _git_submodule () { __git_has_doubledash && return; local subcommands="add status init deinit update summary foreach sync"; if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then case "$cur" in --*) __gitcomp "--quiet --cached" ;; *) __gitcomp "$subcommands" ;; esac; return; fi } _git_svn () { local subcommands=" init fetch clone rebase dcommit log find-rev set-tree commit-diff info create-ignore propget proplist show-ignore show-externals branch tag blame migrate mkdirs reset gc "; local subcommand="$(__git_find_on_cmdline "$subcommands")"; if [ -z "$subcommand" ]; then __gitcomp "$subcommands"; else local remote_opts="--username= --config-dir= --no-auth-cache"; local fc_opts=" --follow-parent --authors-file= --repack= --no-metadata --use-svm-props --use-svnsync-props --log-window-size= --no-checkout --quiet --repack-flags --use-log-author --localtime --ignore-paths= --include-paths= $remote_opts "; local init_opts=" --template= --shared= --trunk= --tags= --branches= --stdlayout --minimize-url --no-metadata --use-svm-props --use-svnsync-props --rewrite-root= --prefix= --use-log-author --add-author-from $remote_opts "; local cmt_opts=" --edit --rmdir --find-copies-harder --copy-similarity= "; case "$subcommand,$cur" in fetch,--*) __gitcomp "--revision= --fetch-all $fc_opts" ;; clone,--*) __gitcomp "--revision= $fc_opts $init_opts" ;; init,--*) __gitcomp "$init_opts" ;; dcommit,--*) __gitcomp " --merge --strategy= --verbose --dry-run --fetch-all --no-rebase --commit-url --revision --interactive $cmt_opts $fc_opts " ;; set-tree,--*) __gitcomp "--stdin $cmt_opts $fc_opts" ;; create-ignore,--* | propget,--* | proplist,--* | show-ignore,--* | show-externals,--* | mkdirs,--*) __gitcomp "--revision=" ;; log,--*) __gitcomp " --limit= --revision= --verbose --incremental --oneline --show-commit --non-recursive --authors-file= --color " ;; rebase,--*) __gitcomp " --merge --verbose --strategy= --local --fetch-all --dry-run $fc_opts " ;; commit-diff,--*) __gitcomp "--message= --file= --revision= $cmt_opts" ;; info,--*) __gitcomp "--url" ;; branch,--*) __gitcomp "--dry-run --message --tag" ;; tag,--*) __gitcomp "--dry-run --message" ;; blame,--*) __gitcomp "--git-format" ;; migrate,--*) __gitcomp " --config-dir= --ignore-paths= --minimize --no-auth-cache --username= " ;; reset,--*) __gitcomp "--revision= --parent" ;; *) ;; esac; fi } _git_tag () { local i c=1 f=0; while [ $c -lt $cword ]; do i="${words[c]}"; case "$i" in -d | -v) __gitcomp_nl "$(__git_tags)"; return ;; -f) f=1 ;; esac; ((c++)); done; case "$prev" in -m | -F) ;; -* | tag) if [ $f = 1 ]; then __gitcomp_nl "$(__git_tags)"; fi ;; *) __gitcomp_nl "$(__git_refs)" ;; esac } _git_whatchanged () { _git_log } _gitk () { __git_wrap__gitk_main } _npm_completion () { local si="$IFS"; IFS=' ' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" COMP_LINE="$COMP_LINE" COMP_POINT="$COMP_POINT" npm completion -- "${COMP_WORDS[@]}" 2>/dev/null)) || return $?; IFS="$si" } _tobase () { local _outputBaseSpecChar=${outputBaseSpecChar:-d}; local n; for n in "$@"; do printf "%#${_outputBaseSpecChar}\n" $(( n )); done } af () { f "$@" } brm () { [[ $1 == '-h' || $1 == '--help' ]] && { echo 'Prints the contents of ${BASH_REMATCH[@]} in diagnostic form.'; return 0 }; (( $# )) && { echo 'ERROR: Unexpected parameter(s) specified. Use -h for help.' 1>&2; return 2 }; local i m; for m in "${BASH_REMATCH[@]}"; do echo "[$((i++))] = [$m]"; done } calc () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "usage: $FUNCNAME expression\n Evaluates the specified arithmetic expression using (( )) and prints the result.\n Useful for simple calculations and converting hex or oct numbers to decimals." && return 0; echo $(( $@ )) } cdp () { local CDPATH=~:~/Documents/Projects:~/Documents/Projects/OSS:~/Documents/Projects/AlfredWorkflows; builtin cd "$@" } de () { local a i=0; for a in "$@"; do printf '%s\n' "\$$((i+=1))=[$a]"; done } dfs () { df -hl | grep 'disk0s2' | awk '{print $4"/"$2" free ("$5" used)"}' } difs () { echo -n "$IFS" | od -a } doIt () { echo "$$: [$*]" } docker-start () { typeset vm=${1:-default} sts; case $vm in -h | --help) echo 'usage: docker-start [] Ensures that the specified/default Docker VM is started and the environment is initialized.'; return 0 ;; esac; sts=$(docker-machine status "$vm") || return; [[ $sts == 'Running' ]] && echo "(Docker VM '$vm' is already running.)" || { echo "-- Starting Docker VM '$vm' (\`docker-machine start "$vm"\`; this will take a while)..."; docker-machine start "$vm" || return }; echo "-- Setting DOCKER_* environment variables (\`eval \"\$(docker-machine env "$vm")\"\`)..."; eval "$(docker-machine env "$vm")" || return; export | grep -o 'DOCKER_.*'; echo "-- Docker VM '$vm' is running." } docker-stop () { typeset vm=${1:-default} sts envVarNames fndx; case $vm in -h | --help) echo 'usage: docker-stop [] Ensures that the specified/default Docker VM is stopped and the environment is cleaned up.'; return 0 ;; esac; sts=$(docker-machine status "$vm") || return; [[ $sts == 'Running' ]] && { echo "-- Stopping Docker VM '$vm' (\`docker-machine stop "$vm"\`)..."; docker-machine stop "$vm" || return } || echo "(Docker VM '$vm' is not running.)"; [[ -n $BASH_VERSION ]] && fndx=3 || fndx=1; envVarNames=($(export | awk -v fndx="$fndx" '$fndx ~ /^DOCKER_/ { sub(/=.*/,"", $fndx); print $fndx }')); if [[ -n $envVarNames ]]; then echo "-- Unsetting DOCKER_* environment variables ($(echo "${envVarNames[@]}" | sed 's/ /, /g'))..."; unset "${envVarNames[@]}"; else echo "(No DOCKER_* environment variables to unset.)"; fi; echo "-- Docker VM '$vm' is stopped." } dsh () { function die () { echo "${FUNCNAME[1]}(): ERROR: ${1:-"ABORTING due to unexpected error."}" 1>&2; return ${2:-1} }; function dieSyntax () { echo "${FUNCNAME[1]}(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h or --h for help." 1>&2; return 2 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; return $ecode } env_parallel () { local _grep_REGEXP="$( perl -e ' for(@ARGV){ /^_$/ and $next_is_env = 0; $next_is_env and push @envvar, split/,/, $_; $next_is_env = /^--env$/; } $vars = join "|",map { quotemeta $_ } @envvar; print $vars ? "($vars)" : "(.*)"; ' -- "$@" )"; local _ignore_UNDERSCORE="$( perl -e ' for(@ARGV){ $next_is_env and push @envvar, split/,/, $_; $next_is_env=/^--env$/; } if(grep { /^_$/ } @envvar) { if(not open(IN, "<", "$ENV{HOME}/.parallel/ignored_vars")) { print STDERR "parallel: Error: ", "Run \"parallel --record-env\" in a clean environment first.\n"; } else { chomp(@ignored_vars = ); $vars = join "|",map { quotemeta $_ } "env_parallel", @ignored_vars; print $vars ? "($vars)" : "(,,nO,,VaRs,,)"; } } ' -- "$@" )"; if ! perl -e 'exit grep { /^--record-env$/ } @ARGV' -- "$@"; then ( compgen -a; compgen -A function; compgen -A variable ) | cat > $HOME/.parallel/ignored_vars; return 0; fi; local _alias_NAMES="$(compgen -a | grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ )"; local _list_alias_BODIES="alias $_alias_NAMES"; if [[ "$_alias_NAMES" = "" ]]; then _list_alias_BODIES="true"; fi; unset _alias_NAMES; local _function_NAMES="$(compgen -A function | grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ )"; local _list_function_BODIES="typeset -f $_function_NAMES"; if [[ "$_function_NAMES" = "" ]]; then _list_function_BODIES="true"; fi; unset _function_NAMES; local _variable_NAMES="$(compgen -A variable | grep -E "^$_grep_REGEXP"\$ | grep -vE "^$_ignore_UNDERSCORE"\$ | grep -vFf <(readonly) | grep -Ev '^(BASHOPTS|BASHPID|EUID|GROUPS|FUNCNAME|DIRSTACK|_|PIPESTATUS|PPID|SHELLOPTS|UID|USERNAME|BASH_[A-Z_]+)$')"; local _list_variable_VALUES="typeset -p $_variable_NAMES"; if [[ "$_variable_NAMES" = "" ]]; then _list_variable_VALUES="true"; fi; unset _variable_NAMES; export PARALLEL_ENV="$( shopt 2>/dev/null | perl -pe 's:\s+off:;: and s/^/shopt -u /; s:\s+on:;: and s/^/shopt -s /; s:;$:&>/dev/null;:'; echo 'shopt -s expand_aliases &>/dev/null'; $_list_alias_BODIES; $_list_variable_VALUES; $_list_function_BODIES)"; unset _list_alias_BODIES; unset _list_variable_VALUES; unset _list_function_BODIES; `which parallel` "$@"; _parallel_exit_CODE=$?; unset PARALLEL_ENV; return $_parallel_exit_CODE } f () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <] Description: Opens the specified folder in Finder, or, if invoked as "af", in Alfred 2's file browser. By default, the current folder is targeted. You can also specify a file, in which case its containing folder is opened. can also be the name of a quick-cd function defined in the current shell. Quick-cd functions by conventions start with 'f', and, for convenience, you may specify the function name without the initial 'f'. Examples: $FUNCNAME /Library $FUNCNAME fh # 'fh' is quick-cd function for home folder; 'h' would work, too. EOF return 0; fi (( ${#@} >= 2 )) && echo -e "$FUNCNAME: PARAMETER ERROR: Unexpected parameter(s) specified. Use -h or --h to get help." 1>&2 && return 3; local haveFolder=$(( ${#1} ? 1 : 0 )); if (( haveFolder )); then if [[ -f "$1" ]]; then pushd "$(dirname "$1")" > /dev/null || return 2; else if [[ -d "$1" ]]; then pushd "$1" > /dev/null || return 2; else if [[ ${1/\/} != $1 ]]; then echo "ERROR: '$1', assumed to be a folder path, does not exist." 1>&2; return 1; else quickCdFunc="$1"; if [[ ! "$quickCdFunc" =~ ^[fF] ]]; then quickCdFunc="f$quickCdFunc"; fi; declare -f "$quickCdFunc" > /dev/null || { echo "ERROR: '$1' is neither an existing file or folder nor the name of a quick-cd function." 1>&2; return 1 }; $quickCdFunc > /dev/null || return 2; fi; fi; fi; fi; if [[ ${FUNCNAME[1]} == 'af' ]]; then osascript -e 'tell application "Alfred 2" to search "'"$PWD"'"'; else echo Opening Finder to \"$PWD\"...; open .; fi; if (( haveFolder )); then popd > /dev/null; fi } fa () { pushdX /Applications "$@" } fag () { pushdX "$HOME/Projects/CreativeSmarts/AppGyver" "$@" } fas () { pushdX /Library/Application\ Support "$@" } fasu () { pushdX ~/Library/Application\ Support "$@" } fau () { pushdX ~/Applications "$@" } fawf () { pushdX "$HOME/Dropbox/Alfred.alfredpreferences/workflows" "$@" } fawfc () { pushdX "$HOME/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data" "$@" } fawfd () { pushdX "$HOME/Library/Application Support/Alfred 2/Workflow Data" "$@" } fawfp () { pushdX "$HOME/Projects/AlfredWorkflows" "$@" } fcfg () { pushdX ~/Documents/Config "$@" } fcu () { pushdX ~/Library/Caches "$@" } fd () { pushdX ~/Documents "$@" } fdb () { pushdX ~/Dropbox "$@" } fdbp () { pushdX ~/Dropbox/Public "$@" } fdl () { pushdX ~/Downloads "$@" } fdla () { pushdX ~/Documents/DownloadArchive "$@" } fdt () { pushdX ~/Desktop "$@" } feb () { pushdX ~/Documents/eBooks "$@" } febi () { pushdX ~/Documents/eBooks/IT "$@" } febo () { pushdX ~/Calibre\ Library/ "$@" } ff () { local isFunc=1; [[ -z "$FUNCNAME" ]] && isFunc=0; local thisName=$FUNCNAME; (( isFunc )) || thisName=$(basename "$BASH_SOURCE"); if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2 && { (( isFunc )) && return 3 || exit 3 }; find . -iname "*$@*" } fh () { pushdX ~ "$@" } fhomer () { pushdX "/Volumes/jdoe" "$@" } fic () { pushdX "$HOME/Documents/Config/Icons" "$@" } fif () { local isFunc=1; [[ -z "$FUNCNAME" ]] && isFunc=0; local thisName=$FUNCNAME; (( isFunc )) || thisName=$(basename "$BASH_SOURCE"); if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2 && { (( isFunc )) && return 3 || exit 3 }; egrep -lr "$@" . } findexes () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "Synopsis:\n $FUNCNAME [dir]\n\nDescription:\n Finds all executable files in the specified subtree. Uses \`find\` with the \`-type\` and \`-perm\` primaries." && return 0; find "${1:-.}" -type f -perm "-u=x" } findq () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "Synopsis:\n $FUNCNAME {params for \`find\`}\n\nDescription:\n Same as \`find\` with the (implied) \`print\` primary (for listing matching paths),\n except that paths whose names contain reserved chars. are quoted (escaped);\n\n e.g.: 'a name with spaces' -> 'a\ name \ with\ spaces'\n\n Therefore it's safe to pass the output of this function to \`xargs\`.\n e.g.: \`$FUNCNAME . | xargs file\` lists the file type of every file in the current folder's subtree.\n\n CAVEAT: Do not specify a \`find\` primary - \`print\` is implied.\n" && return 0; find "$@" -print0 | while IFS='' read -r -d '' f; do printf '%q\n' "$f"; done } fkkac () { pushdX "$HOME/Projects/CreativeSmarts/AppGyver/Kakooma" "$@" } fkkai () { pushdX "$HOME/Projects/CreativeSmarts/Kakooma iOS Apps/src" "$@" } fl () { pushdX /Library "$@" } fla () { pushdX /Library/LaunchAgents "$@" } flau () { pushdX ~/Library/LaunchAgents "$@" } flsys () { pushdX /System/Library "$@" } flu () { pushdX ~/Library "$@" } fngb () { pushdX "$(npm bin -g)" "$@" } fngm () { pushdX "$(npm prefix -g)"/lib/node_modules "$@" } fobt () { pushdX "/Volumes/C/Users/jdoe/Documents/Projects/ta/onboarding-termination" "$@" } foldIndent () { local width=${1:-80} indent=${2- }; (( width-=${#indent} )); while IFS= read -r line; do fold -s -w $width <<< "$line" | awk 'NR>1 { print "'"$indent"'" $0; next } 1'; done } foss () { pushdX "$HOME/Projects/OSS" "$@" } fpg () { pushdX "$HOME/Desktop/pg" "$@" } fpgw () { pushdX "/Volumes/C/Users/jdoe/Desktop/pg" "$@" } fph () { pushdX ~/Pictures/ "$@" } fppg () { pushdX ~/Projects/pg "$@" } fpr () { pushdX ~/Projects "$@" } fpref () { pushdX /Library/Preferences "$@" } fprefu () { pushdX ~/Library/Preferences "$@" } fql () { pushdX /Library/QuickLook "$@" } fqlu () { pushdX ~/Library/QuickLook "$@" } fs () { pushdX /Library/Services "$@" } fsba () { pushdX ~/Library/Containers "$@" } fsd () { pushdX "/Volumes/data" "$@" } fsl () { pushdX /Library/'Script Libraries' "$@" } fslu () { pushdX ~/Library/'Script Libraries' "$@" } fsn () { pushdX "/Volumes/C/Users/jdoe/Documents/Projects/ta/sponsored-renewal/PsScripts" "$@" } fsph () { pushdX "/Volumes/media/Photos" "$@" } fss () { pushdX ~/Library/'Saved Searches' "$@" } fstp () { d=$([[ $(uname) == 'Darwin' ]] && printf "$HOME/Library/Application Support/Sublime Text 3/Packages" || printf "$HOME/.config/sublime-text-2/Packages"); pushdX "$d" "$@" } fstpu () { d=$([[ $(uname) == 'Darwin' ]] && printf "$HOME/Library/Application Support/Sublime Text 3/Packages/User" || printf "$HOME/.config/sublime-text-2/Packages/User"); pushdX "$d" "$@" } fsu () { pushdX ~/Library/Services "$@" } fsv () { pushdX "/Volumes/media/Videos" "$@" } fsvms () { pushdX '/Volumes/data/VMs/VMware Fusion/Virtual Machines' "$@" } ft () { pushdX '/tmp' "$@" } ftr () { pushdX "/Volumes/data/Transfer" "$@" } ftu () { pushdX "$TMPDIR" "$@" } fu () { pushdX "$MK_UTIL_FOLDER" "$@" } fub () { pushdX ~/bin "$@" } fuc () { pushdX "$MK_UTIL_FOLDER/sourced.d/bash_completion.d" "$@" } fulb () { pushdX '/usr/local/bin' "$@" } fullpath () { [[ "$1" == '--help' || "$1" == '-h' ]] && { echo -e "usage: $FUNCNAME [-ep] [path]\n Prints the absolute version of the specified path; defaults to \$PWD.\n The path is normalized, i.e, '.' and '..' components are resolved, if present.\n If only a filename is given and the file doesn't exist in the current folder, -p will search for it in the \$PATH, too.\n -e reports an error if the resulting path doesn't exist."; return 0 }; local params=() decompressed=0 argsReached=0 p=''; for p in "$@"; do if [[ $argsReached -eq 0 && $p == -[a-z,A-Z,0-9]?* ]]; then decompressed=1; params+=(${p:0:2}); for ((i = 2; i < ${#p}; i++ )) do params+=("-${p:$i:1}"); done; else [[ $p == '--' ]] && argsReached=1; params+=("$p"); fi; done; if (( decompressed )); then set -- "${params[@]}"; fi; unset params decompressed argsReached p; local fp searchInPath mustExist; while (( $# )); do case "$1" in -p) searchInPath=1 ;; -e) mustExist=1 ;; --) shift; break ;; -*) echo "PARAMETER ERROR: Unrecognized option: '$1'. To force interpretation as non-option, precede with '--'." 1>&2; return 2 ;; *) break ;; esac; shift; done; [[ -z $2 ]] || { echo "PARAMETER ERROR: Too many parameters specified. Use -h for help." 1>&2; return 2 }; if [[ -z $1 ]]; then fp=$PWD; else if [[ "${1:0:1}" == '/' ]]; then fp=$1; else fp="$PWD/$1"; if [[ -n $searchInPath && ! -e "$fp" && "${1/\//}" == "$1" ]]; then fp=$(which "$1" 2>/dev/null) || fp="$1"; fi; fi; fi; if [[ $fp =~ (/|^)(\.\.?)(/|$) && ( -e "$fp" || -d "$(dirname "$fp")" ) ]]; then local fld; [[ -d "$fp" ]] && fld=$fp || fld=$(dirname "$fp"); local fldResolved=$(cd "$fld"; pwd); [[ -d "$fp" ]] && fp=$fldResolved || fp=$fldResolved/$(basename "$fp"); fi; [[ -n $mustExist && ! -e "$fp" ]] && { echo "ERROR: Path '$fp' does not exist." 1>&2; return 1 }; echo "$fp" } fus () { pushdX "$MK_UTIL_FOLDER/sourced.d" "$@" } fuw () { pushdX "$MK_UTIL_FOLDER.Win" "$@" } fvms () { dirs=(~/'Documents/Virtual Machines.localized' ~/'Documents/Virtual Machines'); for dir in "${dirs[@]}"; do [[ -d "$dir" ]] && { pushdX "$dir" "$@"; return }; done } fwac () { pushdX "/Volumes/C/Users/jdoe/Documents/Projects/ta/workday-ad-consistency" "$@" } getip () { [[ "$1" == '--help' || "$1" == '-h' ]] && { echo -e "usage: $FUNCNAME\n Prints the IPv4 address of the first *bound* Ethernet interface (e.g., en0); cf. getips()."; return 0 }; if [[ $(uname) == 'Darwin' ]]; then for ifName in $(ifconfig -l | egrep -o "\ben[0-9]+"); do local protName='inet'; local addrFragment=$(ifconfig "$ifName" | egrep -o "\b$protName \S+"); if [[ -n $addrFragment ]]; then echo "$addrFragment" | egrep -o '[0-9].*'; return 0; fi; done; return 1; else local addr; addr=$(ip route get 10.0.0.1 | awk '{print $NF; exit}'); [[ -n $addr ]] || return 1; echo "$addr"; fi } getips () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "usage: $FUNCNAME [-b] [interface-type]\n Prints all this machine's IPv4 addresses of the specified interface *type* (Ethernet by default); cf. getip()\n Use \`ifconfig\` directly to get a specific interface's address.\n -b prints addresses only (suppresses the interface-name prefix) and skips interfaces without address." && return 0; local bare=0; [[ $1 == -b ]] && { bare=1; shift }; local ifType=${1:-en}; for ifName in $(ifconfig -l | egrep -o "\b${ifType}\d+"); do local protName='inet'; local addrFragment=$(ifconfig "$ifName" | egrep -o "\b$protName \S+"); local addr=${addrFragment#$protName }; if (( bare )); then [[ -n $addr ]] && echo "$addr"; else echo "$ifName: $addr"; fi; done; return 0 } installnode () { local THIS_NAME=$FUNCNAME; function _installnode_die () { echo "$THIS_NAME(): ERROR: ${1:-"ABORTING due to unexpected error."}" 1>&2; return ${2:-1} }; function _installnode_dieSyntax () { echo "$THIS_NAME(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h for help." 1>&2; return 2 }; function _installnode_indexOf () { local e ndx=-1; for e in "${@:2}"; do (( ++ndx )); [[ "$e" == "$1" ]] && echo $ndx && return 0; done; echo '-1'; return 1 }; function _installnode_isIn () { _installnode_indexOf "$@" > /dev/null }; function _installnode_pruneToMajorMinor () { printf '%s' | cut -d '.' -f 1-2 <<< "$1" }; function _installnode_resolveInstalledVersion () { local verSpec=$1 verInstalled; [[ ${verSpec:0:1} == 'v' ]] && verSpec=${verSpec:1}; read -r verInstalled <<< "$(nvm ls "$verSpec" | tail -1)"; [[ $verInstalled =~ \ *(v[[:digit:]]+[.[:digit:]]+) ]] && verInstalled=${BASH_REMATCH[1]} || verInstalled=''; printf '%s' "$verInstalled" }; function _installnode_resolveRemoteVersion () { local verSpec=$1; nvm ls-remote "$verSpec" | tail -1 | egrep -o 'v[[:digit:]]+[.[:digit:]]+' }; function _installnode_getLatestUnstableVersion () { _installnode_resolveRemoteVersion }; function _installnode_getLatestProductionVersion () { local latestOverall major minor; latestOverall=$(nvm ls-remote | tail -1 | egrep -o 'v[[:digit:]]+[.[:digit:]]+'); major=$(cut -d '.' -f 1 <<<"$latestOverall"); minor=$(cut -d '.' -f 2 <<<"$latestOverall"); minor=$(( minor - minor % 2 )); _installnode_resolveRemoteVersion "${major}.${minor}" }; function _installnode_isInstalled () { local verSpec=$1; [[ ${verSpec:0:1} == 'v' ]] || verSpec="v${verSpec}"; nvm ls | egrep -v '(:|->)' | egrep "$verSpec" > /dev/null; return $? }; function _installnode_getDefaultVerSpec () { nvm alias default | cut -d ' ' -f 3 }; function _installnode_getDefaultVer () { nvm alias default | awk -F '->' '{print $3}' | tr -d ' )' }; function _installnode_vercomp () { [[ $1 == $2 ]] && return 0; local i v1=$1 v2=$2; [[ ${v1:0:1} == 'v' ]] && v1=${v1:1}; [[ ${v2:0:1} == 'v' ]] && v2=${v2:1}; local IFS='.'; local i vna1=($v1) vna2=($v2); for ((i=${#vna1[@]}; i<${#vna2[@]}; i++)) do vna1[i]=0; done; for ((i=0; i<${#vna1[@]}; i++)) do [[ -z ${vna2[i]} ]] && vna2[i]=0; (( 10#${vna1[i]} > 10#${vna2[i]} )) && return 1; (( 10#${vna1[i]} < 10#${vna2[i]} )) && return 2; done; return 0 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat < /dev/null; then argsReached=1; fi; fi; params+=("$p"); fi; done; (( decompressed )) && set -- "${params[@]}"; unset params decompressed argsReached p; local showStatus=0 installFresh=0 upgrade=0 installAndCopy=0; local useUnstableVersion=0 skipPrompt=0 force=0; while (( $# )); do case "$1" in status) showStatus=1 ;; fresh) installFresh=1 ;; copy) installAndCopy=1 ;; upgrade) upgrade=1 ;; --) shift; break ;; -d | --unstable) useUnstableVersion=1 ;; -y | --yes) skipPrompt=1 ;; -f | --force) force=1 ;; -?) return $(_installnode_dieSyntax "Unrecognized option: '$1'. To force interpretation as non-option, precede with '--'.") ;; *) break ;; esac; shift; done; local newVerSpec oldVerSpec majorMinorSpec haveNewVerSpec haveOldVerSpec downgrading defaultVerHint defaultVerSpec suggestedNewDefaultVerSpec qualifier otherOptCount descr; newVerSpec=$1; shift; oldVerSpec=$1; shift; [[ -z $1 ]] || return $(_installnode_dieSyntax "Too many parameters specified."); local cmdCount=$(( showStatus + installFresh + installAndCopy + upgrade )); (( cmdCount <= 1 )) || return $(_installnode_dieSyntax "Only 1 command may be specified."); (( cmdCount == 1 )) || showStatus=1; if [[ -n $oldVerSpec ]]; then (( upgrade || installAndCopy )) || return $(_installnode_dieSyntax "An old version number can only be specified with the 'upgrade' and 'copy' commands."); fi; if [[ -n $newVerSpec ]]; then (( ! useUnstableVersion )) || return $(_installnode_dieSyntax "-d implies the latest unstable version, do not also supply an explicit version spec."); fi; haveNewVerSpec=0; if [[ -n $newVerSpec ]]; then haveNewVerSpec=1; [[ ${newVerSpec:0:1} == 'v' ]] || newVerSpec=v${newVerSpec}; fi; haveOldVerSpec=0; if [[ -n $oldVerSpec ]]; then haveOldVerSpec=1; [[ ${oldVerSpec:0:1} == 'v' ]] || oldVerSpec=v${oldVerSpec}; fi; [[ "$(type -t nvm)" != 'function' && -s ~/.nvm/nvm.sh ]] && . ~/.nvm/nvm.sh; [[ "$(type -t nvm)" == 'function' ]] || return $(_installnode_die "nvm (node.js version manager) not found."); if (( haveNewVerSpec )); then resolvedNewVersion=$(_installnode_resolveRemoteVersion "$newVerSpec") || return $(_installnode_die "No available version matching '$newVerSpec' found."); else if (( useUnstableVersion )); then resolvedNewVersion=$(_installnode_getLatestUnstableVersion); else resolvedNewVersion=$(_installnode_getLatestProductionVersion); fi; [[ -n $resolvedNewVersion ]] || return $(_installnode_die "Failed to determine latest available version."); fi; resolvedOldVersion=''; if (( haveOldVerSpec )); then resolvedOldVersion=$(_installnode_resolveInstalledVersion "$oldVerSpec"); [[ -n $resolvedOldVersion ]] || return $(_installnode_die "Old version spec. does not match any installed versions: '$oldVerSpec'"); else if (( haveNewVerSpec )); then majorMinorSpec=$(_installnode_pruneToMajorMinor "$newVerSpec"); else majorMinorSpec=$(_installnode_pruneToMajorMinor "$resolvedNewVersion"); fi; resolvedOldVersion=$(_installnode_resolveInstalledVersion "$majorMinorSpec"); fi; if (( showStatus )); then otherOptCount=$(( skipPrompt + force )); (( otherOptCount == 0 )) || return $(_installnode_dieSyntax "The 'status' command cannot be combined with these options."); descr=''; if (( haveNewVerSpec )); then descr="'$newVerSpec' version"; else if (( useUnstableVersion )); then descr="UNSTABLE version"; else descr="PRODUCTION version"; fi; fi; cat <&2 ;; esac; else if _installnode_isInstalled $resolvedNewVersion; then (( force )) || return $(_installnode_die "Version $resolvedNewVersion is already installed. To force reinstallation, use --force."); echo "WARNING: As requested, REINSTALLING $resolvedNewVersion." 1>&2; fi; fi; if (( installFresh )); then echo "Will INSTALL FRESH: $resolvedNewVersion"; else if (( installAndCopy )); then echo "Will INSTALL: $resolvedNewVersion"; echo "And COPY GLOBAL PACKAGES FROM: $resolvedOldVersion"; else if (( upgrade )); then echo "Will INSTALL: $resolvedNewVersion"; echo "And UPGRADE FROM (copy global packages, then DELETE): $resolvedOldVersion"; fi; fi; fi; while (( ! skipPrompt )); do read -p "CONTINUE? (y/N) " promptInput; [[ $promptInput =~ ^[yY]$ ]] && break; ( [[ $promptInput =~ ^[nN]$ || -z $promptInput ]] ) && { echo "Aborted." 1>&2; return 1 }; echo "Invalid input; please try again (^C to abort)." 1>&2; done; if (( force )) && _installnode_isInstalled "$resolvedNewVersion"; then echo "-- UNinstalling $resolvedOldVersion..."; nvm deactivate > /dev/null; nvm uninstall "$resolvedNewVersion" || return $(_installnode_die); fi; echo "-- INSTALLING $resolvedNewVersion..."; nvm install "$resolvedNewVersion" || return $(_installnode_die); if (( installAndCopy || upgrade )); then echo "-- COPYING global packages from $resolvedOldVersion..."; echo " Note: This CAN TAKE A WHILE, as packages are being rebuilt."; npm_config_loglevel='error' nvm copy-packages "$resolvedOldVersion" > /dev/null || return $(_installnode_die); fi; if (( upgrade )); then echo "-- DELETING old version $resolvedOldVersion..."; nvm uninstall "$resolvedOldVersion" || return $(_installnode_die); fi; if [[ "$resolvedNewVersion" != "$(_installnode_getDefaultVer)" ]]; then suggestedNewDefaultVerSpec=$(_installnode_pruneToMajorMinor "$resolvedNewVersion"); defaultVerSpec=$(_installnode_getDefaultVerSpec); qualifier="the latest $suggestedNewDefaultVerSpec.x version - and therefore now $resolvedNewVersion - "; if [[ "$suggestedNewDefaultVerSpec" == "$(_installnode_getDefaultVerSpec)" ]]; then qualifier="$resolvedNewVersion SPECIFICALLY"; suggestedNewDefaultVerSpec=$resolvedNewVersion; fi; defaultVerHint=" NOTE: The DEFAULT VERSION (spec.) is currently: $(_installnode_getDefaultVerSpec) To make $qualifier the NEW default version, run: nvm alias default $suggestedNewDefaultVerSpec "; fi; if (( SHLVL > 1 )); then echo " -- WARNING: $resolvedNewVersion was SUCCESSFULLY INSTALLED, *but* to MAKE IT TAKE EFFECT, do the following: - open a NEW Terminal tab or window. - and execute the following: nvm use $resolvedNewVersion In the future, consider loading this script - '$BASH_SOURCE' - from your shell profile to avoid having to do this. " 1>&2; else echo "-- Done. ACTIVE VERSION is now $resolvedNewVersion."; fi; if [[ -n $defaultVerHint ]]; then echo "$defaultVerHint"; else echo " $resolvedNewVersion is also the NEW DEFAULT."; fi } iterm2_begin_osc () { printf "\033]" } iterm2_end_osc () { printf "\007" } iterm2_preexec_install () { if ( [ x"${PROMPT_COMMAND:-}" = x ] ); then PROMPT_COMMAND="iterm2_preexec_invoke_cmd"; else PROMPT_COMMAND="$(echo -n $PROMPT_COMMAND | sed -e 's/; *$//'); iterm2_preexec_invoke_cmd"; fi; trap 'iterm2_preexec_invoke_exec "$_"' DEBUG } iterm2_preexec_invoke_cmd () { set -o functrace > /dev/null 2>&1; shopt -s extdebug > /dev/null 2>&1; \local s=$?; last_hist_ent="$(HISTTIMEFORMAT= builtin history 1)"; precmd; if [ -z "${ITERM_ORIG_PS1+xxx}" ]; then export ITERM_ORIG_PS1="$PS1"; fi; if [[ "$PS1" != "$ITERM_PREV_PS1" ]]; then export ITERM_ORIG_PS1="$PS1"; fi; \local iterm2_prompt_prefix_value="$(iterm2_prompt_prefix)"; if [[ $ITERM_ORIG_PS1 != *'$(iterm2_prompt_mark)'* ]]; then iterm2_prompt_prefix_value="$iterm2_prompt_prefix_value$(iterm2_prompt_mark)"; fi; sh -c "exit $s"; export PS1="\[$iterm2_prompt_prefix_value\]$ITERM_ORIG_PS1\[$(iterm2_prompt_suffix)\]"; export ITERM_PREV_PS1="$PS1"; sh -c "exit $s"; ITERM_PREEXEC_INTERACTIVE_MODE="yes" } iterm2_preexec_invoke_exec () { if [ ! -t 1 ]; then return; fi; if [[ -n "${COMP_LINE:-}" ]]; then return; fi; if [[ -z "$ITERM_PREEXEC_INTERACTIVE_MODE" ]]; then return; else if [[ 0 -eq "$BASH_SUBSHELL" ]]; then ITERM_PREEXEC_INTERACTIVE_MODE=""; fi; fi; if [[ "iterm2_preexec_invoke_cmd" == "$BASH_COMMAND" ]]; then ITERM_PREEXEC_INTERACTIVE_MODE=""; return; fi; hist_ent="$(HISTTIMEFORMAT= builtin history 1)"; \local prev_hist_ent="${last_hist_ent}"; last_hist_ent="${hist_ent}"; if [[ "${prev_hist_ent}" != "${hist_ent}" ]]; then \local this_command="$(echo "${hist_ent}" | sed -e "s/^[ ]*[0-9]*[ ]*//g")"; else \local this_command=""; fi; preexec "$this_command" } iterm2_print_state_data () { iterm2_begin_osc; printf "1337;RemoteHost=%s@%s" "$USER" "$iterm2_hostname"; iterm2_end_osc; iterm2_begin_osc; printf "1337;CurrentDir=%s" "$PWD"; iterm2_end_osc; iterm2_print_user_vars } iterm2_print_user_vars () { true } iterm2_print_version_number () { iterm2_begin_osc; printf "1337;ShellIntegrationVersion=4;shell=bash"; iterm2_end_osc } iterm2_prompt_mark () { iterm2_begin_osc; printf "133;A"; iterm2_end_osc } iterm2_prompt_prefix () { iterm2_begin_osc; printf "133;D;\$?"; iterm2_end_osc; iterm2_print_state_data } iterm2_prompt_suffix () { iterm2_begin_osc; printf "133;B"; iterm2_end_osc } iterm2_set_user_var () { iterm2_begin_osc; printf "1337;SetUserVar=%s=%s" "$1" $(printf "%s" "$2" | base64 | tr -d '\n'); iterm2_end_osc } kill-script () { [[ -z $1 || $1 == '-h' || $1 == '--help' ]] && { echo "Usage: $FUNCNAME scriptFileName ..."' '"Kills the specified bash/sh script(s)."; return $(( ${#1} == 0 )) }; local ec=0; for p in "$@"; do pkill -nf '/?(bash|sh)[ ]+(.*/)?'"$p"'( |$)' && echo "'$1' killed." || { ec=$?; echo "ERROR: bash/sh script process not found: '$p'" 1>&2 }; done; return $ec } list-available-locales () { case $(uname) in 'Darwin') locale -a ;; 'Linux') [[ -f /usr/share/i18n/SUPPORTED ]] && { cat /usr/share/i18n/SUPPORTED; return }; which localectl &> /dev/null && { localectl list-locales; return }; { echo "Don't know how to determine available locales for $(uname -a)." 1>&2; return 1 } ;; *) { echo "Don't know how to determine available locales for $(uname)." 1>&2; return 1 } ;; esac } lock () { '/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession' -suspend } lsp () { local isFunc=1; [[ -z "$FUNCNAME" ]] && isFunc=0; local thisName=$FUNCNAME; (( isFunc )) || thisName=$(basename "$BASH_SOURCE"); if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat < Save Project As... CAVEAT: As of ST2 v2.0.1, if a project file is opene and the project happens to be open in ST2 already, a new, *blank* window will open. EOF (( isFunc )) && return 0 || exit 0; fi local projSwitch='--project'; local projFile="$@"; if [[ -z $projFile ]]; then local EXT=.sublime-project; local projFiles=($(shopt -s nullglob; echo *$EXT)); projFile=${projFiles[0]}; if [[ -z $projFile ]]; then projSwitch=''; projFile='.'; echo "Opening folder '$PWD' as implicit, transient ST2 project..."; else echo "Opening project '$projFile'..."; fi; else ls "$projFile" > /dev/null 2>&1 || { echo "ERROR: ST2 project file(s) '$projFile' not found." 1>&2; return 1 }; echo "Opening project(s) '$projFile'..."; fi; subl $projSwitch "$projFile" } mang () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat </dev/null | cut -d= -f2 | xargs); [[ -n $expandedAlias ]] && name=$expandedAlias; if (( $# > 1 )); then man "$@"; else { help -s "$name" | grep -E "^$name:" } &> /dev/null && isBuiltIn=1; if [[ $isBuiltIn -ne 0 && $name != 'printf' ]]; then echo "(\"$name\" is a BUILTIN; using 'help'...)"; help "$name"; return $?; else man "$name" 2> /dev/null && return; fi; echo "(No 'man' page found, trying --help, then -h...)" 1>&2; [[ $(echo $name | tr [:upper:] [:lower:]) == 'setfile' ]] && { $name -h; return 0 }; [[ $(echo $name | tr [:upper:] [:lower:]) == 'plistbuddy' || $name == 'plb' ]] && { local exePath="/usr/libexec/PlistBuddy"; echo "IMPORTANT: 'PlistBuddy' is NOT in the PATH - lives at '$exePath'."' '; $exePath; $exePath -h; return 0 }; local ht=$($name --help 2> /dev/null || $name -h) || return; if [[ -z $ht ]]; then ht=$($name --help 2>&1) || ht=$($name -h 2>&1); fi; echo -E "$ht"; fi } manxg () { local targetCmd=${FUNCNAME%g}; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; return ${2:-1} }; function dieSyntax () { echo "${FUNCNAME[1]}(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h or --h for help." 1>&2; return 2 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; else [[ -n $firstDirCreated ]] || firstDirCreated="$dir"; argsForMkDir+=("$dir"); (( ++createCount )); fi; done; (( createCount )) && { mkdir "${argsForMkDir[@]}" || return $(die) }; cd "$firstDir" || return $(die); msgCreation=''; case $createCount in 0) msgCreation='C' ;; 1) if [[ $firstDirCreated == $firstDir ]]; then msgCreation='Created and c'; else msgCreation='1 dir. created; c'; fi ;; *) msgCreation="$createCount dirs. created; c" ;; esac; echo "${msgCreation}hanged to '$firstDir' [$PWD]." } mktempfile () { [[ "$1" == '--help' || "$1" == '-h' ]] && echo -e "usage: $FUNCNAME [ext]\n Creates a unique temporary file or folder and returns its full path.\n Acts as a simple wrapper around \`mktemp -t tmp\`; i.e., file is created in \$TMPDIR (or /tmp, in its absence);\n optionally specify additional \`mktemp\` options, such as -u to delete the file right away,\n or -d to create a directory instead.\n If you specify EXT, the temporary file is given the specified filename extension." && return 0; local ext; local isDir=0; local dontCreate=0; for p in "$@"; do if [[ "${p:0:1}" != "-" ]]; then [[ -n "$ext" ]] && { echo "$FUNCNAME: PARAMETER ERROR: You can only specify ONE filename extension." 1>&2; return 1 }; ext=$p; else if [[ "$p" == "-d" ]]; then isDir=1; else if [[ "$p" == "-u" ]]; then dontCreate=1; fi; fi; fi; done; [[ isDir -eq 1 && -n $ext ]] && { echo "$FUNCNAME: PARAMETER ERROR: You can only specify a filename extension when you create a file (not a directory)." 1>&2; return 1 }; local passThru=${@/$ext}; local outPath=$(mktemp $passThru -t 'tmp'); [[ -z "$outPath" ]] && return 1; if [[ -n "$ext" ]]; then local oldOutPath=$outPath; [[ "${ext:0:1}" != '.' ]] && ext=".$ext"; outPath+=$ext; if (( ! dontCreate )); then mv "$oldOutPath" "$outPath" || return 1; fi; fi; echo "$outPath" } npmf () { function die () { echo "${FUNCNAME[1]}(): ERROR: ${1:-"ABORTING due to unexpected error."}" 1>&2; return ${2:-1} }; function dieSyntax () { echo "${FUNCNAME[1]}(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h or --h for help." 1>&2; return 2 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat < /dev/null || return $(die) } npml () { function die () { echo "${FUNCNAME[1]}(): ERROR: ${1:-"ABORTING due to unexpected error."}" 1>&2; return ${2:-1} }; function dieSyntax () { echo "${FUNCNAME[1]}(): PARAMETER ERROR: ${1:-"Invalid parameter(s) specified."} Use -h for help." 1>&2; return 2 }; if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat </dev/null | perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))'`; if [[ -z $data ]]; then echo ERROR: No HTML data found on clipboard. 1>&2; return 1; fi; echo "$data" } pbpaste_rtf () { local data; data=`osascript -e 'class RTF of (the clipboard as record)' 2>/dev/null | perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))'`; if [[ -z $data ]]; then echo ERROR: No RTF data found on clipboard. 1>&2; return 1; fi; echo "$data" } pifs () { set | egrep '^IFS=' } precmd () { if [[ -z "${iterm2_ran_preexec:-}" ]]; then preexec ""; fi; iterm2_ran_preexec="" } preexec () { iterm2_begin_osc; printf "133;C;"; iterm2_end_osc; if [ -n "${ITERM_ORIG_PS1+xxx}" -a "$PS1" = "$ITERM_PREV_PS1" ]; then export PS1="$ITERM_ORIG_PS1"; fi; iterm2_ran_preexec="yes" } pushdX () { pushd "$1" > /dev/null || return $?; [[ -t 1 ]] && echo "${PWD/#$HOME/~}" || echo "${PWD}"; shift; if (( $# )); then "$@"; fi } pv () { local pipeStatus=(${PIPESTATUS[@]}); local bashReMatch=("${BASH_REMATCH[@]}"); [[ "$1" == '-h' || "$1" == '--help' ]] && { cat < e.g., 'HOME="/Users/jdoe" # -x' $FUNCNAME 'histf*' # -> e.g., $'HISTFILE="/Users/jdoe/.bash_history"\nHISTFILESIZE="500"' EOF return 0 } function __pv_encodeCtrlChars () { local v=$1; v=${v//' '/\\t}; v=${v//' '/\\n}; '/\\r}; v=${v//''/\\v}; local/l=$(( ${#v} - 2 )); printf '%s' "\$'${v:1:$l}'" }; local vname vnamePattern vnames=("$@") allVnames=() matchPatterns=0 countOk=0 patternMatched=0 warnBashVars=0; for vname in "${vnames[@]}"; do if [[ $vname == *[][*?]* ]]; then matchPatterns=1; break; fi; done; if (( $# == 0 || matchPatterns )); then if [[ $BASH_VERSINFO -lt 4 ]]; then local allVnames=($(declare -p | LC_ALL=C sed -n -E -e '1,/^[^=]+\(\)/p' | LC_ALL=C sed -E -n -e '/^[[:alnum:]_]+=/p' | LC_ALL=C awk -F '=' '{ print $1 }')); else local allVnames=($(declare -p | LC_ALL=C egrep '^declare -' | cut -d ' ' -f 3- | cut -d '=' -f 1)); fi; allVnames+=('-'); if (( $# == 0 )); then vnames=("${allVnames[@]}"); else vnamesWithPatterns=("${vnames[@]}"); vnames=(); local mustReset=$(shopt -q nocasematch; echo $?); shopt -s nocasematch; for vnamePattern in "${vnamesWithPatterns[@]}"; do if [[ $vnamePattern == *[][*?]* ]]; then patternMatched=0; for vname in "${allVnames[@]}"; do [[ "$vname" == $vnamePattern ]] && { vnames+=("$vname"); patternMatched=1 }; done; (( patternMatched )) || { echo "WARNING: No variables match pattern: $vnamePattern" 1>&2 }; else vnames+=("$vnamePattern"); fi; done; (( mustReset )) && shopt -u nocasematch; fi; fi; for vname in "${vnames[@]}"; do if [[ $vname == '-' ]]; then echo "-=$- # -r"; else [[ $vname == 'BASH_'* && ! ( $vname == 'BASH_REMATCH' || $vname == 'BASH_VERSION' || $vname == 'BASH_VERSINFO' ) || $vname == '_' ]] && { warnBashVars=1; continue }; local vdef=$(declare -p "$vname" 2> /dev/null); if [[ -z $vdef ]]; then if (( $# )); then echo "WARNING: Variable '$vname' is not defined." 1>&2; fi; else local vdef=${vdef#declare }; local attrs vval; IFS=' =' read -d '' -r attrs vname vval <<< "$vdef"; if [[ $vname == 'PIPESTATUS' ]]; then vval=$(declare -p pipeStatus | cut -d= -f2-); else if [[ $vname == 'BASH_REMATCH' ]]; then vval=$(declare -p bashReMatch | cut -d= -f2-); else vval=$(printf '%s' "$vval"); fi; fi; [[ $vname == 'IFS' ]] && vval=$(__pv_encodeCtrlChars "$vval"); printf '%s' "$vname=$vval"; attrs=${attrs/a/}; [[ -n $attrs && $attrs != '--' && $attrs != '-' ]] && printf " # $attrs"; printf '\n'; (( ++countOk )); fi; fi; done; (( warnBashVars )) && echo "WARNING: Cannot report true value of \$_ and some \$BASH_* variables due to technical limitations."' '"Use \`echo \"\$BASH_...\"\` instead; e.g., \`echo \"\${BASH_SOURCE[@]}\"\`." 1>&2; return $(( countOk == 0 )) } ql () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat < /dev/null } resetcolors () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; return 2 }; printf '\e[0m' } resume-script () { [[ -z $1 || $1 == '-h' || $1 == '--help' ]] && { echo "Usage: $FUNCNAME scriptFileName ..."' '"Resumes the specified bash/sh script(s)."; return $(( ${#1} == 0 )) }; local ec=0; for p in "$@"; do pkill -CONT -nf '/?(bash|sh)[ ]+(.*/)?'"$p"'( |$)' && echo "'$1' resumed." || { ec=$?; echo "ERROR: bash/sh script process not found: '$p'" 1>&2 }; done; return $ec } sl () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2 && return 1 ;; *) break ;; esac; shift; done; [[ -z "$1" ]] && echo -e "$FUNCNAME: PARAMETER ERROR: Too few parameters specified. Use -h or --h to get help." 1>&2 && return 1; local allTokens; if (( !optNoTotal && ${#@} >=2 )); then local allTokens=$*; fi; local totalLen=0; local result=''; while (( ${#@} )); do local len=${#1}; (( totalLen+=len )); result="${result}'$1': $len"' '; shift; done; if [[ -n "$allTokens" ]]; then echo "Total: ${#allTokens}/$totalLen (with/without interior spaces)"; fi; echo -n "$result" } stripColors () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&2; return 2 }; LC_ALL=C sed -E 's/'''\[([0-9]{1,2})?(;[0-9]{1,2})*m//g' } stripFormatting () { if [[ $(uname) == 'Linux' ]]; then stripColors | col -b; else stripColors | LC_ALL=C col -b; fi } suspend-script () { [[ -z $1 || $1 == '-h' || $1 == '--help' ]] && { echo "Usage: $FUNCNAME scriptFileName ..."' '"Suspends the specified bash/sh script(s)."; return $(( ${#1} == 0 )) }; local ec=0; for p in "$@"; do pkill -STOP -nf '/?(bash|sh)[ ]+(.*/)?'"$p"'( |$)' && echo "'$1' suspended." || { ec=$?; echo "ERROR: bash/sh script process not found: '$p'" 1>&2 }; done; return $ec } tc () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&1 | $FUNCNAME' instead of just '| $FUNCNAME'. - With COMMAND specified, executes it, and copies its stdout output to the clipboard using 'pbcopy'. To capture commands involving pipes and stdout/err redirection, use the postpositional form instead. If COMMAND returns an error, it is reported, and nothing is copied to the clipboard. No stdout output is displayed by default. Pass -p (--passthru) as the 1st argument to also echo what was captured. A nonzero exitcode, possibly accompanied by an error message, indicates failure. Examples: ls | $FUNCNAME $FUNCNAME ls EOF return 0; fi [[ $1 == '-p' || $1 =~ ^--?[Pp][Aa][Ss][Ss][Tt][Hh][Rr][Uu]$ ]] && { local passThru=1; shift }; if (( $# )); then local ftemp=$(mktemp -t "$FUNCNAME"); ( eval "$@" > "$ftemp" ); local ec=$?; (( ec != 0 )) && rm "$ftemp" && echo '(Nothing was copied to clipboard.)' 1>&2 && return $ec; echo -En "$( < "$ftemp" )" | pbcopy; rm "$ftemp"; else pbcopy || return; fi; (( passThru )) && pbpaste } tobin () { local n; for n in "$@"; do bc <<< "obase=2;$(( n ))"; done } todec () { local outputBaseSpecChar='d'; _tobase "$@" } tohex () { local outputBaseSpecChar='x'; _tobase "$@" } tooct () { local outputBaseSpecChar='o'; _tobase "$@" } trim () { var=$1; var="${var#"${var%%[![:space:]]*}"}"; var="${var%"${var##*[![:space:]]}"}"; echo -n "$var" } typex () { case $1 in -h | --help | --version | --man | --man-source | --home) "$__typex_scriptpath" "$@"; return ;; esac; function __typex_rreadlinkchain () { ( command typeset target="$1" targetDir= targetName= CDPATH=; unalias cd pwd readlink dirname basename printf 2> /dev/null; unset -f cd pwd readlink dirname basename printf 2> /dev/null; while :; do [[ -L $target || -e $target ]] || { printf '%s\n' "typex: WARNING: '$target' does not exist." 1>&2; return 1 }; cd "$(dirname -- "$target")"; targetDir=$PWD; targetName=$(basename -- "$target"); [[ $targetName == '/' ]] && targetName=''; done=0; if [[ ! -L $targetName ]]; then targetDir=$(pwd -P); done=1; fi; printf '%s\n' "${targetDir%/}/$targetName"; (( done )) && break; target=$(readlink -- "$targetName"); done ) }; function __typex_getFileTimestamp () { command typeset file="$1" kind="${2:-m}" outFmt="$3" fmtOptChar= fmtChar= osNdx=; osNdx=0; [[ $(command uname) == 'Linux' ]] && osNdx=1; fmtOptChar='fc'; case "$kind" in m) fmtChar='mY' ;; a) fmtChar='aX' ;; b) fmtChar='BW' ;; c) fmtChar='cZ' ;; *) return 1 ;; esac; ts=$(command stat -${fmtOptChar:$osNdx:1} "%${fmtChar:$osNdx:1}" "$file") || return; if [[ -n $outFmt ]]; then case $osNdx in 0) command date -j -f '%s' "$ts" +"$outFmt" || return ;; 1) command date -d @"$ts" +"$outFmt" || return ;; esac; else command printf '%s\n' "$ts"; fi }; function __typex_reMatch () { command typeset ec= outVar="${3:-__typex_reMatch}"; unset -v "$outVar"; [[ $1 =~ $2 ]]; ec=$?; if [[ $ec -eq 0 ]]; then [[ -n $BASH_VERSION ]] && eval "$outVar"'=( "${BASH_REMATCH[@]}" )'; [[ -n $KSH_VERSION ]] && eval "$outVar"'=( "${.sh.match[@]}" )'; [[ -n $ZSH_VERSION ]] && eval "$outVar"'=( "$MATCH" "${match[@]}" )'; fi; return $ec }; function __typex_reQuote () { command sed 's/[^^]/[&]/g; s/\^/\\^/g' <<< "$*" }; function __typex_install () { command typeset targetShellFilename=$1 install=$2 runningStandalone=$3 scriptFileAbsPath=$4; command typeset verbose=1 scriptFileAbsPathQ= initFile= instLineRegEx= found=0 cmd= cmt= ec= newContents=; command typeset dir=${TYPEX_TEST_INITFILE_DIR:-~}; case "$targetShellFilename" in 'bash') [[ $(uname) == 'Darwin' ]] && initFile="$dir/.bash_profile" || initFile="$dir/.bashrc" ;; 'ksh') initFile="$dir/.kshrc" ;; 'zsh') initFile="$dir/.zshrc" ;; *) printf '%s\n' "ERROR: ${scriptFileAbsPath##*/} can only be sourced in bash, ksh, or zsh -- $targetShell is not supported." 1>&2; return 2 ;; esac; scriptFileAbsPathQ=$(command printf '%q' "$scriptFileAbsPath"); cmd="[[ -f $scriptFileAbsPathQ ]] && . $scriptFileAbsPathQ"; cmt="# Added by ${scriptFileAbsPath##*/} -i; ${scriptFileAbsPath##*/} -u to remove."; instLineRegEx='^[[:space:]]*'"$(__typex_reQuote "$cmd")"'([[:space:]]|$)'; [[ -f $initFile ]] && command grep -Eq "$instLineRegEx" "$initFile" && found=1; ec=0; if (( install )); then if (( found )); then (( verbose )) && command printf '%s\n' "(Sourcing command for '$scriptFileAbsPath' already present in '$initFile'; nothing to do.)"; else printf '\n%s %s\n' "$cmd" "$cmt" >> "$initFile"; ec=$?; fi; else if (( ! found )); then (( verbose )) && command printf '%s\n' "(Sourcing command for '$scriptFileAbsPath' not present in '$initFile'; nothing to do.)"; else newContents=$(command grep -Ev "$instLineRegEx" "$initFile") && command printf '%s\n' "$newContents" > "$initFile"; ec=$?; unset -f ${scriptFileAbsPath##*/} 2> /dev/null; fi; fi; if (( install )); then if (( ec == 0 )); then command printf '%s\n' "Sourcing of '$scriptFileAbsPath' installed in '$initFile'."; else command printf '%s\n' "ERROR: Failed to install sourcing of '$scriptFileAbsPath' in '$initFile'; please manually add line '. $scriptFileAbsPath'." 1>&2; fi; else if (( ec == 0 )); then command printf '%s\n' "Sourcing of '$scriptFileAbsPath' uninstalled from '$initFile'."; else command printf '%s\n' "ERROR: Failed to uninstall sourcing of '$scriptFileAbsPath' from '$initFile'; please manually remove the line containing '. $scriptFileAbsPath'." 1>&2; fi; fi; return $ec }; function __typex_init () { [[ -n $ZSH_VERSION ]] && { __typex_prevPosixBuiltinsOptState=${options[posixbuiltins]}; options[POSIX_BUILTINS]=on; __typex_prevKshArrayEmulationOptState=${options[ksharrays]}; options[ksharrays]=on } || unset __typex_prevPosixBuiltinsOptState __typex_prevKshArrayEmulationSOpttate }; function __typex_restore () { [[ -n $__typex_prevPosixBuiltinsOptState ]] && options[posixbuiltins]=$__typex_prevPosixBuiltinsOptState; [[ -n $__typex_prevKshArrayEmulationOptState ]] && options[ksharrays]=$__typex_prevKshArrayEmulationOptState }; __typex_init; command typeset thisFuncName=$([[ -n $BASH_VERSION ]] && command printf %s "$FUNCNAME" || command printf %s "$0"); command typeset notSourced=0; [[ $1 == '--not-sourced' ]] && { shift; notSourced=1 }; command typeset all=1; command typeset CDPATH= numNotFound=0 name= names= isExplicitPath=0 isKeyword=0 keywordOutput= def= found=0 isBuiltIn=0 specialFileType= brokenSymlink=0 extraOpt= files= file= thisfile= fileCategory= fileType= scriptType= ver= fileLinkChain= trueFile= errMsgSuffix= shell=; command typeset fileSystemOnly=0 noVersion=0 verbose=0 install=0 uninstall=0; command typeset allowOptsAfterOperands=1 i=0 optName= isLong=0 prefix= optArg= haveOptArgAttached=0 haveOptArgAsNextArg=0 acceptOptArg=0 needOptArg=0; command typeset -a operands; __typex_reMatch=; while (( $# )); do if __typex_reMatch "$1" '^(-)[a-zA-Z0-9]+.*$' || __typex_reMatch "$1" '^(--)[a-zA-Z0-9]+.*$'; then prefix=${__typex_reMatch[1]}; [[ $prefix == '--' ]] && isLong=1 || isLong=0; for ((i = 1; i < (isLong ? 2 : ${#1}); i++ )) do command typeset acceptOptArg=0 needOptArg=0 haveOptArgAttached=0 haveOptArgAsNextArg=0 optArgAttached= optArgOpt= optArgReq=; if (( isLong )); then optName=${1:2}; __typex_reMatch "$optName" '^([^=]+)=(.*)$' && { optName=${__typex_reMatch[1]}; optArgAttached=${__typex_reMatch[2]}; haveOptArgAttached=1 }; else optName=${1:$i:1}; optArgAttached=${1:$i+1}; (( ${#optArgAttached} >= 1 )) && haveOptArgAttached=1; fi; (( haveOptArgAttached )) && optArgOpt=$optArgAttached optArgReq=$optArgAttached || { (( $# > 1 )) && { optArgReq=$2; haveOptArgAsNextArg=1 } }; case $optName in p | files-only) fileSystemOnly=1 ;; v | verbose) verbose=1 ;; V | skip-version) noVersion=1 ;; i | install-sourcing) install=1 ;; u | uninstall-sourcing) uninstall=1 ;; *) { echo "$thisFuncName: ARGUMENT ERROR: Unknown option: ${prefix}${optName}" 1>&2; __typex_restore; return 2 } ;; esac; (( needOptArg )) && { (( ! haveOptArgAttached && ! haveOptArgAsNextArg )) && { echo "$thisFuncName: ARGUMENT ERROR: Option ${prefix}${optName} is missing its argument." 1>&2; __typex_restore; return 2 } || (( haveOptArgAsNextArg )) && shift }; (( acceptOptArg || needOptArg )) && break; done; else if [[ $1 == '--' ]]; then shift; operands+=("$@"); break; else if (( allowOptsAfterOperands )); then operands+=("$1"); else operands=("$@"); break; fi; fi; fi; shift; done; (( ${#operands[@]} > 0 )) && set -- "${operands[@]}"; unset allowOptsAfterOperands operands i optName isLong prefix optArgAttached haveOptArgAttached haveOptArgAsNextArg acceptOptArg needOptArg; if (( install || uninstall )); then (( !fileSystemOnly && !noVersion && !(install && uninstall) && $# == 0 )) || { echo "$thisFuncName: ARGUMENT ERROR: Incompatible options specified." 1>&2; __typex_restore; return 2 }; (( uninstall )) && install=0; command typeset shellCount=0 okCount=0; for shell in bash ksh zsh; do (( ++shellCount )); if [[ $TYPEX_TEST_ALL_INITFILES != '1' ]]; then if [[ -n $ZSH_VERSION ]]; then command which -p $shell > /dev/null 2>&1 || continue; else command which $shell > /dev/null 2>&1 || continue; fi; fi; __typex_install $shell $install $notSourced "$__typex_scriptpath" && (( ++okCount )); done; (( install && okCount )) && command printf '%s\n' 'Open a new shell tab or window for sourcing to take effect.'; if (( okCount == shellCount )); then __typex_restore; return 0; else __typex_restore; return $(( shellCount - okCount )); fi; fi; if (( $# == 0 )); then names=($(f=$(command ps -o comm= $( (( notSourced )) && command printf $PPID || command printf $$ )); [[ $f =~ ^- ]] && command printf %s "$SHELL" || command printf %s "$f")); fileSystemOnly=1; else names=("$@"); fi; if (( ! fileSystemOnly )); then fileSystemOnly=1; for name in "${names[@]}"; do [[ $name == */* ]] || { fileSystemOnly=0; break }; done; fi; if (( ! fileSystemOnly && notSourced )); then fileSystemOnly=1; if __typex_isParentSupportedShell; then command cat 1>&2 <\` To install sourcing persistently for interactive shells, run \`${__typex_scriptpath##*/} -i\`. Use \`-p\` to suppress this warning if you're only looking for executable *files*. EOF else command cat 1>&2 < /dev/null | command egrep -q ' keyword$' && isKeyword=1; else if [[ -n $ZSH_VERSION ]]; then command type -wa "$name" 2> /dev/null | command egrep -q ' reserved$' && isKeyword=1; else command type -ta "$name" 2> /dev/null | command fgrep -qx 'keyword' && isKeyword=1; fi; fi; if (( isKeyword )); then found=1; keywordOutput=$(command printf '%-10s %s' 'KEYWORD:' "$name"); fi; if [[ -n $keywordOutput && -n $KSH_VERSION ]]; then command printf '%s\n' "$keywordOutput"; fi; def=$(command alias "$name" 2>/dev/null); if [[ -n $def ]]; then found=1; command printf '%-10s %s\n' 'ALIAS:' "${def#alias }"; (( all )) || { __typex_restore; return 0 }; def=$(cut -d= -f2- <<<"$def" | tr -d \'\" | cut -d' ' -f1); typex -- "$def" 2> /dev/null | sed 's/^/ /'; fi; if [[ -n $keywordOutput && -z $KSH_VERSION ]]; then command printf '%s\n' "$keywordOutput"; fi; def=$(command typeset -f "$name" 2>/dev/null); if [[ -n $def ]]; then found=1; command printf '%-10s %s' 'FUNCTION:' "$name()"; if [[ -n $BASH_VERSION ]]; then command declare -F | command egrep -q -- "-fx $name\$" && command printf ' # -x'; fi; command printf '\n'; (( verbose )) && command sed 's/^/ /' <<< "$def"; (( all )) || { __typex_restore; return 0 }; fi; if [[ -n $KSH_VERSION ]]; then command builtin | command fgrep -qx -- "$name" && isBuiltIn=1; else if [[ -n $ZSH_VERSION ]]; then command type -wa -- "$name" 2> /dev/null | command egrep -q ':\s+builtin$' && isBuiltIn=1; else command type -ta -- "$name" 2> /dev/null | command fgrep -qx 'builtin' && isBuiltIn=1; fi; fi; if (( isBuiltIn )); then command printf '%-10s %s\n' 'BUILTIN:' "$name"; (( all )) || { __typex_restore; return 0 }; found=1; fi; fi; files=; if (( isExplicitPath )) || [[ $name == '.' ]]; then if [[ -d $name ]]; then files=$(command cd "$name" && command echo "$PWD"); else if [[ -e $name || -L $name ]]; then [[ ! -e $name ]] && brokenSymlink=1; [[ -n $KSH_VERSION && $name =~ ^'../.' ]] && name="${PWD%/}/$name"; files=$(command cd -- "$(command dirname -- "$name")" && command echo "${PWD%/}/")$(command basename -- "$name"); [[ $files =~ / ]] || { __typex_restore; return 1 }; else :; fi; fi; else if [[ -n $ZSH_VERSION ]]; then files=$(command which -ap -- "$name" 2>/dev/null) || files=''; else files=$(command which -a -- "$name" 2>/dev/null) || files=''; fi; fi; if [[ -n $files ]]; then found=1; while command read -r file; do (( brokenSymlink )) || extraOpt='-L'; fileType=$(command file -b $extraOpt -- "$file"); if [[ -d $file ]]; then fileCategory='DIRECTORY:'; else if [[ -x $file ]]; then scriptType=$(command egrep -o '(POSIX )?(\w+ )script' <<<"$fileType"); [[ -z $scriptType ]] && command egrep -q '\' <<< "$fileType" && scriptType='script w/o shebang line'; [[ -n $scriptType ]] && fileCategory='SCRIPT:' || fileCategory='BINARY:'; else fileCategory='FILE:'; fi; fi; fileLinkChain=$(__typex_rreadlinkchain "$file"); if [[ ! $fileLinkChain =~ ' ' ]]; then trueFile=$fileLinkChain; if [[ "$file" != "$trueFile" ]]; then command printf '%-10s %s -> %s' "$fileCategory" "$file" "$fileLinkChain"; else command printf '%-10s %s' "$fileCategory" "$file"; fi; else trueFile=$(command tail -n 1 <<<"$fileLinkChain"); command printf '%-10s %s' "$fileCategory" "$(command awk -v RS= -v sep=' -> ' '{ gsub("\n$", ""); gsub("\n", "@" sep); printf "%s", $0 }' <<<"$fileLinkChain")"; fi; if [[ -d $file ]]; then :; else if [[ -x $file ]]; then [[ -n $scriptType ]] && printf ' (%s)' "$scriptType"; ver=; if (( ! noVersion )); then ver=$("$file" --version &1 | command sed '/^$/d; q' | command fgrep -v -- '--version' | command fgrep -vi -- 'unknown invalid illegal unrecognized not recognized' | command egrep -i -e '[0-9]\.' -e 'version' -e 'build' ); fi; [[ -z $ver ]] && ver=$(__typex_getFileTimestamp "$trueFile" m '%Y-%m-%d'); printf ' [%s]' "$ver"; else printf ' (%s)' "$fileType"; fi; fi; if (( verbose )); then while command read -r thisfile; do command printf '\n %s' "$(command ls -dFAhl -- "$thisfile" | command cut -d/ -f1)"; done <<< "${fileLinkChain:-$file}"; if [[ ! -d $file ]]; then if [[ -n $scriptType ]]; then command printf '\n %s' "$(command head -n 1 "$file")"; else if [[ -x $file ]]; then command printf '\n %s' "$(sed '1! s/^/ /' <<<"$fileType")"; fi; fi; fi; fi; command printf '\n'; (( all )) || break; done <<< "$files"; fi; if (( ! found )); then (( ++numNotFound )); if (( isExplicitPath )); then errMsgSuffix=": No such file or directory, or insufficient permissions for inspection."; else (( fileSystemOnly )) && errMsgSuffix=' is not an executable in the PATH.' || errMsgSuffix=' is neither an alias, keyword, function, builtin, nor an executable in the PATH.'; [[ -e $name ]] && errMsgSuffix+=' However, it does exist as a filesystem item in the current directory. To target that, prefix with "./"'; fi; command printf '%s\n' "$thisFuncName: \"${name}\"${errMsgSuffix}" 1>&2; fi; done; __typex_restore; return $numNotFound } up () { local dir='../'; [[ "$1" == '-h' || "$1" == '--help' ]] && { echo -e "usage:\n\t$FUNCNAME [n]\n\t$FUNCNAME dirname\n Moves up N levels in the path to the current working directory, 1 by default.\n If DIRNAME is given, it must be the full name of an ancestral directory (case does not matter).\n If there are multiple matches, the one *lowest* in the hierarchy is changed to." && return 0 }; if [[ -n "$1" ]]; then if [[ $1 =~ ^[0-9]+$ ]]; then local strpath=$( printf "%${1}s" ); dir=${strpath// /$dir}; else if [[ $1 =~ ^/ ]]; then dir=$1; else local wdLower=$(echo -n "$PWD" | tr '[:upper:]' '[:lower:]'); local tokenLower=$(echo -n "$1" | tr '[:upper:]' '[:lower:]'); local newParentDirLower=${wdLower%/$tokenLower/*}; [[ "$newParentDirLower" == "$wdLower" ]] && { echo "$FUNCNAME: No ancestral directory named '$1' found." 1>&2; return 1 }; local targetDirPathLength=$(( ${#newParentDirLower} + 1 + ${#tokenLower} )); dir=${PWD:0:$targetDirPathLength}; fi; fi; fi; pushd "$dir" > /dev/null } vmrun () { "/Applications/VMware Fusion.app/Contents/Library/vmrun" "$@" } vo () { if [[ "$1" == '--help' || "$1" == '-h' ]]; then cat <&1 | $FUNCNAME' instead of just '| $FUNCNAME'. - With COMMAND specified, executes it, and captures both its stdout and stderr output. If COMMAND returns a nonzero exit code, a warning is printed to stderr. This utility itself, however, always returns exit code 0. If the output captured contains ANSI color escape sequences or troff formatting such as from `man` output, such formatting is automatically removed. Examples: $FUNCNAME ls *.txt nosuch ls *.txt nosuch | $FUNCNAME ls *.txt nosuch 2>&1 | $FUNCNAME EOF return 0; fi local ph=''; [[ $(uname) == 'Darwin' ]] || ph='.XXXXXXXXXX'; local ftemp=$(mktemp -t "$FUNCNAME$ph"); if (( $# )); then ( shopt -s expand_aliases; eval "$@" 2>&1 | stripFormatting > "$ftemp"; [[ ${PIPESTATUS[0]} -eq 0 ]] || echo "$FUNCNAME: WARNING: Command returned nonzero exit code: ${PIPESTATUS[0]}" 1>&2 ); else cat | stripFormatting > "$ftemp"; fi; local editor=$(which -a subl code | fgrep -v -x "$MK_UTIL_FOLDER/subl" | head -n 1); [[ -n $editor ]] || { echo "ERROR: Neither \`code\` nor \`subl\` are in your PATH." 2> /dev/null; exit 1 }; local newWin=1; (( newWin )) && newWinOpt=--new-window; ( { "$editor" --wait $newWinOpt "$ftemp"; rm -f "$ftemp" } & ) } doIt hi