Last active
May 6, 2019 16:50
-
-
Save ubergoober/1b9dbeaf5f0cd381a490 to your computer and use it in GitHub Desktop.
Bash profile (created for mac terminal) which I use. To keep this updated without impacting your additions, edit the file ~/.bash_adds which is added after restarting your terminal or doing a "source ~/.bash_profile"
This file contains hidden or 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
| # advise not editing this file for copy/paste drop in updating (not that I update this gist that often). | |
| # when you source this file (or restart term), a ~/.bash_adds file is created which get's sourced from this file. | |
| # Feel free to edit this file in your ~/.bash_profile file, but don't blame me if you overwrite some cool addtions :) | |
| # -- old -- export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[32m\]\$(parse_git_branch)\[\033[00m\]\$ " | |
| export PS1="\n\[\033[48;5;235m\]\[\033[36m\]\u\[\033[m\]\[\033[48;5;235m\]@\[\033[32m\]\h\[\033[38;5;245m\] | \[\033[38;5;99m\]Node: \$(parse_node_version)\[\033[38;5;245m\] | \[\033[38;5;204m\]\$(parse_date_time)\[\033[00m\]\n\[\033[33;1m\]\w\[\033[32m\]\$(parse_git_branch)\[\033[00m\]$ " | |
| export CLICOLOR=1 | |
| export LSCOLORS=DxFxBxDxCxegedabagacad | |
| # general | |
| alias grepn='grep -n --exclude-dir=node_modules -r ' | |
| # mongodb | |
| alias runmongo='mongod --config /usr/local/etc/mongod.conf -fork' | |
| alias runmongo34='mongod --config /usr/local/etc/mongod3.4.conf -fork' | |
| # react native | |
| alias reactkill='lsof -t -i :8081 | xargs kill -9' | |
| alias rn_rebundle_android='react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res' | |
| alias greprn='grep -n --exclude-dir=node_modules --exclude-dir=android --exclude-dir=ios --exclude-dir=__tests__ -r ' | |
| # history grep, takes char(s) to grep on as param. Could be expanded to do more, but haven't bothered (yet) | |
| alias hg='history | grep ' | |
| # list all hosts configured in ssh config (if exists) | |
| alias ssha='grep -i -e ^host ~/.ssh/config | cut -d" " -f 2' | |
| # alternate? not sure, don't remember | |
| # alias sshhosts='grep "Host " ~/.ssh/config | cut -d" " -f2' | |
| # show all your network connections with alternate grep char(s) | |
| alias mynetcon="sudo lsof -n -P -i +c 15" | |
| alias mynetcong="sudo lsof -n -P -i +c 15 | grep " | |
| # nodejs grep (excludes node modules) | |
| alias grepn='grep -n --exclude-dir=node_modules -r ' | |
| # git graphs can use an (optional) last parameter of the number of commits to display (ex usage gitgraph -10) | |
| alias gitgraph="git log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all" | |
| alias gitgraph2lines="git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all" | |
| # System Aliases | |
| # Speed up or slow down timemachine backups | |
| # Speeding up gives more priority to the process and can have an impact on system performance | |
| alias timemachine_fast='sudo sysctl debug.lowpri_throttle_enabled=0' | |
| alias timemachine_slow='sudo sysctl debug.lowpri_throttle_enabled=1' | |
| # Manual updatedb for use with locate command. Unlike linux, updatedb isn't run on a schedule. | |
| # I'd advise setting updatedb to run on schedule, and use this in between schedules. | |
| alias updatedb='sudo /usr/libexec/locate.updatedb' | |
| # ls variants | |
| alias ls='ls -GFh' | |
| alias ll='ls -la' | |
| # show/hide hidden files/folders in Finder (files with ., like .git, .idea, etc) | |
| alias finder_show_hidden='finderShowHidden' | |
| alias finder_hide_hidden='finderHideHidden' | |
| function finderShowHidden() { | |
| defaults write com.apple.finder AppleShowAllFiles TRUE | |
| killall Finder | |
| } | |
| function finderHideHidden() { | |
| defaults write com.apple.finder AppleShowAllFiles FALSE | |
| killall Finder | |
| } | |
| export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin | |
| #Returns the current git branch in the terminal. | |
| parse_git_branch() { | |
| git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
| } | |
| #Returns current nodejs version. | |
| parse_node_version() { | |
| node -v | |
| } | |
| #Returns current data/time | |
| parse_date_time() { | |
| date "+%a %h(%m)/%d %I:%M%p " | |
| } | |
| #git command and branch completion | |
| if [ -f ~/.git-completion.bash ]; then | |
| . ~/.git-completion.bash | |
| else | |
| # this will download the git completion script from master for the latest. If git completion doesn't work after this, | |
| # you may be using an incompatible (older?) version of git than what's in the master branch. | |
| # in that case, delete the ~/.git-completion.bash file and update this url below with a raw link that matches your git version (git --version) | |
| # Example url for git version 2.11.0: | |
| # https://raw.githubusercontent.com/git/git/v2.11.0/contrib/completion/git-completion.bash | |
| echo "Downloading git tab completion script (will only do this once)..." | |
| curl -o ~/.git-completion.bash https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash | |
| . ~/.git-completion.bash | |
| fi | |
| # add second bash file for additional (custom/personalized) additions | |
| if [ -f ~/.bash_adds ]; then | |
| source ~/.bash_adds | |
| else | |
| touch ~/.bash_adds | |
| . ~/.bash_adds | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment