Skip to content

Instantly share code, notes, and snippets.

@Axeltherabbit
Last active October 2, 2020 13:26
Show Gist options
  • Save Axeltherabbit/dc7bf261841c4ade631c318a80bff00e to your computer and use it in GitHub Desktop.
Save Axeltherabbit/dc7bf261841c4ade631c318a80bff00e to your computer and use it in GitHub Desktop.
#!/bin/bash
#this is a custom file of the original source https://gist.github.com/hernamesbarbara/1937937
export TERM=xterm-color
export CLICOLOR=1
# export LSCOLORS=Exfxcxdxbxegedabagacad
export LSCOLORS=gxfxcxdxbxegedabagacad # Dark lscolor scheme
# Don't put duplicate lines in your bash history
export HISTCONTROL=ignoredups
#tab autocomplete
bind 'TAB:menu-complete'
bind 'set show-all-if-ambiguous on'
bind '"\e[Z":menu-complete-backward'
# Readline, the line editing library that bash uses, does not know
# that the terminal escape sequences do not take up space on the
# screen. The redisplay code assumes, unless told otherwise, that
# each character in the prompt is a `printable' character that
# takes up one character position on the screen.
# You can use the bash prompt expansion facility (see the PROMPTING
# section in the manual page) to tell readline that sequences of
# characters in the prompt strings take up no screen space.
# Use the \[ escape to begin a sequence of non-printing characters,
# and the \] escape to signal the end of such a sequence.
# Define some colors first:
RED='\[\e[1;31m\]'
BOLDYELLOW='\[\e[1;33m\]'
GREEN='\[\e[0;32m\]'
BLUE='\[\e[1;34m\]'
DARKBROWN='\[\e[1;33m\]'
DARKGRAY='\[\e[1;30m\]'
CUSTOMCOLORMIX='\[\e[1;30m\]'
DARKCUSTOMCOLORMIX='\[\e[1;32m\]'
LIGHTBLUE="\[\033[1;36m\]"
PURPLE='\[\e[1;35m\]' #git branch
NC='\[\e[0m\]' # No Color
PS1="${LIGHTBLUE}\\u@\\h ${BOLDYELLOW}[\\w] ${PURPLE}\$(parse_git_branch)${DARKCUSTOMCOLORMIX}$ ${NC}"
list_detailed_more()
{
ls -lah $1 | more
}
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export -f parse_git_branch
parse_svn_branch() {
parse_svn_url | sed -e 's#^'"$(parse_svn_repository_root)"'##g' | awk -F / '{print "(svn::"$1 "/" $2 ")"}'
}
export -f parse_svn_branch
parse_svn_url() {
svn info 2>/dev/null | grep -e '^URL*' | sed -e 's#^URL: *\(.*\)#\1#g '
}
export -f parse_svn_url
parse_svn_repository_root() {
svn info 2>/dev/null | grep -e '^Repository Root:*' | sed -e 's#^Repository Root: *\(.*\)#\1\/#g '
}
export -f parse_svn_repository_root
# Safe rm procedure
safe_rm()
{
# Cycle through each argument for deletion
for file in $*; do
if [ -e $file ]; then--color=auto
# Target exists and can be moved to Trash safely
if [ ! -e ~/.Trash/$file ]; then
mv $file ~/.Trash
# Target exists and conflicts with target in Trash
elif [ -e ~/.Trash/$file ]; then
# Increment target name until
# there is no longer a conflict
i=1
while [ -e ~/.Trash/$file.$i ];
do
i=$(($i + 1))
done
# Move to the Trash with non-conflicting name
mv $file ~/.Trash/$file.$i
fi
# Target doesn't exist, return error
else
echo "rm: $file: No such file or directory";
fi
done
}
###############################
## Aliases ##
###############################
alias reload='source ~/.bash_profile && source ~/.bashrc'
alias ls='ls -hp --color=auto'
alias la='ls -la --color=auto'
alias l='ls -CF --color=auto'
alias cll="clear; ls -lAh"
alias ..="cd .."
alias ..2="cd ../../"
alias ..3="cd ../../../"
alias back='cd -'
alias ~='cd ~'
alias o='open'
alias bp='mate ~/.bash_profile'
alias trash='safe_rm'
alias grep='grep -H -n --color=auto'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias cwd='pwd | tr -d "\r\n" | pbcopy' #copy working directory
alias where="pwd"
alias h='history'
alias ppath="echo $PATH | tr ':' '\n'" #print path
alias untar="tar -xvf"
alias rtags="find . -name '*.rb' | xargs /usr/bin/ctags -R -a -f TAGS"
#alias xcopy='xclip -selection clipboard'
#alias xpaste='xclip -selection clipboard -o'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment