Skip to content

Instantly share code, notes, and snippets.

@bloatfan
Last active May 27, 2021 04:57
Show Gist options
  • Save bloatfan/3b94c88cdbd023bc3678f299724d2576 to your computer and use it in GitHub Desktop.
Save bloatfan/3b94c88cdbd023bc3678f299724d2576 to your computer and use it in GitHub Desktop.
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ll='ls -al'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
find_git_branch () {
local dir=. head
until [ "$dir" -ef / ]; do
if [ -f "$dir/.git/HEAD" ]; then
head=$(< "$dir/.git/HEAD")
if [[ $head = ref:\ refs/heads/* ]]; then
git_branch=" → ${head#*/*/}"
elif [[ $head != '' ]]; then
git_branch=" → (detached)"
else
git_branch=" → (unknow)"
fi
return
fi
dir="../$dir"
done
git_branch=''
}
PROMPT_COMMAND="find_git_branch; $PROMPT_COMMAND"
# Here is bash color codes you can use
black=$'\[\e[1;30m\]'
red=$'\[\e[1;31m\]'
green=$'\[\e[1;32m\]'
yellow=$'\[\e[1;33m\]'
blue=$'\[\e[1;34m\]'
magenta=$'\[\e[1;35m\]'
cyan=$'\[\e[1;36m\]'
white=$'\[\e[1;37m\]'
normal=$'\[\e[m\]'
ip=`/sbin/ifconfig br0 | awk -F '[ :]+' '/inet /{print $3}' | head -n1`
PS1="$white[$green\u$white@$red$ip$white:$cyan\W$yellow\$git_branch$white]# $normal"
complete -D -o default
# history related tuning
export HISTTIMEFORMAT="%F %T "
export HISTCONTROL=ignoredups:erasedups # no duplicate entries
export HISTSIZE=100000 # big big history
export HISTFILESIZE=100000 # big big history
shopt -s histappend # append to history, don't overwrite it
# Save and reload the history after each command finishes
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
#!/bin/bash
set -x
TIME=$(date +"%Y%m%d-%s")
BASH_RC="$HOME/.bashrc"
[ -f "$BASH_RC" ] && mv "$BASH_RC" "$BASH_RC.bak.$TIME"
yum install -y wget git
wget https://gist.github.com/lslz627/3b94c88cdbd023bc3678f299724d2576/raw/.bashrc -O "$BASH_RC"
which fzf
if [ "$?" == "0" ] then
echo "不需要下载 fzf " && exit 0
else
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install --all
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment