-
Notifications
You must be signed in to change notification settings - Fork 11
/
sr_quality_of_life.sh
86 lines (75 loc) · 2.75 KB
/
sr_quality_of_life.sh
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
#!/bin/bash
while [[ $# > 1 ]]
do
key="$1"
case $key in
-u|--user)
MY_USERNAME="$2"
shift
;;
-e|--emacs)
INSTALL_EMACS="$2"
shift
;;
-b|--bash_only)
BASH_ONLY="$2"
shift
;;
*)
# ignore unknown option
;;
esac
shift
done
if [ -z "${MY_USERNAME}" ]; then
if [ -z "${USER}" ]; then
MY_USERNAME="user"
else
MY_USERNAME="${USER}"
fi
fi
if [ -z "${INSTALL_EMACS}" ]; then
INSTALL_EMACS=false
fi
if [ -z "${BASH_ONLY}" ]; then
BASH_ONLY=false
fi
echo ""
echo "================================================================="
echo "| |"
echo "| Shadow quality of life tools |"
echo "| |"
echo "================================================================="
echo ""
echo "possible options: "
echo " * -u or --user Overwrite the auto-detected username (current username is $MY_USERNAME)"
echo " * -b or --bash_only Set to true to only install bash functions"
echo ""
echo "example: bash <(curl -Ls bit.ly/sr_qol)"
echo ""
echo "User? = ${MY_USERNAME}"
echo "BASH_ONLY? = ${BASH_ONLY}"
if [[ "${BASH_ONLY}" == false ]]; then
echo "Installing and configuring additional quality-of-life tools"
sudo apt update
sudo apt install -y tree highlight speedometer xsel screen nano git curl jq nmap
if [[ "${INSTALL_EMACS}" == true ]]; then
sudo apt install -y byobu emacs
fi
echo "Configuring highlight"
for new_lang in $(echo -e "launch\nxacro\nurdf"); do
if [[ $(cat /etc/highlight/filetypes.conf | grep "Lang=\"xml\", Extensions=" | grep ${new_lang} | wc -l) -eq 0 ]]; then
echo "Adding ${new_lang} as xml to highlight"
cat /etc/highlight/filetypes.conf | sed -r 's/\{ Lang=\"xml\", Extensions=\{/\{ Lang=\"xml\", Extensions=\{\"'${new_lang}'\", /g' | sudo tee /etc/highlight/filetypes.conf
fi
done
fi
echo "Installing fzf"
git clone --depth 1 https://github.com/junegunn/fzf.git /home/${MY_USERNAME}/.fzf
/home/${MY_USERNAME}/.fzf/install --all
BASH_FUNCTIONS_LOCATION="/home/${MY_USERNAME}/.bash_functions"
echo "Grabbing additional bash cmds and saving them to ${BASH_FUNCTIONS_LOCATION}"
wget -O ${BASH_FUNCTIONS_LOCATION} https://raw.githubusercontent.com/shadow-robot/sr-build-tools/master/docker/utils/additional_bashrc_commands_quality_of_life
if [[ $(cat /home/${MY_USERNAME}/.bashrc | grep "source ~/.bash_functions$" | wc -l) -eq 0 ]]; then
echo "source ~/.bash_functions" >> /home/${MY_USERNAME}/.bashrc
fi