-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy-functions
More file actions
133 lines (111 loc) · 3.54 KB
/
my-functions
File metadata and controls
133 lines (111 loc) · 3.54 KB
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
#!/bin/bash
####
# My Functions
####
function backup_bashrc(){
local date=`date +%Y%m%d%H%M%S`
cp ~/.bashrc{,.$date}
}
function install_liquidprompt(){
# Make bin and .config directories
mkdir -p ~/bin ~/.config
git clone https://github.com/nojhan/liquidprompt.git ~/bin/liquidprompt
cp ~/bin/liquidprompt/liquidpromptrc-dist ~/.config/liquidpromptrc
backup_bashrc
cat >> ~/.bashrc << STOP
# Hareesh. Added liquidprompt support at $date.
# Only load Liquid Prompt in interactive shells, not from a script or from scp
[[ \$- = *i* ]] && source ~/bin/liquidprompt/liquidprompt
STOP
# Customize the config.
sed -i.bak 's/LP_ENABLE_VCS_ROOT=0/LP_ENABLE_VCS_ROOT=1/' ~/.config/liquidpromptrc
echo "Done installing liquidprompt"
}
function install_cgrep(){
backup_bashrc
cat >> ~/.bashrc << STOP
function cgrep(){
local command=\$@
echo \${command}
grep --color=always \${command} | less -R
}
STOP
}
function install_fzf(){
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
}
function install_vim_plug(){
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
}
function install_dotfiles(){
git clone https://github.com/hareeshpc/dotfiles.git ~/.dotfiles
}
function setup_dotfile_symlinks(){
ln -s ~/.dotfiles/.vimrc .vimrc
ln -s ~/.dotfiles/.tmux.conf .tmux.conf
}
##########################
# Devstack functions
# These are curated functions imported from Devstack
##########################
function passed {
local lineno
lineno=$(caller 0 | awk '{print $1}')
local function
function=$(caller 0 | awk '{print $2}')
local msg="$1"
if [ -z "$msg" ]; then
msg="OK"
fi
PASS=$((PASS+1))
echo "PASS: $function:L$lineno - $msg"
}
# fail a test, printing out MSG
# usage: failed message
function failed {
local lineno
lineno=$(caller 0 | awk '{print $1}')
local function
function=$(caller 0 | awk '{print $2}')
local msg="$1"
FAILED_FUNCS+="$function:L$lineno\n"
echo "ERROR: $function:L$lineno!"
echo " $msg"
ERROR=$((ERROR+1))
}
function _install_epel {
# NOTE: We always remove and install latest -- some environments
# use snapshot images, and if EPEL version updates they break
# unless we update them to latest version.
if sudo yum repolist enabled epel | grep -q 'epel'; then
uninstall_package epel-release || true
fi
# This trick installs the latest epel-release from a bootstrap
# repo, then removes itself (as epel-release installed the
# "real" repo).
#
# You would think that rather than this, you could use
# $releasever directly in .repo file we create below. However
# RHEL gives a $releasever of "6Server" which breaks the path;
# see https://bugzilla.redhat.com/show_bug.cgi?id=1150759
cat <<EOF | sudo tee /etc/yum.repos.d/epel-bootstrap.repo
[epel-bootstrap]
name=Bootstrap EPEL
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-7&arch=\$basearch
failovermethod=priority
enabled=0
gpgcheck=0
EOF
# Enable a bootstrap repo. It is removed after finishing
# the epel-release installation.
is_package_installed yum-utils || install_package yum-utils
sudo yum-config-manager --enable epel-bootstrap
yum_install epel-release || \
die $LINENO "Error installing EPEL repo, cannot continue"
sudo rm -f /etc/yum.repos.d/epel-bootstrap.repo
# ... and also optional to be enabled
sudo yum-config-manager --enable rhel-7-server-optional-rpms
}
#################