Little bits of tips ʼnʼ tricks I want to keep around.
You may find it useful too sometimes ^.^
Print side-by-side: pr -mtw $(tput cols)
Type decimal numbers, echo and copy hexadecimal escapes:
cat (echo "obase=16" | psub) - | bc | xargs -I % -n 1 bash -c "echo -n \\\\x% | pbcopy; echo \\\\x%"
watchexec
to watch files & directories and then rerun make
or whatnot. better than entr
pipe into sponge filename.txt
if filename.txt
is used earlier in the command (since output redirection erases the file)
pbpaste
/pbcopy
(stdout/stdin only)/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk -F' SSID: ' '/ SSID: / {print $2}'
xkbset ma 60 10 10 5 2
git clone --filter=blob:none <url>
is a new better alternative to git clone --depth=1 <url>
(with git clone --filter=tree:0 <url>
skipping downloading trees but not recommended for dev work since it will redownload trees more often than necessary)
git push --set-upstream origin $(git branch --show-current)
View history of file (commits + patches): git log -p -- foo.sh
Local/private version of .gitignore
: .git/info/exclude
Remove untracked and/or ignored files via git clean
:
git clean -f
, dry-run: git clean -n
git clean -fX
, dry-run: git clean -nX
git clean -fx
, dry-run: git clean -nx
Current branch name: git branch --show-current
Upstream for current branch (pretty name): git rev-parse --abbrev-ref --symbolic-full-name @{upstream}
See what changes you are about to push: git diff @{u} HEAD
Explanation
First it finds the upstream @{u}
/@{upstream}
for the current branch.
HEAD
means to compare against the currently committed changes, not whatever files are in your working tree.
ctrl+b
then d
.tmux a
.ctrl+b
then s
.new URLSearchParams(window.location.search).{get,getAll,has,entries,...}(...)
.entries
returns an iterator??POST JSON to server:
fetch('localhost', {
method: 'POST', body: JSON.stringify(yourData),
headers: { "Content-Type": "application/json" },
.then(r => r.json()); })
NODE_OPTIONS='--stack-trace-limit=10000'
util.inspect.defaultOptions.depth = null;
(no commandline option :sad:)io:format(user, <<"~p~n">>, [Object])
in tests and rp(Object).
in the REPLf(VarName)
to unbind a variable in the REPL, f()
to unbind them all.cd -- "$(dirname $0)"
Simple argument handling:
case "$1" in
"--no-build")
shift 1;;
*)
make;;
esac
Conditionals, flags like -e
, -f
: https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html
cd (dirname (status -f))
(or status --current-filename
)
(do I need quotes? did we fix that in fish?)
Compare directory listings, excluding hidden files
git diff --no-index (cd $ROOT1; find . -not -path '*/\.*' -type f | sort | psub) (cd $ROOT2; find . -not -path '*/\.*' -type f | sort | psub)
Nix test installation:
nix-shell -p nix-info --run "nix-info -m"
@lang:markdown
.
This will apply those settings to that language specifically!
"[markdown]": { ... your settings ... }
.~/.vscode-oss/extensions
~/.vscode/extensions
/Applications/VSCodium.app/Contents/Resources/app/extensions
/Applications/VSCode.app/Contents/Resources/app/extensions
codium --list-extensions
& codium --install-extension
Keybinds for ctrl+(shift)+tab to just switch tabs, no “most recently used” switcher:
Details
From “Is there a quick change tabs function in Visual Studio Code?”:
[
{
"key": "ctrl+tab",
"command": "workbench.action.nextEditorInGroup"
},
{
"key": "ctrl+shift+tab",
"command": "workbench.action.previousEditorInGroup"
},
]
(or workbench.action.{next,previous}Editor
to have it apply across windows instead of wrapping around)
By default, Ctrl+Tab in Visual Studio Code cycles through tabs in order of most recently used. This is confusing because it depends on hidden state.
Web browsers cycle through tabs in visible order. This is much more intuitive.
Right click to add file in same parent folder (extension)
Alt+up/down to reorder lines
Alt+click for multiselect
re
in a markdown makes syntax highlighting wonky: it turns out to be caused by the extension file ocamllabs.ocaml-platform-1.*.*-universal/syntaxes/reason-markdown-codeblock.json
, so you can just delete that whole file (you will have to do this at every update).p
/Space
to pauses
to step to next frameSum durations of A/V media (.mp3
s in this case):
for f in *.mp3; ffprobe -show_entries format=duration -v quiet -i $f | grep -oE '[[:digit:].]+'; end | awk '{s+=$1} END {print s}'
Alt + right click > open the app once, the security dialog will now have an “Open” button, and then it will be fine.“VSCodium.app” can’t be opened because Apple cannot check it for malicious software.