-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_obsidian.sh
83 lines (67 loc) · 2.68 KB
/
install_obsidian.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
#!/bin/bash
install_obsidian_linux() {
echo "Installing Obsidian for Linux..."
sudo apt update
sudo apt install -y wget jq
wget https://github.com/obsidianmd/obsidian-releases/releases/download/v1.7.4/Obsidian-1.7.4.AppImage -O obsidian.AppImage
chmod +x obsidian.AppImage
./obsidian.AppImage &
# Simulate creating a command alias for testing
sudo ln -sf $(pwd)/obsidian.AppImage /usr/local/bin/obsidian
}
install_obsidian_macos() {
echo "Installing Obsidian for macOS..."
which -s brew
if [[ $? != 0 ]] ; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
brew install wget jq
wget https://github.com/obsidianmd/obsidian-releases/releases/download/v1.7.4/Obsidian-1.7.4.dmg -O Obsidian.dmg
hdiutil attach Obsidian.dmg
cp -r /Volumes/Obsidian/Obsidian.app /Applications/
hdiutil detach /Volumes/Obsidian
open /Applications/Obsidian.app &
# Simulate creating a command alias for testing
sudo ln -sf /Applications/Obsidian.app/Contents/MacOS/Obsidian /usr/local/bin/obsidian
}
install_plugins() {
echo "Installing plugins..."
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
pkill Obsidian
elif [[ "$OSTYPE" == "darwin"* ]]; then
pkill Obsidian
elif [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
taskkill /IM Obsidian.exe /F
fi
if [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "darwin"* ]]; then
mkdir -p ~/.config/obsidian/plugins
elif [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
mkdir -p "$APPDATA\obsidian\plugins"
fi
PLUGINS_FILE=plugins.json
CORE_PLUGINS=$(jq -r '.core_plugins[]' $PLUGINS_FILE)
COMMUNITY_PLUGINS=$(jq -r '.community_plugins[]' $PLUGINS_FILE)
for plugin in $CORE_PLUGINS; do
echo "Enabling core plugin: $plugin"
# Simulate enabling core plugin by creating a file
touch "$HOME/.config/obsidian/plugins/$plugin"
done
for plugin in $COMMUNITY_PLUGINS; do
echo "Installing community plugin: $plugin"
# Simulate installing community plugin by creating a directory
mkdir -p "$HOME/.config/obsidian/plugins/$plugin"
done
echo "Plugins installed successfully!"
}
echo "Please select your operating system:"
echo "L) Linux"
echo "M) macOS"
echo "W) Windows"
read -p "Enter your choice: " os_choice
case "$os_choice" in
[Ll]) install_obsidian_linux ;;
[Mm]) install_obsidian_macos ;;
[Ww]) echo "Please run the script install_obsidian.ps1 in PowerShell for Windows installation." ;;
*) echo "Invalid choice. Exiting." ;;
esac
install_plugins