Last active
January 10, 2018 12:57
-
-
Save hanbei/5322981 to your computer and use it in GitHub Desktop.
my bashrc settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ "$color_prompt" = yes ]; then | |
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(__git_ps1)\$ ' | |
else | |
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(__git_ps1)\$ ' | |
fi | |
unset color_prompt force_color_prompt | |
# some more ls aliases | |
alias ll='ls -l' | |
alias la='ls -A' | |
alias l='ls -CF' | |
alias +='pushd .' | |
alias p='popd' | |
# enable programmable completion features (you don't need to enable | |
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile | |
# sources /etc/bash.bashrc). | |
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then | |
. /etc/bash_completion | |
fi | |
function up { | |
[ "${1/[^0-9]/}" == "$1" ] && { | |
local ups="" | |
for i in $(seq 1 $1) | |
do | |
ups=$ups"../" | |
done | |
cd $ups | |
} || echo "usage: up INTEGER" | |
} | |
# | |
# Go up to the specified directory | |
# | |
upto(){ | |
if [ -z $1 ]; then | |
echo "Usage: upto [directory]" | |
return 1 | |
fi | |
local upto=$1 | |
cd "${PWD/\/$upto\/*//$upto}" | |
} | |
# | |
# Completion function for upto | |
# | |
_upto(){ | |
local cur=${COMP_WORDS[COMP_CWORD]} | |
d=${PWD//\//\ } | |
COMPREPLY=( $( compgen -W "$d" -- $cur ) ) | |
} | |
complete -F _upto upto | |
# | |
# Jumps to a directory at any level below. | |
# using globstar | |
# | |
jd(){ | |
if [ -z $1 ]; then | |
echo "Usage: jd [directory]"; | |
return 1 | |
else | |
cd **/$1 | |
fi | |
} | |
#export CDPATH=".::..:../..:~:~/projects/" | |
shopt -s cdspell # correct dir spelling errors on cd | |
shopt -s autocd # if a command is a dir name, cd to it | |
shopt -s cdable_vars # if cd arg is not a dir, assume it is a var | |
export GITAWAREPROMPT=~/.bash/git-aware-prompt | |
source "${GITAWAREPROMPT}/main.sh" | |
export PS1="\${debian_chroot:+(\$debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment