fix multiple word app names (#1087)

* fix multiple word app names

* fix multiple words string handling

* upstream selector and tui-remove multi-select

---------

Co-authored-by: David Heinemeier Hansson <david@hey.com>
This commit is contained in:
John Schmidt
2025-08-26 11:57:39 +02:00
committed by GitHub
parent 334aa214ba
commit 13f2cd9641
2 changed files with 27 additions and 16 deletions

View File

@@ -3,8 +3,8 @@
ICON_DIR="$HOME/.local/share/applications/icons" ICON_DIR="$HOME/.local/share/applications/icons"
DESKTOP_DIR="$HOME/.local/share/applications/" DESKTOP_DIR="$HOME/.local/share/applications/"
if [ "$#" -ne 1 ]; then if [ "$#" -eq 0 ]; then
# Find all web apps # Find all TUIs
while IFS= read -r -d '' file; do while IFS= read -r -d '' file; do
if grep -q '^Exec=.*alacritty.*-e' "$file"; then if grep -q '^Exec=.*alacritty.*-e' "$file"; then
TUIS+=("$(basename "${file%.desktop}")") TUIS+=("$(basename "${file%.desktop}")")
@@ -14,23 +14,28 @@ if [ "$#" -ne 1 ]; then
if ((${#TUIS[@]})); then if ((${#TUIS[@]})); then
IFS=$'\n' SORTED_TUIS=($(sort <<<"${TUIS[*]}")) IFS=$'\n' SORTED_TUIS=($(sort <<<"${TUIS[*]}"))
unset IFS unset IFS
APP_NAME=$(gum choose --no-limit --header "Select TUI to remove..." --selected-prefix="✗ " "${SORTED_TUIS[@]}") APP_NAMES_STRING=$(gum choose --no-limit --header "Select TUI to remove..." --selected-prefix="✗ " "${SORTED_TUIS[@]}")
# Convert newline-separated string to array
APP_NAMES=()
while IFS= read -r line; do
[[ -n "$line" ]] && APP_NAMES+=("$line")
done <<< "$APP_NAMES_STRING"
else else
echo "No TUIs to remove." echo "No TUIs to remove."
exit 1 exit 1
fi fi
else else
APP_NAME="$1" # Use array to preserve spaces in app names
APP_NAMES=("$@")
fi fi
if [[ -z "$APP_NAME" ]]; then if [[ ${#APP_NAMES[@]} -eq 0 ]]; then
echo "You must provide TUI name." echo "You must provide TUI names."
exit 1 exit 1
fi fi
rm "$DESKTOP_DIR/$APP_NAME.desktop" for APP_NAME in "${APP_NAMES[@]}"; do
rm "$ICON_DIR/$APP_NAME.png" rm -f "$DESKTOP_DIR/$APP_NAME.desktop"
rm -f "$ICON_DIR/$APP_NAME.png"
if [ "$#" -ne 1 ]; then echo "Removed $APP_NAME"
echo -e "Removed $APP_NAME\n" done
fi

View File

@@ -14,21 +14,27 @@ if [ "$#" -eq 0 ]; then
if ((${#WEB_APPS[@]})); then if ((${#WEB_APPS[@]})); then
IFS=$'\n' SORTED_WEB_APPS=($(sort <<<"${WEB_APPS[*]}")) IFS=$'\n' SORTED_WEB_APPS=($(sort <<<"${WEB_APPS[*]}"))
unset IFS unset IFS
APP_NAMES=$(gum choose --no-limit --header "Select web app to remove..." --selected-prefix="✗ " "${SORTED_WEB_APPS[@]}") APP_NAMES_STRING=$(gum choose --no-limit --header "Select web app to remove..." --selected-prefix="✗ " "${SORTED_WEB_APPS[@]}")
# Convert newline-separated string to array
APP_NAMES=()
while IFS= read -r line; do
[[ -n "$line" ]] && APP_NAMES+=("$line")
done <<< "$APP_NAMES_STRING"
else else
echo "No web apps to remove." echo "No web apps to remove."
exit 1 exit 1
fi fi
else else
APP_NAMES="$*" # Use array to preserve spaces in app names
APP_NAMES=("$@")
fi fi
if [[ -z "$APP_NAMES" ]]; then if [[ ${#APP_NAMES[@]} -eq 0 ]]; then
echo "You must provide web app names." echo "You must provide web app names."
exit 1 exit 1
fi fi
for APP_NAME in $APP_NAMES; do for APP_NAME in "${APP_NAMES[@]}"; do
rm -f "$DESKTOP_DIR/$APP_NAME.desktop" rm -f "$DESKTOP_DIR/$APP_NAME.desktop"
rm -f "$ICON_DIR/$APP_NAME.png" rm -f "$ICON_DIR/$APP_NAME.png"
echo "Removed $APP_NAME" echo "Removed $APP_NAME"