Is it possible to hide link file:... behide "SHOW"? notify-send "Warning: Git Changes…
- User
Is it possible to hide link
file:...behide "SHOW"? notify-send "Warning: Git Changes Detected" "Unstaged changes found!\nClick to view: file://APP_NAME Assistant
Yes, it is possible to hide the
file://...link behind a word like "SHOW", butnotify-sendhas limitations. Specifically:⚠️ Limitations of
notify-send:notify-sendonly supports very basic formatting, and does not support rich text or clickable links with custom labels like HTML<a href="...">SHOW</a>.- It only supports plain text, and if you include a
file://orhttp://URL, some notification daemons (likelibnotifyon GNOME) will automatically make it clickable — but always showing the full URL.
✅ Workaround: Use "SHOW" as the body and open the file manually
You can't display
"SHOW"as a clickable link label usingnotify-send, but you can do this:- Show
"SHOW"in the notification. - When the user clicks the notification, open the file (or terminal command) using a script or desktop notification actions.
Here's how:
🔧 Option 1: Use
dunst+ custom action (advanced)If you're using Dunst, you can define custom notification actions and format notifications more flexibly.
Example:
notify-send -a "$APP_NAME" -u critical \ "Warning: Git Changes Detected" \ "Unstaged changes found! Click SHOW to view." \ -h string:x-dunst-stack-tag:git-warning \ -a "action=show_diff;SHOW"Then in your Dunst config (
~/.config/dunst/dunstrc), define a rule to execute a command when "SHOW" is clicked.This requires configuration and is not portable across all desktop environments.
🛠️ Option 2: Simpler approach (standard
notify-send+ click handler)Use a shell script that opens the file manually when the notification is clicked.
#!/bin/bash APP_NAME="Git Watcher" RESULTS_FILE="/tmp/git_changes.log" # Write git diff output to file git diff > "$RESULTS_FILE" # Notify user notify-send \ -u critical \ -a "$APP_NAME" \ "Warning: Git Changes Detected" \ "Unstaged changes found! Click to view details." \ "file://$RESULTS_FILE"When clicked, it will try to open the file in your default file manager or editor (depending on your desktop environment). But again, it shows the full
file:///tmp/git_changes.log.
✅ Best Practical Solution: Use a wrapper script for click behavior
Instead of trying to show
"SHOW"in the notification, intercept the click event by wrapping the notification in a script that opens the file manually.#!/bin/bash APP_NAME="Git Watcher" RESULTS_FILE="/tmp/git_changes.log" # Write git diff output to file git diff > "$RESULTS_FILE" # Show notification NOTIFY_PID=$$ notify-send \ -u critical \ -a "$APP_NAME" \ "Warning: Git Changes Detected" \ "Unstaged changes found! Click SHOW to view." \ -A "open_file=SHOW" \ "file://$RESULTS_FILE"Then use something like
dunstifyornclickor a DBus listener to detect the click and run a command like:xdg-open "$RESULTS_FILE"Or better yet, open it directly in a text editor:
xdg-open "$RESULTS_FILE" &
✅ Alternative: Use a GUI toolkit like
zenityoryadIf you want full control over the UI:
zenity --warning \ --text="Unstaged changes found!" \ --extra-button=SHOW \ && xdg-open "$RESULTS_FILE"This gives you a modal dialog with a
SHOWbutton that opens the file.
✅ Summary
Approach Can show "SHOW" as clickable label? Notes notify-send❌ Only shows full URL dunst+ custom actions✅ Requires setup xdg-openafter click✅ (indirectly) Simple and works everywhere zenity/yad✅ Full control, GUI-based
📝 Recommendation:
For portability and simplicity, go with:
notify-send -u critical "Warning: Git Changes Detected" "Unstaged changes found!\nClick to view: file://$RESULTS_FILE" -a "$APP_NAME"And then just accept that the full path is shown — most users don't mind.
If you really want to show "SHOW", consider launching a GUI dialog (
zenity) or switch to a notification daemon like Dunst that allows advanced scripting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.