| 1 | git_branch= |
| 2 | git_dirty= |
| 3 | if [ -d ~/.bash/git-aware-prompt ]; then |
| 4 | source ~/.bash/git-aware-prompt/prompt.sh |
| 5 | fi |
| 6 | |
| 7 | # set variable identifying the chroot you work in (used in the prompt below) |
| 8 | if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then |
| 9 | debian_chroot=$(cat /etc/debian_chroot) |
| 10 | fi |
| 11 | |
| 12 | # set a fancy prompt (non-color, unless we know we "want" color) |
| 13 | case "$TERM" in |
| 14 | xterm-color) color_prompt=yes;; |
| 15 | esac |
| 16 | |
| 17 | # uncomment for a colored prompt, if the terminal has the capability; turned |
| 18 | # off by default to not distract the user: the focus in a terminal window |
| 19 | # should be on the output of commands, not on the prompt |
| 20 | force_color_prompt=yes |
| 21 | |
| 22 | if [ -n "$force_color_prompt" ]; then |
| 23 | if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then |
| 24 | # We have color support; assume it's compliant with Ecma-48 |
| 25 | # (ISO/IEC-6429). (Lack of such support is extremely rare, and such |
| 26 | # a case would tend to support setf rather than setaf.) |
| 27 | color_prompt=yes |
| 28 | else |
| 29 | color_prompt= |
| 30 | fi |
| 31 | fi |
| 32 | |
| 33 | if [ "$color_prompt" = yes ]; then |
| 34 | if [ "$EUID" -ne 0 ]; then |
| 35 | PS1='${debian_chroot:+($debian_chroot)}($SHLVL) \u@\h {\A} \e[32m[\w] \e[1;34m$git_branch\e[31m$git_dirty\e[0m\n$ ' |
| 36 | else |
| 37 | PS1='${debian_chroot:+($debian_chroot)}($SHLVL) \u@\h {\A} \e[31m[\w]\e[0m\n# ' |
| 38 | fi |
| 39 | else |
| 40 | if [ "$EUID" -ne 0 ]; then |
| 41 | PS1='${debian_chroot:+($debian_chroot)}($SHLVL) u@h {A} [w] $git_branch$git_dirty\n$ ' |
| 42 | else |
| 43 | PS1='${debian_chroot:+($debian_chroot)}($SHLVL) u@h {A} [w]\n# ' |
| 44 | fi |
| 45 | fi |
| 46 | unset color_prompt force_color_prompt |
| 47 | |
| 48 | case "$TERM" in |
| 49 | xterm*|rxvt*) |
| 50 | PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1";; |
| 51 | *) |
| 52 | ;; |
| 53 | esac |
| 54 | |
| 55 | # enable color support of ls and also add handy aliases |
| 56 | if [ -x /usr/bin/dircolors ]; then |
| 57 | test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" |
| 58 | alias ls='ls --color=auto' |
| 59 | alias dir='dir --color=auto' |
| 60 | alias vdir='vdir --color=auto' |
| 61 | |
| 62 | alias grep='grep --color=auto' |
| 63 | alias fgrep='fgrep --color=auto' |
| 64 | alias egrep='egrep --color=auto' |
| 65 | fi |
| 66 | |
| 67 | alias nano='nano --nowrap --smooth -T 4' |
| 68 | alias plz='sudo' |
| 69 | alias dammit='sudo !!' |
| 70 | |
| 71 | # stop yourself from breaking the server by accident |
| 72 | alias mv='mv -i' |
| 73 | alias cp='cp -i' |
| 74 | alias ln='ln -i' |
| 75 | alias rm='rm -I --preserve-root' |
| 76 | alias chown='chown --preserve-root' |
| 77 | alias chmod='chmod --preserve-root' |
| 78 | alias chgrp='chgrp --preserve-root' |
| 79 | |
| 80 | function findinfiles() { find ./ -type f -print0 | xargs -0 grep -i "$1"; } |
| 81 | function findinphpfiles() { find ./ -type f -name "*.php" -print0 | xargs -0 grep -i "$1"; } |
| 82 | |
| 83 | complete -W "$(echo $(grep '^ssh ' ~/.bash_history | sort -u | sed 's/^ssh //'))" ssh |
| 84 | |
| 85 | if [ "$(uname)" == "Darwin" ]; then |
| 86 | # got pbcopy |
| 87 | : |
| 88 | elif grep -q Microsoft /proc/version; then |
| 89 | # route error to /dev/null because thanks microsoft |
| 90 | alias pbcopy='clip.exe > /dev/null 2>&1' |
| 91 | else |
| 92 | # install xclip through apt first |
| 93 | alias pbcopy='xclip -selection clipboard' |
| 94 | fi |
| 95 | |
| 96 | # thanks @jamesdoc |
| 97 | alias e-thumbsup="printf \"๐\" | pbcopy && echo \"๐ copied to the clipboard\"" |
| 98 | alias e-pointup="printf \"๐\" | pbcopy && echo \"๐ copied to the clipboard\"" |
| 99 | alias e-pointdown="printf \"๐\" | pbcopy && echo \"๐ copied to the clipboard\"" |
| 100 | alias e-rocket="printf \"๐\" | pbcopy && echo \"๐ copied to the clipboard\"" |
| 101 | alias e-tada="printf \"๐\" | pbcopy && echo \"๐ copied to the clipboard\"" |
| 102 | alias e-lightning="printf \"โก\" | pbcopy && echo \"โก copied to the clipboard\"" |
| 103 | alias shruggie="printf \"ยฏ\_(ใ)_/ยฏ\" | pbcopy && echo \"ยฏ\_(ใ)_/ยฏ copied to clipboard\"" |
| 104 | |
| 105 | if [ -x /usr/bin/termsaver ]; then |
| 106 | alias tsm="termsaver matrix" |
| 107 | fi |
| 108 | |
| 109 | if [ -x /usr/bin/cmatrix ]; then |
| 110 | alias etm="cmatrix -a -b -s -C cyan" |
| 111 | fi |
| 112 | |
| 113 | # this is needed to enter the passphrase when attempting to gpg-sign git commits |
| 114 | #export GPG_TTY=$(tty) |
| 115 | |
| 116 | # if you're on WSL you may want to see information from MOTD such as pending updates |
| 117 | #sudo run-parts /etc/update-motd.d/ |
| 118 | |
| 119 | # if you're on WSL and you want to mount network shares |
| 120 | #sudo mount -a |
| 121 | |
| 122 | # if you want to hide commands from your bash history with space and don't include duplicates |
| 123 | # you need this but it may already be set elsewhere |
| 124 | #HISTCONTROL=ignoreboth |
| 125 | |
| 126 | # Debian doesn't have bash-completion by default so you need to apt install bash-completion and add the below |
| 127 | #if [ -f /etc/bash_completion ]; then |
| 128 | # . /etc/bash_completion |
| 129 | #fi |
willpower232 / bash.bashrc
Last active 1 month ago
I am making my .bashrc portable as inspired by this https://www.cyberciti.biz/tips/bash-aliases-mac-centos-linux-unix.html
Revision 65420631f63e78721381f77c28d62f23bec9a43d