-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsetup_omp.sh
More file actions
executable file
·57 lines (52 loc) · 1.72 KB
/
Copy pathsetup_omp.sh
File metadata and controls
executable file
·57 lines (52 loc) · 1.72 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
#!/usr/bin/env bash
: '
# :setup oh-my-posh theme using default base fonts
sudo scripts/linux/.include/setup_omp.sh --user $(id -un)
# :setup oh-my-posh theme using powerline fonts
sudo scripts/linux/.include/setup_omp.sh --user $(id -un) --theme powerline
# :setup oh-my-posh theme using nerd fonts
sudo scripts/linux/.include/setup_omp.sh --user $(id -un) --theme nerd
# :you can specify any themes from https://ohmyposh.dev/docs/themes/ (e.g. atomic)
sudo scripts/linux/.include/setup_omp.sh --user $(id -un) --theme atomic
'
if [ $EUID -ne 0 ]; then
printf '\e[31;1mRun the script as root.\e[0m\n'
exit 1
fi
# parse named parameters
theme=${theme:-base}
user=${user:-$(id -un 1000 2>/dev/null)}
while [ $# -gt 0 ]; do
if [[ $1 == *"--"* ]]; then
param="${1/--/}"
declare $param="$2"
fi
shift
done
# check if specified user exists
if ! sudo -u $user true 2>/dev/null; then
if [ -n "$user" ]; then
printf "\e[31;1mUser does not exist ($user).\e[0m\n"
else
printf "\e[31;1mUser ID 1000 not found.\e[0m\n"
fi
exit 1
fi
# path variables
CFG_PATH="$(sudo -u $user sh -c 'echo $HOME/tmp/config/omp_cfg')"
OH_MY_POSH_PATH='/usr/local/share/oh-my-posh'
# create CFG folder
sudo -u $user mkdir -p $CFG_PATH
# copy profile for WSL setup
if [ -f ".config/omp_cfg/${theme}.omp.json" ]; then
cp -f ".config/omp_cfg/${theme}.omp.json" "$CFG_PATH"
else
curl -fsSk -o "$CFG_PATH/${theme}.omp.json" "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/${theme}.omp.json" 2>/dev/null
fi
# *Copy oh-my-posh theme
if [ -f "$CFG_PATH/${theme}.omp.json" ]; then
mkdir -p "$OH_MY_POSH_PATH"
install -m 0644 "$CFG_PATH/${theme}.omp.json" "$OH_MY_POSH_PATH/theme.omp.json"
fi
# clean config folder
rm -fr "$CFG_PATH"