| 1 | #### Set prompt basics ####
|
| 2 |
|
| 3 | # set variable identifying the chroot you work in (used in the prompt below)
|
| 4 | if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
|
| 5 | debian_chroot=$(cat /etc/debian_chroot)
|
| 6 | fi
|
| 7 |
|
| 8 | # set a fancy prompt (non-color, unless we know we "want" color)
|
| 9 | case "$TERM" in
|
| 10 | xterm-color) color_prompt=yes;;
|
| 11 | esac
|
| 12 |
|
| 13 | # uncomment for a colored prompt, if the terminal has the capability; turned
|
| 14 | # off by default to not distract the user: the focus in a terminal window
|
| 15 | # should be on the output of commands, not on the prompt
|
| 16 | force_color_prompt=yes
|
| 17 |
|
| 18 | if [ -n "$force_color_prompt" ]; then
|
| 19 | if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
|
| 20 | # We have color support; assume it's compliant with Ecma-48
|
| 21 | # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
|
| 22 | # a case would tend to support setf rather than setaf.)
|
| 23 | color_prompt=yes
|
| 24 | else
|
| 25 | color_prompt=
|
| 26 | fi
|
| 27 | fi
|
| 28 |
|
| 29 | #### Set initial prompt ####
|
| 30 |
|
| 31 | ps1_shelllevel='${debian_chroot:+($debian_chroot)}($SHLVL) '
|
| 32 |
|
| 33 | if [ "$color_prompt" = yes ]; then
|
| 34 | ps1_user='\u@\h {\A} '
|
| 35 |
|
| 36 | # have to remember to wrap the 0-width characters on the line of the prompt in \[ and \]
|
| 37 | if [ "$EUID" -ne 0 ]; then
|
| 38 | ps1_folder='\e[32m[\w]'
|
| 39 | ps1_prompt='\n\[\e[0m\]$ '
|
| 40 | else
|
| 41 | ps1_folder='\e[31m[\w]'
|
| 42 | ps1_prompt='\n\[\e[0m\]# '
|
| 43 | fi
|
| 44 | else
|
| 45 | ps1_user='u@h {a} '
|
| 46 | ps1_folder='[w]'
|
| 47 |
|
| 48 | if [ "$EUID" -ne 0 ]; then
|
| 49 | ps1_prompt='\n$ '
|
| 50 | else
|
| 51 | ps1_prompt='\n# '
|
| 52 | fi
|
| 53 | fi
|
| 54 |
|
| 55 | PS1=$ps1_shelllevel$ps1_user$ps1_folder$ps1_prompt
|
| 56 |
|
| 57 | # don't unset these so they can be used later
|
| 58 | #unset color_prompt force_color_prompt
|
| 59 |
|
| 60 | # not sure what this bit does
|
| 61 | #case "$TERM" in
|
| 62 | # xterm*|rxvt*)
|
| 63 | # PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1";;
|
| 64 | # *)
|
| 65 | # ;;
|
| 66 | #esac
|
| 67 |
|
| 68 | #### Colour support ####
|
| 69 |
|
| 70 | if [ -x /usr/bin/dircolors ]; then
|
| 71 | test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
| 72 | alias ls='ls --color=auto'
|
| 73 | alias dir='dir --color=auto'
|
| 74 | alias vdir='vdir --color=auto'
|
| 75 |
|
| 76 | alias grep='grep --color=auto'
|
| 77 | alias fgrep='fgrep --color=auto'
|
| 78 | alias egrep='egrep --color=auto'
|
| 79 |
|
| 80 | # may be --color=auto in some versions...
|
| 81 | alias ip='ip -c'
|
| 82 | fi
|
| 83 |
|
| 84 | #### Aliases for all ####
|
| 85 |
|
| 86 | # alias commands that prefix commands
|
| 87 | # so they can prefix your aliases
|
| 88 | # https://askubuntu.com/a/22043
|
| 89 | alias sudo='sudo '
|
| 90 | alias watch='watch '
|
| 91 |
|
| 92 | alias vim='vim -i NONE'
|
| 93 | alias nano='nano --nowrap --smooth -T 4'
|
| 94 | alias plz='sudo '
|
| 95 | alias dammit='sudo !!'
|
| 96 |
|
| 97 | # stop yourself from breaking the server by accident
|
| 98 | alias mv='mv -i'
|
| 99 | alias cp='cp -i'
|
| 100 | alias ln='ln -i'
|
| 101 | alias rm='rm -I --preserve-root'
|
| 102 | alias chown='chown --preserve-root'
|
| 103 | alias chmod='chmod --preserve-root'
|
| 104 | alias chgrp='chgrp --preserve-root'
|
| 105 |
|
| 106 | function findinfiles() { find ./ -type f -print0 | xargs -0 grep -i "$1"; }
|
| 107 | function findinphpfiles() { find ./ -type f -name "*.php" -print0 | xargs -0 grep -i "$1"; }
|
| 108 |
|
| 109 | complete -W "$(echo $(grep '^ssh ' ~/.bash_history | sort -u | sed 's/^ssh //'))" ssh
|
| 110 |
|
| 111 | if [ "$(uname)" == "Darwin" ]; then
|
| 112 | # got pbcopy
|
| 113 | :
|
| 114 | elif grep -q Microsoft /proc/version; then
|
| 115 | # route error to /dev/null because thanks microsoft
|
| 116 | alias pbcopy='clip.exe > /dev/null 2>&1'
|
| 117 | # todo: pbpaste in wsl
|
| 118 | else
|
| 119 | # install xclip through apt first
|
| 120 | alias pbcopy='xclip -selection clipboard'
|
| 121 | alias pbpaste='xclip -selection clipboard -o'
|
| 122 | fi
|
| 123 |
|
| 124 | # inspired by @jamesdoc https://twitter.com/jamesdoc/status/902829327187931137
|
| 125 | # ref https://github.com/dannyfritz/commit-message-emoji
|
| 126 | alias gc-InitialCommit="printf \"๐\" | pbcopy && pbpaste && echo \"\""
|
| 127 | alias gc-VersionTag="printf \"๐\" | pbcopy && pbpaste && echo \"\""
|
| 128 | alias gc-NewFeature="printf \"โจ\" | pbcopy && pbpaste && echo \"\""
|
| 129 | alias gc-Bugfix="printf \"๐\" | pbcopy && pbpaste && echo \"\""
|
| 130 | alias gc-SecurityFix="printf \"๐\" | pbcopy && pbpaste && echo \"\""
|
| 131 | alias gc-Metadata="printf \"๐\" | pbcopy && pbpaste && echo \"\""
|
| 132 | alias gc-Refactoring="printf \"โป๏ธ\" | pbcopy && pbpaste && echo \"\""
|
| 133 | alias gc-Documentation="printf \"๐\" | pbcopy && pbpaste && echo \"\""
|
| 134 | alias gc-Internationalization="printf \"๐\" | pbcopy && pbpaste && echo \"\""
|
| 135 | alias gc-Accessibility="printf \"โฟ\" | pbcopy && pbpaste && echo \"\""
|
| 136 | alias gc-Performance="printf \"๐\" | pbcopy && pbpaste && echo \"\""
|
| 137 | alias gc-Cosmetic="printf \"๐จ\" | pbcopy && pbpaste && echo \"\""
|
| 138 | alias gc-Tooling="printf \"๐ง\" | pbcopy && pbpaste && echo \"\""
|
| 139 | alias gc-Tests="printf \"๐จ\" | pbcopy && pbpaste && echo \"\""
|
| 140 | alias gc-Deprecation="printf \"๐ฉ\" | pbcopy && pbpaste && echo \"\""
|
| 141 | alias gc-Removal="printf \"๐๏ธ\" | pbcopy && pbpaste && echo \"\""
|
| 142 | alias gc-WorkInProgress="printf \"๐ง\" | pbcopy && pbpaste && echo \"\""
|
| 143 | alias gc-Deforestation="printf \"๐ฒ\" | pbcopy && pbpaste && echo \"\""
|
| 144 |
|
| 145 | if [ -x /usr/bin/termsaver ]; then
|
| 146 | alias tsm="termsaver matrix"
|
| 147 | fi
|
| 148 |
|
| 149 | if [ -x /usr/bin/cmatrix ]; then
|
| 150 | alias etm="cmatrix -a -b -s -C cyan"
|
| 151 | fi
|
| 152 |
|
| 153 | #### Final settings for all ####
|
| 154 |
|
| 155 | # this is needed to enter the passphrase when attempting to gpg-sign git commits
|
| 156 | #export GPG_TTY=$(tty)
|
| 157 |
|
| 158 | # if you're on WSL you may want to see information from MOTD such as pending updates
|
| 159 | #sudo run-parts /etc/update-motd.d/
|
| 160 |
|
| 161 | # if you're on WSL and you want to mount network shares
|
| 162 | #sudo mount -a
|
| 163 |
|
| 164 | # if you want to hide commands from your bash history with space and don't include duplicates
|
| 165 | # you need this but it may already be set elsewhere
|
| 166 | #HISTCONTROL=ignoreboth
|
| 167 |
|
| 168 | # Debian doesn't have bash-completion by default so you need to apt install bash-completion and add the below
|
| 169 | # also don't forget about https://github.com/cykerway/complete-alias
|
| 170 | #if [ -f /etc/bash_completion ]; then
|
| 171 | # . /etc/bash_completion
|
| 172 | #fi
|
| 173 |
|