willpower232

willpower232 / bash.bashrc

Last active 1 month ago

Like 0

I am making my .bashrc portable as inspired by this https://www.cyberciti.biz/tips/bash-aliases-mac-centos-linux-unix.html

Revision 3a647b9b2683dc9506ffd96448b1e14b156790d2

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