This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Context: | |
Pass array to function, where one or more elements of the array have embedded spaces. | |
Goal: Have the embedded spaces respected in the array processed by the function. | |
############### The script | |
#!/usr/bin/env bash | |
set -eu | |
function echo_passed_array() { | |
list_of_options=("$@") | |
echo "List of options [0]: ${list_of_options[0]}" | |
echo "List of options [1]: ${list_of_options[1]}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Context: | |
Pass array to function, where one or more elements of the array have embedded spaces. | |
Moreover, script seeks a nonnumeric result from function; uses command substitution to call the function. | |
For the case without command substitution, see https://gist.github.com/jimratliff/ddcb5eb7e6fb184840e5dfd7e240c7ee | |
Goal: Have the embedded spaces respected in the array processed by the function. | |
############### The script | |
#!/usr/bin/env bash | |
set -eu | |
function echo_passed_array() { | |
list_of_options=("$@") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################################################################## | |
#!/usr/bin/env bash | |
# | |
# ANSI Rainbow | |
# See, e.g., "How to change the output color of echo in Linux", Stack Overflow, 5/10/2011 | |
# https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux | |
for (( i = 30; i < 38; i++ )); do echo -e "\033[0;"$i"m Normal: (0;$i); \033[1;"$i"m Light: (1;$i)"; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example: Bash function returns multiple values, passed via command substitution, | |
# with a READ command and Here string in calling script | |
#!/usr/bin/env bash | |
set -e #Stop on any errors | |
function inside_function() { | |
yvariable1="8" | |
yvariable2="64" | |
echo $yvariable1 $yvariable2 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################################################################## | |
#!/usr/bin/env bash | |
# | |
# Script to determine empirically the extent to which a variable set in a script or | |
# function can be seen by a hierarchically related function or script | |
# Specifically, (a) main script calls (b) function level1(), which calls | |
# function level2(). (No arguments are used in any function call.) | |
# Scalar variables are set in each component prior to any function call: | |
# Main script sets $set_in_main_x, for x ∈ {A,B,C} | |
# Function level1() sets $set_in_level_1_x, for x ∈ {A,B,C} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See also the help for plutil, which discloses additional options not disclosed in the man page | |
# For the help content, see https://gist.github.com/jimratliff/71414b2896e1b5feb40038ce688205de | |
PLUTIL(1) BSD General Commands Manual PLUTIL(1) | |
NAME | |
plutil -- property list utility | |
SYNOPSIS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PLISTBUDDY(8) BSD System Manager's Manual PLISTBUDDY(8) | |
NAME | |
PlistBuddy -- read and write values to plists | |
SYNOPSIS | |
PlistBuddy [-cxh] file.plist | |
DESCRIPTION | |
The PlistBuddy command is used to read and modify values inside of a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This help for plutil discloses additional options not disclosed in the man page | |
# For the man page, see https://gist.github.com/jimratliff/daeba692a66d2683b35d193e08b800b0 | |
$ plutil -help | |
plutil: [command_option] [other_options] file... | |
The file '-' means stdin | |
Command options are (-lint is the default): | |
-help show this message and exit | |
-lint check the property list files for syntax errors | |
-convert fmt rewrite property list files in format |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Keyboard Label | Character | ASCII code (Parameter #1) | Mac Virtual Key Code (Parameter #2) | Layout dependence? | |||
---|---|---|---|---|---|---|---|
0 | 0 | 48 | 029 | ANSI-US | |||
1 | 1 | 49 | 018 | ANSI-US | |||
2 | 2 | 50 | 019 | ANSI-US | |||
3 | 3 | 51 | 020 | ANSI-US | |||
4 | 4 | 52 | 021 | ANSI-US | |||
5 | 5 | 53 | 023 | ANSI-US | |||
6 | 6 | 54 | 022 | ANSI-US | |||
7 | 7 | 55 | 026 | ANSI-US |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Last login: Sun Apr 22 10:04:40 on ttys001 | |
Primary-MBPR:~ playground1$ defaults read com.apple.symbolichotkeys | |
{ | |
AppleSymbolicHotKeys = { | |
15 = { | |
enabled = 0; | |
}; | |
16 = { | |
enabled = 0; | |
}; |
OlderNewer