4 Commits 7d79b1e5c2 ... 4cf327c025

Author SHA1 Message Date
  Kyle P Davis 4cf327c025 fix: minor quoting shellcheck issue VS Code terminal tweaks in profile 2 years ago
  Kyle P Davis 3c80e3907b feat: more node aliases 2 years ago
  Kyle P Davis 4d9986769e refactor: group node aliases 2 years ago
  Kyle P Davis 6bb2787d2e fix: improve node-print error handling 2 years ago
1 changed files with 9 additions and 3 deletions
  1. 9 3
      .profile

+ 9 - 3
.profile

@@ -92,10 +92,16 @@ alias d="l"
 alias tree="tree -C -F"
 alias tree="tree -C -F"
 alias grep="grep --color --exclude-dir={.svn,.git,node_modules}"
 alias grep="grep --color --exclude-dir={.svn,.git,node_modules}"
 alias man='LESS_TERMCAP_md=$(tput bold && tput setaf 4 || :) LESS_TERMCAP_me=$(tput sgr0 || :) LESS_TERMCAP_mb=$(tput blink || :) LESS_TERMCAP_us=$(tput setaf 2 || :) LESS_TERMCAP_ue=$(tput sgr0 || :) LESS_TERMCAP_so=$(tput smso || :) LESS_TERMCAP_se=$(tput rmso || :) PAGER="${commands[less]:-$PAGER}" man'
 alias man='LESS_TERMCAP_md=$(tput bold && tput setaf 4 || :) LESS_TERMCAP_me=$(tput sgr0 || :) LESS_TERMCAP_mb=$(tput blink || :) LESS_TERMCAP_us=$(tput setaf 2 || :) LESS_TERMCAP_ue=$(tput sgr0 || :) LESS_TERMCAP_so=$(tput smso || :) LESS_TERMCAP_se=$(tput rmso || :) PAGER="${commands[less]:-$PAGER}" man'
-alias node-print="node -e 'let [,f=\".\",e=\"this\"]=process.argv,ctx; try{ctx=require(f)}catch{ctx=require(path.resolve(f))}; eval(\`(async function(){ with(this) return (\${e}); })\`).call(ctx).then(console.log,console.error)'"
-alias ts-node-print="TS_NODE_FILES=true node -r ts-node/register -e 'let [,f=\".\",e=\"this\"]=process.argv,ctx; try{ctx=require(f)}catch{ctx=require(path.resolve(f))} eval(\`(async function(){ with(this) return (\${e}); })\`).call(ctx).then(console.log,console.error)'"
 alias vi=vim
 alias vi=vim
 
 
+# aliases for node
+alias node-print="node -e 'let [,f=\".\",e=\"this\"]=process.argv,ctx; try{ctx=require(f)}catch{ctx=require(path.resolve(f))}; eval(\`(async function(){ with(this) return (\${e}); })\`).call(ctx).then(console.log,e=>{console.error(e);process.exit(1)})'"
+alias node-print-json="node -e 'let [,f=\".\",e=\"this\"]=process.argv,ctx; try{ctx=require(f)}catch{ctx=require(path.resolve(f))}; eval(\`(async function(){ with(this) return (\${e}); })\`).call(ctx).then(o=>console.log(JSON.stringify(o,null,2)),e=>{console.error(e);process.exit(1)})'"
+alias node-print-deep="node -e 'let [,f=\".\",e=\"this\"]=process.argv,ctx; try{ctx=require(f)}catch{ctx=require(path.resolve(f))}; eval(\`(async function(){ with(this) return (\${e}); })\`).call(ctx).then(o=>console.log(require(\"util\").inspect(o,{depth:process.env.DEPTH||Infinity})),e=>{console.error(e);process.exit(1)})'"
+alias node-print-repl="node -e 'let [,f=\".\",e=\"this\"]=process.argv,ctx; try{ctx=require(f)}catch{ctx=require(path.resolve(f))}; eval(\`(async function(){ with(this) return (\${e}); })\`).call(ctx).then((r)=>(console.log(r,\`\n = \\\$1\`),repl.start().context.\$1=r),e=>{console.error(e);process.exit(1)})'"
+alias env-ts-node="TS_NODE_FILES=true NODE_OPTIONS=\"-r ts-node/register \$NODE_OPTIONS\""
+alias ts-node-print="env-ts-node node-print"
+
 # color diffs
 # color diffs
 ! command -v colordiff >/dev/null  ||  alias diff="colordiff"
 ! command -v colordiff >/dev/null  ||  alias diff="colordiff"
 
 
@@ -174,7 +180,7 @@ if [ "$TERM_PROGRAM" = "vscode" ]; then
 		ABS_HOME="$(cd "$HOME" && pwd -P)"
 		ABS_HOME="$(cd "$HOME" && pwd -P)"
 		if [ "$ABS_HOME" != "$HOME" ]; then
 		if [ "$ABS_HOME" != "$HOME" ]; then
 			if [[ "$PWD" =~ $ABS_HOME* ]]; then
 			if [[ "$PWD" =~ $ABS_HOME* ]]; then
-				cd "$HOME${PWD##$ABS_HOME}" || :
+				cd "$HOME${PWD##"$ABS_HOME"}" || :
 			fi
 			fi
 		fi
 		fi
 	fi
 	fi