-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-dh
More file actions
41 lines (32 loc) · 1.22 KB
/
Copy pathupdate-dh
File metadata and controls
41 lines (32 loc) · 1.22 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
#!/bin/bash
# =========================================
# update-dh — Interactive Docker Workspace Updater
# Sets the 'dh' alias via whiptail popup
# Works on QNAP / Linux with whiptail installed
# =========================================
# Check if whiptail is installed
if ! command -v whiptail >/dev/null 2>&1; then
echo "❌ whiptail is not installed. Please install it first (e.g., opkg install whiptail)."
exit 1
fi
# Get current dh path from bashrc, fallback to /share/docker
CURRENT_DH=$(grep "alias dh=" ~/.bashrc | cut -d"'" -f2)
CURRENT_DH=${CURRENT_DH:-/share/docker}
# Show whiptail input box (folder only, no cd)
NEW_DH=$(whiptail --title "Docker Workspace Setup" \
--inputbox "Enter your Docker workspace folder:" 10 60 "$CURRENT_DH" 3>&1 1>&2 2>&3)
# If user pressed Cancel, exit
if [[ $? -ne 0 ]]; then
echo "❌ Operation cancelled."
exit 1
fi
# Use current value if empty
NEW_DH=${NEW_DH:-$CURRENT_DH}
# Remove old dh alias from bashrc
sed -i "/alias dh=/d" ~/.bashrc
# Add new dh alias
echo "alias dh='cd $NEW_DH'" >> ~/.bashrc
# Activate alias immediately
alias dh="cd $NEW_DH"
echo "✅ dh alias updated to: $NEW_DH"
echo "You can now use 'dh' to jump to your Docker workspace immediately."