Last active
February 22, 2019 09:51
-
-
Save lotuc/76587798b5603e362e603c37ac8fa458 to your computer and use it in GitHub Desktop.
macOS Bash Configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. ~/.bashrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If not running interactively, don't do anything | |
[ -z "$PS1" ] && return | |
# make less more friendly for non-text input files, see lesspipe(1) | |
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" | |
alias cp='cp -iv' # Preferred 'cp' implementation | |
alias mv='mv -iv' # Preferred 'mv' implementation | |
alias mkdir='mkdir -pv' # Preferred 'mkdir' implementation | |
alias ll='ls -FGlAhp' # Preferred 'ls' implementation | |
alias less='less -FSRXc' # Preferred 'less' implementation | |
alias cd..='cd ../' # Go back 1 directory level (for fast typers) | |
alias ..='cd ../' # Go back 1 directory level | |
alias ...='cd ../../' # Go back 2 directory levels | |
alias .3='cd ../../../' # Go back 3 directory levels | |
alias .4='cd ../../../../' # Go back 4 directory levels | |
alias .5='cd ../../../../../' # Go back 5 directory levels | |
alias .6='cd ../../../../../../' # Go back 6 directory levels | |
if [ -x /usr/bin/dircolors ]; then | |
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" | |
alias ls='ls --color=auto' | |
alias grep='grep --color=auto' | |
alias fgrep='fgrep --color=auto' | |
alias egrep='egrep --color=auto' | |
fi | |
if command -v nvim 1>/dev/null 2>&1; then | |
alias vi=nvim | |
alias vim=nvim | |
fi | |
git config --global alias.co checkout | |
git config --global alias.br branch | |
git config --global alias.ci commit | |
git config --global alias.st status | |
git config --global alias.unstage 'reset HEAD --' | |
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' | |
export HISTCONTROL=ignoredups:erasedups | |
export HISTSIZE=100000 | |
export HISTFILESIZE=100000 | |
shopt -s histappend | |
shopt -s checkwinsize | |
export LANG=en_US.UTF-8 | |
export LC_ALL=en_US.UTF-8 | |
export CLICOLOR=1 | |
# https://github.com/Homebrew/brew/issues/4751 | |
export HOMEBREW_NO_AUTO_UPDATE=1 | |
# https://pipenv.readthedocs.io/en/latest/advanced/ | |
export PIPENV_VENV_IN_PROJECT=1 | |
######################################## | |
# prepend $1 to PATH | |
p() { | |
PATH=$1:$PATH | |
} | |
# brew cask install docker | |
p "/Applications/Docker.app/Contents/Resources/bin" | |
# brew cask install coqide | |
p "/Applications/CoqIDE_8.9.0.app/Contents/Resources/bin/" | |
# brew cask install mactex | |
p "/Library/TeX/texbin" | |
# https://github.com/jenv/jenv | |
p "$HOME/.jenv/bin" | |
export PATH | |
unset p | |
######################################## | |
# eval $2 on command $1 exists | |
e() { | |
command -v $1 1>/dev/null 2>&1 && eval "$2" | |
} | |
# https://github.com/jenv/jenv | |
e jenv "$(jenv init - --no-rehash)" | |
jenv rehash & 1>/dev/null 2>&1 /dev/null | |
# https://github.com/pyenv/pyenv | |
e pyenv "$(pyenv init - --no-rehash)" | |
pyenv rehash & 1>/dev/null 2>&1 /dev/null | |
unset e | |
####################################### | |
# load $1 if exists | |
l() { | |
[ -s $1 ] && \. $1 | |
} | |
# https://github.com/creationix/nvm | |
export NVM_DIR="$HOME/.nvm" | |
l "$NVM_DIR/nvm.sh" | |
l "$NVM_DIR/bash_completion" | |
# brew install bash-completion | |
brew_prefix=/usr/local # brew --prefix | |
l $brew_prefix/etc/bash_completion | |
unset l | |
# ln -s /Applications/Docker.app/Contents/Resources/etc/docker.bash-completion `brew --prefix`/etc/bash_completion.d/docker | |
# ln -s /Applications/Docker.app/Contents/Resources/etc/docker-machine.bash-completion `brew --prefix`/etc/bash_completion.d/docker-machine | |
# ln -s /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion `brew --prefix`/etc/bash_completion.d/docker-compose | |
# ln -s $NVM_DIR/bash_completion `brew --prefix`/etc/bash_completion.d/nvm | |
######################################## | |
# Personal functions | |
jm () { | |
path=$(emacsclient -e "(with-current-buffer | |
(window-buffer (frame-selected-window)) | |
default-directory)") | |
eval cd $(echo $path | sed -E 's/(^\")|(\"$)//g') | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment