/
bashrc
145 lines (119 loc) · 4.88 KB
/
bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#
# Default initial .bashrc for the ac.
#
# Much of your environment should be setup in your .profile or
# .bash_profile file. The environment configured there will be
# inherited by subshells, scripts, batch job etc. This file
# (.bashrc) should only be used to define aliases, functions and,
# where necessary, terminal settings. By default this file will
# be sourced for every bash shell and script so avoid unnecessary
# actions.
#
# See your .profile file for examples of how to add paths to
# software in your environment.
# See http://nf.nci.org.au/facilities/software/modules.php
# for instructions on how to set your environment to use specific
# software packages.
#
# $Id: default.bashrc,v 1.3 2008/12/18 00:08:09 dbs900 Exp $
#
# Avoid going through here more than once in a shell
[[ $- != *i* ]] && return
# Source global definitions to get the module command defined.
# If you remove this from your file and/or you reset the BASH_ENV (or
# ENV) variables, you risk getting "module command not found"
# errors from batch jobs.
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
if [ -n "$PS1" ]; then
##
## Setup aliases etc for interactive session here
##
## Any noisy output should go in here. Output in non-interactive
## sessions can cause failure.
##
## Put any tty settings in here
# echo I am an interactive session, so it is ok to be a bit noisy.
true
fi
#nf_bashrc_sourced=YES
# COLOURS
#######################################################
#call locale to set colour fallback
source ~/.scripts/localeCheck
source ~/.scripts/apoklinonManage
#Some supercomputing clusters tend to use a dog old version of dir_colors - primarily to piss me off.
if [ $(echo "$(dircolors --version | head -n1 | awk '{ print $4 }') < 7.5" | bc) -eq 1 ]; then
[ $apoklinonRGB -eq 1 ] && eval `dircolors -b <(sed -e '/RESET/d' -e '/MULTIHARDLINK/d' -e '/CAPABILITY/d' $HOME/.dir_colors.RGB)` || eval `dircolors -b <(sed -e '/RESET/d' -e '/MULTIHARDLINK/d' -e '/CAPABILITY/d' $HOME/.dir_colors.8bit)`
else
[ $apoklinonRGB -eq 1 ] && eval `dircolors -b $HOME/.dir_colors.RGB` || eval `dircolors -b $HOME/.dir_colors.8bit`
fi
blueg=${blue#\\e[}
export GREP_COLOR=${blueg%m}
alias grep='grep --color=auto'
#-------------------------------------------------------------
# The 'ls' family (this assumes you use a recent GNU ls)
#-------------------------------------------------------------
#alias ll="ls -l --group-directories-first"
alias ls='ls -hF --color' # add colors for filetype recognition
alias la='ls -Al' # show hidden files
alias lx='ls -lXB' # sort by extension
alias lk='ls -lSr' # sort by size, biggest last
alias lc='ls -ltcr' # sort by and show change time, most recent last
alias lu='ls -ltur' # sort by and show access time, most recent last
alias lt='ls -ltr' # sort by date, most recent last
alias lm='ls -al |more' # pipe through 'more'
alias lr='ls -lR' # recursive ls
alias tree='tree -Csu' # nice alternative to 'recursive ls'
# If your version of 'ls' doesn't support --group-directories-first try this:
function ll(){ ls -l "$@"| egrep "^d" ; ls -lXB "$@" 2>&-| \
egrep -v "^d|total "; }
alias dud='du -sh' #requires directory
alias vi='vim'
# NOTES
#######################################################
# To temporarily bypass an alias, we preceed the command with a \
# EG: the ls command is aliased, but to use the normal ls command you would
# type \ls
function ii() {
echo -e "\nYou are logged on ${jazzberry}$HOST"
echo -e "\nAdditionnal information:$reset " ; uname -a
echo -e "\n${jazzberry}Users logged on:$reset " ; w -h
echo -e "\n${jazzberry}Current date :$reset " ; date
echo -e "\n${jazzberry}Machine stats :$reset " ; uptime
echo -e "\n${jazzberry}Memory stats :$reset " ; free
echo
}
# Various variables
host=${HOSTNAME%%[.0-9]*}
Host=${host[@]^}
Time12h="\T"
Time12a="\@"
PathShort="\w"
PathFull="\W"
NewLine="\n"
Jobs="\j"
function get_svn_rev() {
echo $(svn info 2>/dev/null | grep Revision | sed -e 's/Revision: //')
}
export PS1=$davgrayp$Host$resetp'$(git branch &>/dev/null;\
if [ $? -eq 0 ]; then \
echo "$(echo `git status` | grep "nothing to commit" > /dev/null 2>&1; \
if [ "$?" -eq "0" ]; then \
# @4 - Clean repository - nothing to commit
echo "'$bluep'"$(__git_ps1 " (%s)"); \
else \
# @5 - Changes to working tree
echo "'$brickp'"$(__git_ps1 " {%s}"); \
fi) '$sandyp$PathShort$resetp'\$ "; \
elif [[ -d .svn ]]; then\
# SVN repo \
svnrev=$(get_svn_rev); \
echo " $([ "$(svn st)" ] && echo "'$brickp'{svn:$svnrev}" || echo "'$bluep'(svn:$svnrev)";) '$sandyp$PathShort$resetp'\$ "; \
else \
# @2 - Prompt when not in GIT repo
echo " '$aquap$PathShort$resetp'\$ "; \
fi)'
# Host specific proflie additions
[ -f ~/.dotfiles/includes/"$host"/bashrc ] && source ~/.dotfiles/includes/"$host"/bashrc