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 b8d0381fc005fcfd68b56936c88c9ad23af1a8c6

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 PS1='${debian_chroot:+($debian_chroot)}($SHLVL) \u@\h \e[32m[\w]\e[0m\n$ '
29else
30 PS1='${debian_chroot:+($debian_chroot)}($SHLVL) u@h [w]\n$ '
31fi
32unset color_prompt force_color_prompt
33
34case "$TERM" in
35 xterm*|rxvt*)
36 PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1";;
37 *)
38 ;;
39esac
40
41# enable color support of ls and also add handy aliases
42if [ -x /usr/bin/dircolors ]; then
43 test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
44 alias ls='ls --color=auto'
45 alias dir='dir --color=auto'
46 alias vdir='vdir --color=auto'
47
48 alias grep='grep --color=auto'
49 alias fgrep='fgrep --color=auto'
50 alias egrep='egrep --color=auto'
51fi
52
53alias nano='nano --nowrap --smooth -T 4'
54alias please='sudo'
55
56function findinfiles() { find ./ -type f -print0 | xargs -0 grep -i "$1"; }
57function findinphpfiles() { find ./ -type f -name "*.php" -print0 | xargs -0 grep -i "$1"; }
58
59complete -W "$(echo $(grep '^ssh ' ~/.bash_history | sort -u | sed 's/^ssh //'))" ssh
60