Skip to content

Instantly share code, notes, and snippets.

@matthieubosquet
Last active April 9, 2021 11:29
Show Gist options
  • Save matthieubosquet/1a4e19a01127fc4e38d003464d167e64 to your computer and use it in GitHub Desktop.
Save matthieubosquet/1a4e19a01127fc4e38d003464d167e64 to your computer and use it in GitHub Desktop.
Bash shell profile for MacOS
# INFO
## To switch shell:
## - Add desired shell to /etc/shells
## - Run: chsh -s <PATH_TO_SHELL>
echo "Current shell: $SHELL"
echo "Bash version: $BASH_VERSION"
# Setup
## xcode select cli tools
# xcode-select --install
## Homebrew package manager
# /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
## Homebrew basic packages
# brew install bash bash-completion coreutils ffmpeg git tree vim watch wget
# brew cask install osxfuse
# Terminal configuration
## Change base prompt
export PS1="\n\033[1;31m\u \033[0mat \033[1;33m\h \033[0min \033[1;32m\w \033[0m\n$ "
## Default editor
export EDITOR=vim
## History (HISTSIZE maximum saves in 1 session)
export HISTTIMEFORMAT='%F %T '
export HISTSIZE=2000
export HISTFILESIZE=2000
## History, eternal
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND ; }"'echo $$ $USER \
"$(history 1)" >> ~/.bash_eternal_history'
# Aliases
if [ -f ~/.aliases ]; then
. ~/.aliases
fi
## Change directory
alias desk='cd ~/Desktop'
alias ..='cd ..'
## Generate password
alias generatepassword='openssl rand -base64 32'
## GitHub pages
alias github-page='bundle exec jekyll serve'
## Images
alias pngquant='pngquant --quality=65-80'
## List directory
alias ls='ls -GFh'
alias la='ls -As'
alias ll='ls -l'
alias lla='ls -lAs'
## Server
### Node (npm install http-server -g)
alias serve='http-server -p 8000'
alias serve2='simplehttp2server'
### Python 2 (seems like python 3 is the default in 2018)
### alias serve='python -m SimpleHTTPServer 8000'
### Python 3 (the server seems buggy and slow even for development purposes)
### alias serve='python -m http.server 8000'
## Show/hide files (Mac specific)
alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'
alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'
## Set permissions
alias set-files-permissions='find ./ -type f -exec chmod 644 {} \;'
alias set-folders-permissions='find ./ -type d -exec chmod 755 {} \;'
## Check Java defaults
## Minimum heap size
## java -XX:+PrintFlagsFinal -version | grep InitialHeapSize | numfmt --field=4 --to=iec-i | awk '{print $2 " " $4}'
## Maximum heap memory size
## java -XX:+PrintFlagsFinal -version | grep MaxHeapSize | numfmt --field=4 --to=iec-i | awk '{print $2 " " $4}'
## Thread stack size
## java -XX:+PrintFlagsFinal -version | grep ThreadStackSize | numfmt --field=4 --to=iec-i | awk '{print $2 " " $4}'
# Autocompletion
## Load Homebrew bash autocomplete (brew install bash-completion)
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
## Kubectl
source <(kubectl completion bash)
# Applications configuration
## Node and npm
### Install npm packages in homedir
export NPM_PACKAGES="$HOME/.npm-packages"
### Unset manpath so we can inherit from /etc/manpath via the `manpath` command
unset MANPATH # delete if you already modified MANPATH elsewhere in your configuration
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
### Tell Node about npm packages located in the user home
export NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
# Add applications to PATH
## Cargo
export PATH="$HOME/.cargo/bin:$PATH"
## Macports
export PATH="/usr/local/bin:$PATH"
## NPM packages
export PATH="$NPM_PACKAGES/bin:$PATH"
## OpenSSL (Homebrew version !!! KEEP FIRST IN PATH !!!)
export PATH="/usr/local/opt/openssl/bin:$PATH"
## Visual Studio Code
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
# Colors
## CLI
export CLICOLOR=1
## LS
export LSCOLORS=GxFxCxDxBxegedabagaced
# How To
## ANSI graphic modes
howto-colors() {
local esc="\033["
echo -e "\nANSI graphic modes"
echo "\033 ASCII escape character (octal)"
echo "[ Escape sequence prefix"
echo "m Escape sequence suffix (set graphic mode)"
echo "; Value separator (\033[VALUE;...;VALUEm)"
printf 'e.g. \033[1;31;46m\\033[1;31;46m Bold;Red;CyanBG'
echo -e "${esc}0m\n\nText attribute"
echo -e "0 Reset graphic mode"
echo -e "1 ${esc}1mBold${esc}0m"
echo -e "4 ${esc}4mUnderscore${esc}0m"
echo -e "5 ${esc}5mBlink${esc}0m"
echo -e "7 ${esc}7mReverse video${esc}0m"
echo -e "8 ${esc}8mConcealed on${esc}0m (\"Concealed aka do not display)"
echo -e "\nText color (bold displays a different color, lighter by convention)"
echo -e "30\t${esc}30mBlack\t\t${esc}1mDark Gray"
echo -e "${esc}0m31\t${esc}31mRed\t\t${esc}1mLight Red"
echo -e "${esc}0m32\t${esc}32mGreen\t\t${esc}1mLight Green"
echo -e "${esc}0m33\t${esc}33mBrown\t\t${esc}1mYellow"
echo -e "${esc}0m34\t${esc}34mBlue\t\t${esc}1mLight Blue"
echo -e "${esc}0m35\t${esc}35mPurple\t\t${esc}1mLight Purple"
echo -e "${esc}0m36\t${esc}36mCyan\t\t${esc}1mLight Cyan"
echo -e "${esc}0m37\t${esc}37mLight Gray\t${esc}1mWhite"
echo -e "\nBackground color"
echo -e "${esc}0;40m 40 ${esc}41m 41 ${esc}42m 42 ${esc}43m 43 ${esc}44m 44 ${esc}45m 45 ${esc}46m 46 ${esc}47m 47 ${esc}0m"
}
# Pomodoro timer
alias pomodoro='pkill leave && leave +25'
alias pomodororest='pkill leave && leave +5'
alias pomodorostop='pkill leave'
// ~/Library/Application Support/Code/User/settings.json
{
"metals.javaHome": "/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home",
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"java.errors.incompleteClasspath.severity": "ignore",
"git.autofetch": true,
"editor.renderWhitespace": "all",
"git.confirmSync": false,
"explorer.confirmDelete": false,
"javascript.updateImportsOnFileMove.enabled": "never",
"files.watcherExclude": {
"**/.bloop": true,
"**/.metals": true,
"**/.ammonite": true
},
"window.zoomLevel": -1,
"editor.tabSize": 2,
"[typescript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"editor.rulers": [
80,
120
],
"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 120,
"workbench.editor.wrapTabs": true,
"[markdown]": {
"editor.wordWrap": "wordWrapColumn",
"editor.quickSuggestions": false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment