Skip to content

Instantly share code, notes, and snippets.

@leolovenet
Last active June 11, 2016 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leolovenet/bc7c1725343e8745d154 to your computer and use it in GitHub Desktop.
Save leolovenet/bc7c1725343e8745d154 to your computer and use it in GitHub Desktop.
make terminal colors
#!/bin/bash
cd ~
WGET_CMD=$(type -P wget)
if [ "X$WGET_CMD" = "X" ];then
yum -y install wget coreutils
fi
if [ ! -f ~/.dir_colors ]; then
cd ~
wget --no-check-certificate https://github.com/seebi/dircolors-solarized/raw/master/dircolors.ansi-universal -o dircolors
mv dircolors ~/.dir_colors
eval `dircolors ~/.dir_colors`
fi
if ! grep -q "/usr/bin/dircolors"; then
cat >> ~/.bashrc <<'EOF'
######## bash color ####################
if [ -x /usr/bin/dircolors ]; then
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'
alias tree='tree -C'
fi
########################################
#colored-man-pages
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
PAGER="${commands[less]:-$PAGER}" \
_NROFF_U=1 \
PATH="$HOME/bin:$PATH" \
man "$@"
}
#Show progress while file is copying
#
# Rsync options are:
# -p - preserve permissions
# -o - preserve owner
# -g - preserve group
# -h - output in human-readable format
# --progress - display progress
# -b - instead of just overwriting an existing file, save the original
# --backup-dir=/tmp/rsync - move backup copies to "/tmp/rsync"
# -e /dev/null - only work on local files
# -- - everything after this is an argument, even if it looks like an option
alias cpv="rsync -poghb --backup-dir=/tmp/rsync -e /dev/null --progress --"
EOF
source ~/.bashrc
fi
if ! grep -q "..5" ~/.bashrc; then
cat >> ~/.bashrc <<'EOF'
alias ..="cd .."
alias ..2="cd ../.."
alias ..3="cd ../../.."
alias ..4="cd ../../../.."
alias ..5="cd ../../../../.."
alias l="ls -ahl --full-time"
EOF
source ~/.bashrc
fi
ls /
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment