Skip to content

Commit daa657e

Browse files
committed
Merge branch 'master' of github.com:AndrewRayCode/configs
2 parents 6457747 + d9a36c9 commit daa657e

2 files changed

Lines changed: 64 additions & 14 deletions

File tree

.bashrc

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,12 +1225,12 @@ lbl() {
12251225
fi
12261226
}
12271227

1228-
# Execute an apex statement against an environment
1229-
stmt() {
1228+
# Execute an apex expression against an environment
1229+
exp() {
12301230
if [[ -z "$1" ]] || [[ -z "$2" ]]; then
1231-
echo "Execute a statement, and print the output. Takes the apex statement you pass in and wraps it in a System.debug() call."
1231+
echo "Execute an expression, and print the output. Takes the apex expression you pass in and wraps it in a System.debug() call."
12321232
echo "Pass quiet or q as the last paremeter to supress notification messages"
1233-
echo "Usage: stmt [ORG_ID] [STATEMENT_TO_EVALUATE] ['quiet' | 'q']"
1233+
echo "Usage: exp [ORG_ID] [EXPRESSION_TO_EVALUATE] ['quiet' | 'q']"
12341234
return 1
12351235
fi
12361236

@@ -1253,10 +1253,60 @@ stmt() {
12531253
# We need to find from the start of USER_DEBUG to the next non-debug line.
12541254
# Notice "b" is put on a line by itself, making it tricky to include in output
12551255

1256-
sfdx force:apex:execute -u "${1}" -f /dev/stdin<<<"$apexCommand" | # Execute the statement inside a system.debug(). execute expects a file, so use <<< trick to make it seem like a file
1256+
sfdx force:apex:execute -u "${1}" -f /dev/stdin<<<"$apexCommand" | # Execute the expression inside a system.debug(). execute expects a file, so use <<< trick to make it seem like a file
12571257
pcregrep -M 'USER_DEBUG(.|\n)+?([\d]{2}:[\d]{2}:[\d]{2})' | # find debug line, and try to search up to the next apex ouptut line, starting with dd:dd:dd
12581258
sed '$d' | # remove the last line, which is the first non-debug line
12591259
sed 's/.*\|//' # find everything after the last pipe, which will be the debugged output
12601260
}
12611261

1262+
# Execute an apex expression against an environment
1263+
stmt() {
1264+
if [[ -z "$1" ]] || [[ -z "$2" ]]; then
1265+
echo "Execute a statement or list of statements"
1266+
echo "Pass quiet or q as the last paremeter to supress notification messages"
1267+
echo "Usage: stmt [ORG_ID] [STATEMENT_TO_EVALUATE] ['quiet' | 'q']"
1268+
return 1
1269+
fi
1270+
1271+
local apexCommand
1272+
apexCommand=${2}
1273+
if [ "$3" != "quiet" ] && [ "$3" != "q" ]; then
1274+
>&2 echo "${COLOR_BLUE}${BOLD}Executing:${COLOR_RESET}"
1275+
>&2 echo "${COLOR_BLUE}${apexCommand}${COLOR_RESET}"
1276+
>&2 echo
1277+
fi
1278+
1279+
# Example apex output, to see what we're grepping for. Logs for the
1280+
# multline command System.debug('a\nb'):
1281+
# 11:38:56.11 (11521203)|EXECUTION_STARTED
1282+
# 11:38:56.11 (11525424)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
1283+
# 11:38:56.11 (11944606)|USER_DEBUG|[1]|DEBUG|a
1284+
# b
1285+
# 11:38:56.11 (11980694)|CUMULATIVE_LIMIT_USAGE
1286+
# 11:38:56.11 (11980694)|LIMIT_USAGE_FOR_NS|(default)|
1287+
# We need to find from the start of USER_DEBUG to the next non-debug line.
1288+
# Notice "b" is put on a line by itself, making it tricky to include in output
1289+
1290+
sfdx force:apex:execute -u "${1}" -f /dev/stdin<<<"$apexCommand" # Execute the statement inside a system.debug(). execute expects a file, so use <<< trick to make it seem like a file
1291+
}
1292+
1293+
alias lsorg='open https://grhc.lightning.force.com/lightning/setup/DataManagementCreateTestInstance/home'
1294+
function orgid() {
1295+
exp "$1" 'UserInfo.getOrganizationId()'
1296+
}
1297+
1298+
# Some normal junk
1299+
fzf_opts="--multi --layout=reverse --border"
1300+
1301+
# Preview files to the right, in bat for colorizing
1302+
fzf_opts="${fzf_opts} --preview 'bat --style=numbers --color=always {}'"
1303+
1304+
# Doesn't work?
1305+
# Make file list use ripgrep, which auto-ignores git and node_modules by default
1306+
# export FZF_DEFAULT_COMMAND='rg --files'
1307+
1308+
export FZF_DEFAULT_OPTS="$fzf_opts"
12621309
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
1310+
1311+
alias ga="git ls-files -m --exclude-standard | fzf --print0 -m | xargs -0 -t -o git add"
1312+

code/snippets/ecmascript.code-snippets

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"Console Log Parse": {
2727
"scope": "javascript,typescript",
28-
"prefix": "cjj",
28+
"prefix": "cj'",
2929
"body": [
3030
"console.log('$1', JSON.parse(JSON.stringify($1)))",
3131
],
@@ -63,12 +63,12 @@
6363
],
6464
"description": "Console log value name and value"
6565
},
66-
"Console Log Emoji 🔥": {
67-
"scope": "javascript,typescript",
68-
"prefix": "cc",
69-
"body": [
70-
"console.log('${1|🔥,❌,🚽,🌿,💙|}$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1')"
71-
],
72-
"description": "Make console output noticable"
73-
}
66+
"Console Log Emoji 🔥": {
67+
"scope": "javascript,typescript",
68+
"prefix": "cc",
69+
"body": [
70+
"console.log('${1|🔥,❌,🚽,🌿,💙|}$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1')"
71+
],
72+
"description": "Make console output noticable"
73+
}
7474
}

0 commit comments

Comments
 (0)