forked from sigmundch/.scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc
153 lines (122 loc) · 4.02 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
145
146
147
148
149
150
151
152
153
# Usage: load .bashrc, define ahead: HOME, MY_MACHINE, DART_EDITOR_HOME, DART_SDK_HOME
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
# don't put duplicate lines in the history
export HISTCONTROL=ignoredups
# ... and ignore same sucessive entries
export HISTCONTROL=ignoreboth
# update the values of LINES and COLUMNS after each command, if needed
shopt -s checkwinsize
shopt -s histappend
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
export TERM='xterm-256color'
function long_prompt_command {
local red_bold="[01;31m"
local none="[0m"
local green="[0;32m"
local light_gray="[0;38;5;240m"
local light_red="[0;38;5;88m"
echo -en "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"
echo -en "$red_bold|--[$green$(formatted_date)$none ";
show_git_branch;
show_and_update_client;
echo -e "$red_bold]--|$none"
}
function long_prompt_command2 {
local red_bold="[01;31m"
local none="[0m"
local green="[0;32m"
local light_gray="[0;38;5;240m"
local light_red="[0;38;5;88m"
echo -en "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"
echo -e "$red_bold|$light_red--$light_gray end: $green$(formatted_date)"
echo -en "$red_bold|$light_red--$light_gray ";
show_git_branch;
show_and_update_client;
echo -e "$none"
}
function show_and_update_client {
echo -en `pwd`;
}
function formatted_date {
date "+%H:%M:%S"
}
function show_git_branch {
local cyan="[36m"
local none="[0m"
local head_file="$(git rev-parse --show-cdup 2>/dev/null).git/HEAD"
if [ -f $head_file ]; then
(cat $head_file | sed -e "s,.*heads/\(.*\), $cyan(\1)$none," |
xargs echo -en)
fi
}
function von {
PROMPT_COMMAND='long_prompt_command'
}
function voff {
PROMPT_COMMAND='echo -en "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
}
function named_prompt {
PS1="\[\033[01;31m\]|--[\[\033[0m\]$1\[\033[31;1m\]]\[\033[0m\] "
}
PS1='\[\033[01;31m\]`if [ \u != $MY_USER ]; then echo "\u "; fi``if [ \h != $MY_MACHINE ]; then echo "[@\h]"; else echo "|"; fi`\[\033[0m\] '
von;
if [ -f $SCRIPT_DIR/bin/bash_completion ]; then
. $SCRIPT_DIR/bin/bash_completion
fi
if [ -f $SCRIPT_DIR/bin/git_completion.sh ]; then
. $SCRIPT_DIR/bin/git_completion.sh
fi
export EDITOR='vim'
# ls with colors
alias ls='ls --color=auto'
# Dart
export DART_DRT_HOME=$DART_EDITOR_HOME/chromium/
#export MY_DART_SDK=$DART_EDITOR_HOME/dart-sdk
export PATH=$SCRIPT_DIR/bin:~/bin/depot_tools:$PATH:$DART_SDK_HOME/bin:$DART_DRT_HOME:/usr/local/lib/node_modules/
alias dartium=$DART_EDITOR_HOME/chromium/chrome
alias editor="PATH=$JAVA_HOME/bin:$PATH $DART_EDITOR_HOME/DartEditor"
export GYP_GENERATORS="ninja,make"
source $SCRIPT_DIR/bin/load_all.sh
function fix_bashrc {
vim ~/.bashrc;
source ~/.bashrc;
echo "~/.bashrc updated";
}
function reload_bashrc {
source ~/.bashrc;
}
function append_and_reload_history {
history -a; history -c; history -r
}
function notify_done {
notify-send "We are done! $@" -i $([[ $? == 0 ]] && echo "info" || echo "error")
}
export GREP_OPTIONS="--color=auto"
alias v='gvim --remote-silent'
# enable us_intl keyboard and toggling with alt+shift:
# setxkbmap -option grp:switch,grp:shifts_toggle us,us_intl
# see file /usr/share/X11/xkb/symbols/group for more group descriptions...
function before_command2 {
[ -n "$COMP_LINE" ] && return
[ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] && return
local red_bold="[01;31m"
local none="[0m"
local green="[0;32m"
local light_gray="[0;38;5;240m"
local light_red="[0;38;5;88m"
echo -e "$red_bold|$light_red--$light_gray start: $green$(formatted_date)$none";
}
function before_command {
[ -n "$COMP_LINE" ] && return
[ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] && return
local red_bold="[01;31m"
local none="[0m"
local green="[0;32m"
local light_gray="[0;38;5;240m"
local light_red="[0;38;5;88m"
echo -e "$red_bold|$light_red--$light_gray start time: $(formatted_date)$none";
}
trap 'before_command' DEBUG