Just a collection of snippets I use often. Open for the world to see.
Contents
What it is | The command |
---|---|
CLI in the container | docker exec -it <CONTAINER> /bin/bash |
Stop all containers | docker stop $(docker ps -a -q) |
Show output to stdout | Attach -a to the docker run command |
In ~/.gitconfig
, add the [alias]
section:
[alias]
recent = log --oneline -5
undo = !echo "Undoing this commit: " && git log --oneline -1 && git reset --soft HEAD~1 && echo "" && echo "Most recent commits: " && git recent
bookmark = !git add . && git commit -m '---'
amend = commit --amend --no-edit
fileschanged = !read -p 'Starting hash: ' start_hash && git diff --name-only $start_hash
filesdeleted = !git log --diff-filter=D --summary | grep delete
trackedbranches = branch -vv
If you committed something you weren't supposed to and borked master, these steps will reset local to origin/master.
Important: You'll lose data, so make sure you know what you're losing before you do this:
git checkout master
git fetch origin
git reset --hard origin/master
Make the config change:
git config --global core.excludesfile ~/.gitignore_global
Then add the file you want to ignore to .gitignore_global
:
.shalom
Add this file to all your local repos, if you want.
Prune remote dry run.
(To run for real, just remove --dry-run
):
git remote prune origin --dry-run
Find local branches whose remote branches were pruned (has to be run in zsh):
git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}'
Cool. Now you can delete those branches ☝️ one by one.
gh pr list --state all \
--search "$(git for-each-ref --shell --format='%(refname)' refs/heads/ | sed "/'refs\\/heads\\/master'/d" | sed "s_'refs/heads/\(.*\)'_head:\1_" | tr '\n' ' ')"
To return a null value with a formula,
use IFERROR(0/0)
.
let json = theJsonYouWantToPrettyPrint;
JSON.stringify(json,null,2);
If bluetooth crashes for whatever reason and you don't want to restart the machine, you can reset it from the command line:
sudo pkill bluetoothd \
&& sudo rm /Library/Preferences/com.apple.Bluetooth.plist \
&& sudo pkill bluetoothd
Then open Preferences to put everything back in order.
mdfind -onlyin ./ -name <name>
sudo vi /etc/pam.d/sudo
Add auth sufficient pam_tid.so
to the top line so the file looks like this:
# sudo: auth account password session
auth sufficient pam_tid.so # This is the line to add
auth required pam_opendirectory.so
account required pam_permit.so
password required pam_deny.so
session required pam_permit.so
In iTerm 2, go to Preferences > Advanced, and type "allow session". Change Allow sessions to survive logging out and back in to No.
Restart the terminal. Test with a simple command like sudo ls
.
Add these lines to ~/.zshrc
, and then run source ~/.zshrc
.
export LESS='-F -i -J -M -R -W -x4 -X -z-4'
alias zshconfig="vi ~/.zshrc && source ~/.zshrc"
alias snippets="open https://gist.github.com/imnotashrimp/5fefe5176071c73079060bc60f0bad4d"
pbcopy < /path/to/file
or
/path/to/file | pbcopy
- Text expansion: Espanso
- Window management: Window Collage
- Beautiful mono font (with script & ligatures): Victor Mono
tree
command on macOS:brew install tree
Thanks for sharing!