-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.profile
executable file
·105 lines (84 loc) · 4.28 KB
/
.profile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Shell configuration file order:
# - bash: https://scriptingosx.com/2017/04/about-bash_profile-and-bashrc-on-macos/
# - zsh: https://scriptingosx.com/2019/06/moving-to-zsh-part-2-configuration-files/
#
# Environment Variables
#
# Add paths to the PATH variable
if [[ "$(uname -m)" == "arm64" ]]; then
export PATH="/opt/homebrew/bin:$PATH" # Path for Homebrew on Apple Silicon.
fi
HOMEBREW=$(brew --prefix)
export PATH="~/bin:$PATH" # E.g., op (1Password), code (Visual Studio Code).
export PATH="$HOMEBREW/bin:$HOMEBREW/sbin:$PATH" # Prioritize Homebrew's Git etc. over the OS-bundled ones.
export PATH="$HOMEBREW/opt/ruby/bin:$PATH" # Homebrew Ruby gem installed binaries' default path.
# Suppress shell "Warning: Failed to set locale category LC_NUMERIC to en_CH." when macOS' Language & Region settings don't play well with CLI tools.
export LC_ALL=en_US.UTF-8
# Use Visual Studio Code as standard editor
# `--wait` for the files to be closed before returning.
# Setting both standard variables, see: https://unix.stackexchange.com/questions/4859/visual-vs-editor-whats-the-difference
export VISUAL='code --wait'
export EDITOR="$VISUAL"
# Configure Git autocomplete
# Zsh ships with a tab-completion library for Git: https://git-scm.com/book/en/v2/Appendix-A%3A-Git-in-Other-Environments-Git-in-Zsh
# The shell seems to already autocomplete, though, and running `autoload -Uz compinit && compinit` seems to slow down shell startup.
if [ -n "$BASH_VERSION" ]; then
# Use Homebrew's bundled Git bash completions over the OS-bundled ones (no need to `> brew install bash-completion`).
source $HOMEBREW/etc/bash_completion.d/git-completion.bash
source $HOMEBREW/etc/bash_completion.d/git-prompt.sh
source $HOMEBREW/etc/bash_completion.d/hub.bash_completion.sh
fi
# Customize the prompt.
if [ -n "$ZSH_VERSION" ]; then
export PROMPT='%B%1~%b > '
# The line `precmd_vcs_info { vcs_info }` in the snippet to show current Git branch name from the "Git-in-Zsh"-link above errors in bash.
# There doesn't seem to be an easy way to show changes next to the branch w/o messing with git-completion.zsh etc.
elif [ -n "$BASH_VERSION" ]; then
# Show current Git branch name in Git repositories.
export PS1='\u@\h:\[\e[;1m\]\w \[\e[32m\]$(__git_ps1 "(%s)")\[\e[0m\]$ '
# Show changes next to branch.
export GIT_PS1_SHOWDIRTYSTATE=1 # unstaged (*), staged (+)
export GIT_PS1_SHOWSTASHSTATE=1 # stashed ($)
export GIT_PS1_SHOWUNTRACKEDFILES=1 # untracked files (%)
fi
# Customize the color of ls.
export LSCOLORS=Dxfxcxdxbxegedabagacad # Use bold brown (most of the times yellow) for directories and pink for links.
export CLICOLOR=1 # Use ANSI color sequences to distinguish file types.
# Setting GitHub API token for Homebrew to avoid error "GitHub API rate limit exceeded" when `> brew search`ing.
export HOMEBREW_GITHUB_API_TOKEN=$(git config github.token)
# So ffmpeg finds libass' fonts to render subtitles
export FONTCONFIG_FILE=/usr/local/etc/fonts/fonts.conf
# node.js nvm
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
# `> twilio` autocomplete setup added via `> twilio autocomplete <bash|zsh>`
if [ -n "$ZSH_VERSION" ]; then
TWILIO_AC_ZSH_SETUP_PATH=~/.twilio-cli/autocomplete/zsh_setup && test -f $TWILIO_AC_ZSH_SETUP_PATH && source $TWILIO_AC_ZSH_SETUP_PATH;
elif [ -n "$BASH_VERSION" ]; then
TWILIO_AC_BASH_SETUP_PATH=~/.twilio-cli/autocomplete/bash_setup && test -f $TWILIO_AC_BASH_SETUP_PATH && source $TWILIO_AC_BASH_SETUP_PATH;
fi
# `> heroku` autocomplete setup added via `> heroku autocomplete`
if [ -n "$ZSH_VERSION" ]; then
HEROKU_AC_ZSH_SETUP_PATH=~/Library/Caches/heroku/autocomplete/zsh_setup && test -f $HEROKU_AC_ZSH_SETUP_PATH && source $HEROKU_AC_ZSH_SETUP_PATH;
fi
#
# Aliases
#
# Xcode
alias xcp="open *.xcodeproj"
alias xcw="open *.xcworkspace"
alias ddd='rm -rf ~/Library/Developer/Xcode/DerivedData/'
# I'm a dummy.
alias brwe=brew
# lsusb
alias lsusb='system_profiler SPUSBDataType'
#
# Functions
#
# Open files with `/Applications`
# Note the importance of the whitespace in the function definition to avoid syntax errors with bash.
# `> writer` for iA Writer.app
writer() {
open $1 -a /Applications/iA\ Writer.app/
}