You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
2.9 KiB

  1. #!/bin/bash
  2. set -o vi
  3. bind -m vi-insert "\C-l":clear-screen
  4. shopt -s extglob
  5. HISTSIZE=
  6. HISTFILESIZE=
  7. export EDITOR='nvim'
  8. export GIT_AUTHOR_NAME="Tovi Jaeschke-Rogers"
  9. export GIT_AUTHOR_EMAIL="tovi@tovijaeschke.xyz"
  10. export GIT_COMMITTER_NAME="Tovi Jaeschke-Rogers"
  11. export GIT_COMMITTER_EMAIL="tovi@tovijaeschke.xyz"
  12. export LESS='-R'
  13. export LESSOPEN='|~/.lessfilter %s'
  14. alias ls="ls --color=auto" \
  15. vb='nvim ~/.bashrc && source ~/.bashrc' \
  16. va='nvim ~/.config/aliasrc && source ~/.bashrc'
  17. if [[ $(uname) != "Linux" ]]; then
  18. test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash" || true
  19. export HOMEBREW_NO_INSTALL_CLEANUP=1
  20. export GIT_AUTHOR_EMAIL="tovi.jaeschke-rogers@thirty4.com"
  21. export GIT_COMMITTER_EMAIL="tovi.jaeschke-rogers@thirty4.com"
  22. alias ls="ls -G" \
  23. vb='nvim ~/.bash_profile && source ~/.bash_profile' \
  24. va='nvim ~/.config/aliasrc && source ~/.bash_profile'
  25. mount-hdd() {
  26. if [ -z $1 ]; then
  27. sudo umount /dev/disk2s1 && sudo /usr/local/bin/ntfs-3g /dev/disk2s1 /Volumes/NTFS -olocal -oallow_other
  28. else
  29. sudo umount /dev/$1 && sudo /usr/local/bin/ntfs-3g /dev/$1 /Volumes/NTFS -olocal -oallow_other
  30. fi
  31. }
  32. fi
  33. # set PATH so it includes user's private bin if it exists
  34. if [ -d "$HOME/.local/bin" ] ; then
  35. PATH="$PATH:$(du "$HOME/.local/bin/" | cut -f2 | tr '\n' ':')"
  36. fi
  37. source ~/.config/aliasrc
  38. parse_git_branch() {
  39. git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
  40. }
  41. export PS1=" \[\033[0;36m\]\t \[\033[0;35m\]\u\[\033[0;32m\]@\[\033[0;34m\]\h \[\033[32m\]\W\[\033[33m\]\$(parse_git_branch)\[\033[31m\] \n$\[\033[00m\] "
  42. mkcd() {
  43. if [ ! -d "$1" ]; then
  44. mkdir -p "$1" && cd "$1"
  45. elif [ -d "$1" ]; then
  46. cd "$1"
  47. else
  48. echo "Error"
  49. fi
  50. }
  51. # Go up directory structures
  52. up() {
  53. cd $(printf "%0.0s../" $(seq 1 $1));
  54. }
  55. git() {
  56. if [[ $@ == "mergetool" ]]; then
  57. command git mergetool --no-gui
  58. else
  59. command git $@
  60. fi
  61. }
  62. # git branch -vv | grep 'gone\]' | awk ' { print $1 }' | xargs -p git branch -d
  63. git-prune() {
  64. if [[ $@ == "--apply" ]]; then
  65. command git branch --merged develop | grep -vEw "develop$|master$" | xargs git branch -d
  66. else
  67. echo "Run \"git prune --apply\" to delete the following branches:"
  68. command git branch --merged develop | grep -vEw "develop$|master$"
  69. fi
  70. }
  71. color-diff() {
  72. if [ -z ${1+x} ] || [ -z ${2+x} ]; then
  73. echo "Usage: color-diff dir1/ dir2/"
  74. return
  75. fi
  76. diff -bur $1 $2 | colordiff | less
  77. }
  78. export NVM_DIR="$HOME/.nvm"
  79. [ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
  80. [ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm"
  81. [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
  82. [[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"