Skip to content

Instantly share code, notes, and snippets.

@beny
Last active November 12, 2024 11:58
Show Gist options
  • Save beny/814164 to your computer and use it in GitHub Desktop.
Save beny/814164 to your computer and use it in GitHub Desktop.
Bash config
# enviroment variables
export BASH_SILENCE_DEPRECATION_WARNING=1
export CLICOLOR=1
export EDITOR='vim'
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export PATH=/usr/local/bin:$PATH:$HOME/.bin
export MATCH_PASSWORD=Ab22112011
# beware if not escaping these values right, it will broke the output
# https://stackoverflow.com/a/36211560/45846
GREEN='\001\033[0;32m\002'
CYAN='\001\033[0;36m\002'
YELLOW='\001\033[1;33m\002'
RESET_COLOR='\001\033[0m\002' # No Color
export PS1="${GREEN}\w ${YELLOW}\$(parse_git_branch)${CYAN}\$${RESET_COLOR} "
# homebrew
eval "$(/opt/homebrew/bin/brew shellenv)"
# Ruby
eval "$(rbenv init - bash)"
# export SSL_CERT_FILE=/Users/beny/Sync/work/AirBank/certificates/AirBankCASHA2.pem
# Disable fastlane stuff ¯\_(ツ)_/¯
export FASTLANE_OPT_OUT_USAGE=1
export FASTLANE_SKIP_UPDATE_CHECK=1
export FASTLANE_HIDE_CHANGELOG=1
# homebrew
# export HOMEBREW_BUILD_FROM_SOURCE=1
export HOMEBREW_NO_ANALYTICS=1
# Disable crazy characters in brew
export HOMEBREW_NO_EMOJI=1
# Stop homebrew from auto-updating
export HOMEBREW_NO_AUTO_UPDATE=1
# Stop homebrew from running cleanup automatically
export HOMEBREW_NO_INSTALL_CLEANUP=1
# cocoapods
export COCOAPODS_DISABLE_STATS=1
# Swift
export PATH=/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin:"${PATH}"
# git completion
source ~/.bin/git-completion.bash
# git prompt
source ~/.bin/git-prompt.sh
# SPM completion
source ~/.bin/swift-package-complete.sh
# aliases
alias be='bundle exec'
alias ifast='arch -x86_64 bundle exec fastlane'
alias fast='bundle exec fastlane'
alias fix-paste="printf '\e[?2004l'"
alias ll='ls -l'
alias localizations-create='find . -name \*.swift -o -name \*.m | xargs genstrings -o Base.lproj'
alias matej='mate -t source.json'
alias matex='mate -t text.xml'
alias jsonify='ruby -r json -e "jj JSON.parse gets" | matej'
alias xmlify='xmllint --format - | matex'
alias cpuinfo='sysctl -n machdep.cpu.brand_string'
alias libinfo='xcrun -sdk iphoneos lipo -info'
alias gateway='route -n get default | grep gateway | cut -d':' -f2 | xargs'
alias repod='rm -fr Pods/ Podfile.lock *.xcworkspace && pod update'
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /'
}
pretty_print_json() {
cat $1 | python3 -m json.tool | matej
}
alias jsonify=pretty_print_json
# prints UUID of binary in format to easier match the crash log uuid
dwarfuuid() {
xcrun dwarfdump --uuid $1 | tr '[:upper:]' '[:lower:]' | tr -d '-' | cut -f2,3 -d' '
}
# prints UUID of binary located in crash log
crashuuid() {
grep --after-context=1 -C 1 "Binary Images:" $1 | cut -f2 -d'<' | cut -f1 -d'>'
}
symbolicatecrash() {
# /Applications/Xcode.app/Contents/SharedFrameworks/DTDeviceKitBase.framework/Versions/A/Resources/symbolicatecrash -v "$1" > "$1.log"
/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash -v "$1" > "$1.log"
}
symbolicatecrashes() {
for f in "$@"
do
symbolicatecrash "$f"
done
}
XCODE_VERSION_FILE='.xcode-version'
SWIFT_PACKAGE_FILE='Package.swift'
TUIST_FOLDER='Tuist'
xedit() {
if [ -d "$TUIST_FOLDER" ]; then
tuist edit
else
xopen
fi
}
xopen() {
if [ -f $XCODE_VERSION_FILE ]; then
XCODE_VERSION=`cat $XCODE_VERSION_FILE`
DEVELOPER_DIR="/Applications/Xcode_$XCODE_VERSION.app"
if [ -d $DEVELOPER_DIR ]; then
export DEVELOPER_DIR=$DEVELOPER_DIR
fi
fi
if [ -n $DEVELOPER_DIR ]; then
export DEVELOPER_DIR=`xcode-select -p`
fi
CURRENT_XCODE=`echo $DEVELOPER_DIR | cut -f 3 -d'/'`
echo "Using $CURRENT_XCODE"
if [ -d $TUIST_FOLDER ]; then
tuist generate
else
xed .
fi
}
total_code_lines() {
find . \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 cat | wc -l
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment