You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- Run a command in a new Terminal windowtellapplication"Terminal"to do script"cd §directory";
-- Send an application window to the Docktellapplication"§app"toset miniaturized of window §numbertotrue
// From iframe§{parent¦top}.§variable// To iframedocument.getElementById(§iframe_id).contentWindow.§variable// To iframe in different domainvarw=document.getElementById(§iframe_id).contentWindow;w.postMessage(§data,§target_url);// Implemented in iframe document, maybe also in parent documentfunction§handler(event){if(ev.origin!==§src_url)return;/* do something with event.data */event.source.postMessage(§data,§src_url);}window.addEventListener("message",§handler,false);
# Commit all unstaged changes with a message
git commit -am §message
# Show what would be pushed
git push --dry-run
# Show list of changed/added/removed files
git diff --stat §branch §[HEAD]
# Show list of remote branches
git branch -r
# Check out a remote branch
git fetch && git checkout origin/§branch
# Show historical changes of a file
git log -p §file
# Reset the HEAD to the state of the remote branch
git reset §[--hard¦--merge] origin/§branch
# Reset the HEAD to the state of the last commit
git reset HEAD@{1} # last commit# Reset the HEAD to the nth parent of HEAD
git reset --hard §{HEAD~¦HEAD^§n}
# Discard all unstaged changes
git checkout -- .# Alter the last commit before publishing it
git commit --amend
# Undo the changes of a commit (without rewriting history)
git revert §commit
# Publish a new branch to the remote
git push -u origin §branch
# Delete a branch from the remote
git push origin --delete §branch
# This might be necessary after editing gitignore
git rm -r --cached .&& git add .# Remove untracked files & directories
git clean -fd §[--dry-run]
# Merge two branches without autocommiting (optional)
git merge §[--no-commit] §branch
# When you don't want to fix conflicts
git merge --abort
# So you can type "git co develop" instead of "git checkout develop"
git config --global alias.co checkout
# Needed when you also use GitHub Desktop on macOS
git config --global credential.helper osxkeychain
# Compare commit with its parent
git diff §commit^!# Push tags to remote
git push --tags
# Create a new branch that tracks a remote branch
git branch --set-upstream-to=origin/§branch §branch
# Transfer uncommited changes to another branch
git stash && git checkout §branch && git stash apply
# Show differences between stash and current branch
git stash show -p
# Copy changes to specific files from another branch
git checkout --patch §commit¦§branch §file
# Overwrite local files with files from remote branch
git fetch --all
git reset --hard origin/§branch
git pull origin §branch
# Clone new submodules into already existing repository
git submodule update --init --recursive
# Define Git Flow branch names
git flow init
# Features are branched from develop
git flow feature §{start¦publish¦pull origin¦finish} §name
# Features are merged into a release branch, which is also branched from develop
git flow release §{start¦publish¦finish} §version
# Hotfixes are branched from master
git flow hotfix §{start¦finish} §name
SVN
# Edit list of ignored files in a directory
svn propedit svn:ignore §dir
# Set ignored file in §dir
svn propset svn:ignore §file §dir
# Execute this when SVN can’t commit for no reason
svn update
# Show changes of a revision
svn log --verbose -r §revision
Bash
#!/bin/bash# Strict modeset -euo pipefail
IFS=$'\n\t'# Check if a variable/array is defined and not empty
[[ ${var-} ]]
# Check if a variable is defined# (An empty array is not recognized here!)
[[ ${var+1} ]]
# Check if a variable is defined as an array
[[ $(declare -p var 2> /dev/null)=~"declare -a" ]]
# Access variable with dynamic name
varname=prefix_$suffixecho"${!varname}"# Reliably get the path to the directory that contains the current scriptecho"$(dirname "$(readlink -f "$0")")"
Completion
brew install bash-completion # requires Homebrew# Simple completion of subcommands, etc.complete -W §list_of_words §command # only in bash, sh & csh
Mac Development
# Install Xcode command line tools
xcode-select --install
# Create an Apple icon file, given the following directory:# (2x files are optional; not every resolution has to exist)# App.iconset/# ├── icon_16x16.png# ├── icon_16x16@2x.png# ├── icon_32x32.png# ├── icon_32x32@2x.png# ├── icon_128x128.png# ├── icon_128x128@2x.png# ├── icon_256x256.png# ├── icon_256x256@2x.png# ├── icon_512x512.png# └── icon_512x512@2x.png
iconutil -c icns App.iconset