-
Notifications
You must be signed in to change notification settings - Fork 20
fix: keep cursor shim working in AppImage terminals #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
121f586
8945586
70840f4
4fc8394
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,15 +94,20 @@ chmod +x "$CLI_PATH" | |
|
|
||
| log_ok "Cursor installer script has been placed in $CLI_PATH" | ||
|
|
||
| log_step "Ensuring cursor shim..." | ||
| LOCAL_SHIM_PATH="$SCRIPT_DIR/shim.sh" LOCAL_SHIM_HELPER_PATH="$SCRIPT_DIR/scripts/ensure-shim.sh" sync_shim_assets && run_ensure_shim || log_warn "Shim update skipped or failed; continuing." | ||
| log_step "Ensuring cursor shim and shell PATH setup..." | ||
| LOCAL_SHIM_PATH="$SCRIPT_DIR/shim.sh" | ||
| LOCAL_SHIM_HELPER_PATH="$SCRIPT_DIR/scripts/ensure-shim.sh" | ||
| LOCAL_SHELL_PATH_SCRIPT="$SCRIPT_DIR/shell-path.sh" | ||
| LOCAL_SHELL_PATH_HELPER_PATH="$SCRIPT_DIR/scripts/ensure-shell-path.sh" | ||
| sync_shim_assets && sync_shell_path_assets && run_ensure_shim && run_ensure_shell_path || log_warn "Shim or shell PATH setup skipped or failed; continuing." | ||
|
|
||
| # Check if ~/.local/bin is in PATH | ||
| if [[ ":$PATH:" != *":$LOCAL_BIN:"* ]]; then | ||
| log_warn "$LOCAL_BIN is not in your PATH." | ||
| log_info "To add it, run this or add it to your shell profile:" | ||
| log_info "export PATH=\"\$HOME/.local/bin:\$PATH\"" | ||
| fi | ||
| warn_if_cursor_shadowed_by_appimage_runtime | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This new call is unconditional, but Useful? React with 👍 / 👎. |
||
|
|
||
| # Run cursor --update to download and install Cursor | ||
| log_step "Downloading and installing Cursor ($INSTALL_MODE mode) from ${REPO_OWNER}/${REPO_NAME}@${REPO_BRANCH}..." | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| #!/bin/sh | ||
| # Ensure supported interactive shells source cursor-installer's PATH helper. | ||
| set -eu | ||
|
|
||
| ACTION="${1:-ensure}" | ||
| LIB_DIR="${HOME}/.local/share/cursor-installer" | ||
| SHELL_PATH_SCRIPT="${SHELL_PATH_SCRIPT:-$LIB_DIR/shell-path.sh}" | ||
| START_MARKER="# >>> cursor-installer path >>>" | ||
| END_MARKER="# <<< cursor-installer path <<<" | ||
|
|
||
| build_source_block() { | ||
| cat <<EOF | ||
| $START_MARKER | ||
| if [ -f "$SHELL_PATH_SCRIPT" ]; then | ||
| . "$SHELL_PATH_SCRIPT" | ||
| fi | ||
| $END_MARKER | ||
| EOF | ||
| } | ||
|
|
||
| print_target_files() { | ||
| if [ -n "${TARGET_SHELL_FILES:-}" ]; then | ||
| old_IFS="$IFS" | ||
| IFS=: | ||
| for file in $TARGET_SHELL_FILES; do | ||
| [ -n "$file" ] && printf '%s\n' "$file" | ||
| done | ||
| IFS="$old_IFS" | ||
| return 0 | ||
| fi | ||
|
|
||
| if [ -n "${TARGET_SHELL_RC:-}" ]; then | ||
| printf '%s\n' "$TARGET_SHELL_RC" | ||
| return 0 | ||
| fi | ||
|
|
||
| shell_name=$(basename "${SHELL:-}") | ||
| case "$shell_name" in | ||
| bash) | ||
| printf '%s\n' "$HOME/.bashrc" | ||
|
Comment on lines
+37
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
| ;; | ||
| zsh) | ||
| printf '%s\n' "$HOME/.zshrc" | ||
| ;; | ||
| sh|dash|ksh) | ||
| printf '%s\n' "$HOME/.profile" | ||
| ;; | ||
| *) | ||
| echo "Skipping shell PATH setup; unsupported shell: ${SHELL:-unknown}" >&2 | ||
| return 1 | ||
| ;; | ||
| esac | ||
| } | ||
|
|
||
| strip_managed_block() { | ||
| file="$1" | ||
| tmp="$2" | ||
|
|
||
| if [ -f "$file" ]; then | ||
| awk -v start="$START_MARKER" -v end="$END_MARKER" ' | ||
| $0 == start { skip = 1; next } | ||
| skip && $0 == end { skip = 0; next } | ||
| !skip { print } | ||
| ' "$file" > "$tmp" | ||
| else | ||
| : > "$tmp" | ||
| fi | ||
| } | ||
|
|
||
| trim_trailing_blank_lines() { | ||
| trim_file="$1" | ||
| trimmed_file=$(mktemp) | ||
|
|
||
| awk ' | ||
| { lines[NR] = $0 } | ||
| END { | ||
| last = NR | ||
| while (last > 0 && lines[last] ~ /^[[:space:]]*$/) { | ||
| last-- | ||
| } | ||
| for (i = 1; i <= last; i++) { | ||
| print lines[i] | ||
| } | ||
| } | ||
| ' "$trim_file" > "$trimmed_file" | ||
|
|
||
| mv "$trimmed_file" "$trim_file" | ||
| } | ||
|
|
||
| write_updated_file() { | ||
| source_tmp="$1" | ||
| destination_file="$2" | ||
|
|
||
| if [ -e "$destination_file" ] || [ -L "$destination_file" ]; then | ||
| cat "$source_tmp" > "$destination_file" | ||
| rm -f "$source_tmp" | ||
| return 0 | ||
| fi | ||
|
|
||
| mv "$source_tmp" "$destination_file" | ||
| } | ||
|
|
||
| ensure_block() { | ||
| file="$1" | ||
| tmp=$(mktemp) | ||
| mkdir -p "$(dirname "$file")" | ||
| strip_managed_block "$file" "$tmp" | ||
| trim_trailing_blank_lines "$tmp" | ||
|
|
||
| if [ -s "$tmp" ]; then | ||
| printf '\n' >> "$tmp" | ||
| fi | ||
|
|
||
| build_source_block >> "$tmp" | ||
|
|
||
| if [ -f "$file" ] && cmp -s "$tmp" "$file"; then | ||
| rm -f "$tmp" | ||
| echo "Shell PATH setup already present in $file" | ||
| return 0 | ||
| fi | ||
|
|
||
| write_updated_file "$tmp" "$file" | ||
| echo "Ensured shell PATH setup in $file" | ||
| } | ||
|
|
||
| remove_block() { | ||
| file="$1" | ||
| [ -f "$file" ] || return 0 | ||
|
|
||
| tmp=$(mktemp) | ||
| strip_managed_block "$file" "$tmp" | ||
|
|
||
| if cmp -s "$tmp" "$file"; then | ||
| rm -f "$tmp" | ||
| return 0 | ||
| fi | ||
|
|
||
| write_updated_file "$tmp" "$file" | ||
| echo "Removed shell PATH setup from $file" | ||
| } | ||
|
|
||
| if [ "$ACTION" = "ensure" ] && [ ! -f "$SHELL_PATH_SCRIPT" ]; then | ||
| echo "Error: shell-path.sh source not found at $SHELL_PATH_SCRIPT" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! target_files=$(print_target_files); then | ||
| exit 0 | ||
| fi | ||
|
|
||
| printf '%s\n' "$target_files" | while IFS= read -r file; do | ||
| [ -n "$file" ] || continue | ||
|
|
||
| case "$ACTION" in | ||
| ensure) | ||
| ensure_block "$file" | ||
| ;; | ||
| --remove|remove) | ||
| remove_block "$file" | ||
| ;; | ||
| *) | ||
| echo "Unknown action: $ACTION" >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update_cursornow callsrefresh_shell_path_assetsunconditionally, but installed environments can still source an older~/.local/share/cursor-installer/lib.shthat predates this API. In that mixed-version state,cursor-installer --updateexits withcommand not foundbefore any update logic runs, so users are left with a broken updater until lib assets are manually repaired. Add a compatibility guard (or force-refreshlib.sh) before invoking new helper functions.Useful? React with 👍 / 👎.