generated from 2KAbhishek/shelly
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·44 lines (38 loc) · 1.17 KB
/
install.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
#!/usr/bin/env bash
# shellcheck disable=2016
install_fish() {
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
fish -c "fish_add_path $HOME/.local/bin"
fi
if ! printenv NOTES_DIR > /dev/null; then
fish -c "set -Ux NOTES_DIR $NOTES_DIR"
fi
}
install_shell() {
exports_file="$1"
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
echo 'export PATH="$HOME/.local/bin:$PATH"' >>"$exports_file"
fi
if ! printenv NOTES_DIR > /dev/null; then
echo "export NOTES_DIR=$NOTES_DIR" >>"$exports_file"
fi
}
if [ -z "$EDITOR" ]; then
echo "Error: EDITOR environment variable not set. Please set it to your preferred text editor."
exit 1
fi
if [ ! -d "$NOTES_DIR" ]; then
NOTES_DIR="$HOME/Projects/notes"
mkdir -p "$NOTES_DIR"
fi
cp -irv templates "$NOTES_DIR/"
mkdir -p ~/.local/bin
ln -sfnv "$PWD/tdo.sh" ~/.local/bin/tdo
case "$SHELL" in
*/bash) install_shell "$HOME/.bashrc" ;;
*/zsh) install_shell "$HOME/.zshrc" ;;
*/fish) install_fish ;;
*) echo "Unsupported shell. Please set the environment variables manually." && exit 1 ;;
esac
echo "tdo setup completed successfully!"
echo "Please make sure to reload your shell"