#### Set prompt basics #### # set variable identifying the chroot you work in (used in the prompt below) if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then debian_chroot=$(cat /etc/debian_chroot) fi # set a fancy prompt (non-color, unless we know we "want" color) case "$TERM" in xterm-color) color_prompt=yes;; esac # uncomment for a colored prompt, if the terminal has the capability; turned # off by default to not distract the user: the focus in a terminal window # should be on the output of commands, not on the prompt force_color_prompt=yes if [ -n "$force_color_prompt" ]; then if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then # We have color support; assume it's compliant with Ecma-48 # (ISO/IEC-6429). (Lack of such support is extremely rare, and such # a case would tend to support setf rather than setaf.) color_prompt=yes else color_prompt= fi fi #### Set initial prompt #### ps1_shelllevel='${debian_chroot:+($debian_chroot)}($SHLVL) ' if [ "$color_prompt" = yes ]; then ps1_user='\u@\h {\A} ' # have to remember to wrap the 0-width characters on the line of the prompt in \[ and \] if [ "$EUID" -ne 0 ]; then ps1_folder='\e[32m[\w]' ps1_prompt='\n\[\e[0m\]$ ' else ps1_folder='\e[31m[\w]' ps1_prompt='\n\[\e[0m\]# ' fi else ps1_user='u@h {a} ' ps1_folder='[w]' if [ "$EUID" -ne 0 ]; then ps1_prompt='\n$ ' else ps1_prompt='\n# ' fi fi PS1=$ps1_shelllevel$ps1_user$ps1_folder$ps1_prompt # don't unset these so they can be used later #unset color_prompt force_color_prompt # not sure what this bit does #case "$TERM" in # xterm*|rxvt*) # PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1";; # *) # ;; #esac #### Colour support #### if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" alias ls='ls --color=auto' alias dir='dir --color=auto' alias vdir='vdir --color=auto' alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' # may be --color=auto in some versions... alias ip='ip -c' fi #### Aliases for all #### # alias commands that prefix commands # so they can prefix your aliases # https://askubuntu.com/a/22043 alias sudo='sudo ' alias watch='watch ' alias vim='vim -i NONE' alias nano='nano --nowrap --smooth -T 4' alias plz='sudo ' alias dammit='sudo !!' # stop yourself from breaking the server by accident alias mv='mv -i' alias cp='cp -i' alias ln='ln -i' alias rm='rm -I --preserve-root' alias chown='chown --preserve-root' alias chmod='chmod --preserve-root' alias chgrp='chgrp --preserve-root' # I haven't used these in a while since I taught myself to use grep -R # don't forget about -i for ignoring case and -l if you just want file names and first matches # but you could rewrite these to use ag if you wanted but they also might not follow symlinks #function findinfiles() { find ./ -type f -print0 | xargs -0 grep -i "$1"; } #function findinphpfiles() { find ./ -type f -name "*.php" -print0 | xargs -0 grep -i "$1"; } complete -W "$(echo $(grep '^ssh ' ~/.bash_history | sort -u | sed 's/^ssh //'))" ssh if [ "$(uname)" == "Darwin" ]; then # got pbcopy : elif grep -q Microsoft /proc/version; then # route error to /dev/null because thanks microsoft alias pbcopy='clip.exe > /dev/null 2>&1' # todo: pbpaste in wsl else # install xclip through apt first alias pbcopy='xclip -selection clipboard' alias pbpaste='xclip -selection clipboard -o' fi # inspired by @jamesdoc https://twitter.com/jamesdoc/status/902829327187931137 # ref https://github.com/dannyfritz/commit-message-emoji alias gc-InitialCommit="printf \"🎉\" | pbcopy && pbpaste && echo \"\"" alias gc-VersionTag="printf \"🔖\" | pbcopy && pbpaste && echo \"\"" alias gc-NewFeature="printf \"✨\" | pbcopy && pbpaste && echo \"\"" alias gc-Bugfix="printf \"🐛\" | pbcopy && pbpaste && echo \"\"" alias gc-SecurityFix="printf \"🔒\" | pbcopy && pbpaste && echo \"\"" alias gc-Metadata="printf \"📇\" | pbcopy && pbpaste && echo \"\"" alias gc-Refactoring="printf \"♻️\" | pbcopy && pbpaste && echo \"\"" alias gc-Documentation="printf \"📚\" | pbcopy && pbpaste && echo \"\"" alias gc-Internationalization="printf \"🌐\" | pbcopy && pbpaste && echo \"\"" alias gc-Accessibility="printf \"♿\" | pbcopy && pbpaste && echo \"\"" alias gc-Performance="printf \"🐎\" | pbcopy && pbpaste && echo \"\"" alias gc-Cosmetic="printf \"🎨\" | pbcopy && pbpaste && echo \"\"" alias gc-Tooling="printf \"🔧\" | pbcopy && pbpaste && echo \"\"" alias gc-Tests="printf \"🚨\" | pbcopy && pbpaste && echo \"\"" alias gc-Deprecation="printf \"💩\" | pbcopy && pbpaste && echo \"\"" alias gc-Removal="printf \"🗑️\" | pbcopy && pbpaste && echo \"\"" alias gc-WorkInProgress="printf \"🚧\" | pbcopy && pbpaste && echo \"\"" alias gc-Deforestation="printf \"🌲\" | pbcopy && pbpaste && echo \"\"" if [ -x /usr/bin/termsaver ]; then alias tsm="termsaver matrix" fi if [ -x /usr/bin/cmatrix ]; then alias etm="cmatrix -a -b -s -C cyan" fi #### Final settings for all #### # this is needed to enter the passphrase when attempting to gpg-sign git commits #export GPG_TTY=$(tty) # if you're on WSL you may want to see information from MOTD such as pending updates #sudo run-parts /etc/update-motd.d/ # if you're on WSL and you want to mount network shares #sudo mount -a # if you want to hide commands from your bash history with space and don't include duplicates # you need this but it may already be set elsewhere #HISTCONTROL=ignoreboth # Debian doesn't have bash-completion by default so you need to apt install bash-completion and add the below # also don't forget about https://github.com/cykerway/complete-alias #if [ -f /etc/bash_completion ]; then # . /etc/bash_completion #fi # set PATH so it includes user's private bin if it exists # I use a separate bin to backup standalone binaries #if [ -d "$HOME/bin" ] ; then # PATH="$HOME/bin:$PATH" #fi