Skip to content

feat: cursor shim for ~/.local/bin/cursor#20

Merged
watzon merged 5 commits intowatzon:mainfrom
ZanzyTHEbar:feat/cursor-shim
Mar 19, 2026
Merged

feat: cursor shim for ~/.local/bin/cursor#20
watzon merged 5 commits intowatzon:mainfrom
ZanzyTHEbar:feat/cursor-shim

Conversation

@ZanzyTHEbar
Copy link
Copy Markdown
Contributor

Adds an optional cursor shim that delegates to cursor-installer when no Cursor binary is in PATH.

  • shim.sh: Installed as ~/.local/bin/cursor; finds real cursor in PATH, else runs cursor agent or cursor-installer with args.
  • scripts/ensure-shim.sh: Idempotent install/update; skips if existing file is already our shim; never overwrites a non-shim binary.
  • install.sh: Syncs shim + helper to ~/.local/share/cursor-installer, runs ensure-shim after placing CLI.
  • cursor.sh: Refreshes shim assets from GitHub on --update; runs ensure-shim before install/update.

Guards: only replace ~/.local/bin/cursor when it is already a shim (shebang + marker) or missing.

@watzon
Copy link
Copy Markdown
Owner

watzon commented Feb 19, 2026

Can you rebase? This added 35 commits, most of which are already here.

@ZanzyTHEbar
Copy link
Copy Markdown
Contributor Author

Can you rebase? This added 35 commits, most of which are already here.

Absolutely, I was trying to figure out why it did that tbh. Will do.

- shim.sh: ~/.local/bin/cursor shim that finds real cursor or delegates to cursor-installer
- scripts/ensure-shim.sh: detect existing shim, skip if already current, else install/update
- install.sh: sync shim + ensure-shim, run helper after placing CLI
- cursor.sh: refresh shim assets from GitHub on update; ensure_shim before install
- REPO_*, BASE_RAW_URL, SHIM_TARGET, SHARED_SHIM, SHIM_HELPER, URLs
- sync_shim_assets(): copy or fetch shim.sh + ensure-shim.sh into LIB_DIR
- refresh_shim_assets(): re-download from GitHub (for --update)
- run_ensure_shim(): run ensure-shim.sh with SOURCE_SHIM/TARGET_SHIM
- Replace inline shim sync block with LOCAL_SHIM_PATH/LOCAL_SHIM_HELPER_PATH env + sync_shim_assets && run_ensure_shim
- Keep REPO_*, LIB_URL, CURSOR_SCRIPT_URL for bootstrap before first lib source
- Drop local REPO_*, SHARED_SHIM, SHIM_*, ensure_shim, refresh_shim_assets
- Call refresh_shim_assets in update_cursor, run_ensure_shim in install paths
Explain what the shim is, why it exists, how it works,
when it runs, file locations, and manual removal steps.
Repository owner deleted a comment from chatgpt-codex-connector bot Mar 5, 2026
@watzon
Copy link
Copy Markdown
Owner

watzon commented Mar 5, 2026

@codex please review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f4b5c3f738

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

for dir in $PATH; do
[ -n "$dir" ] || continue
cursor_path="$dir/cursor"
if [ "$cursor_path" != "$HOME/.local/bin/cursor" ] && [ -x "$cursor_path" ]; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Exclude the active shim path when resolving cursor

The PATH probe only excludes the literal string $HOME/.local/bin/cursor, so if the shim is invoked through any other path to the same file (for example a symlinked PATH entry or a non-default TARGET_SHIM location), find_cursor can rediscover the shim itself and exec back into it indefinitely. In that setup, cursor hangs in a self-recursive loop instead of reaching cursor-installer or a real Cursor binary.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would the shim be invoked from anywhere else? This seems like a non-existent edgecase.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just Codex doing Codex things haha. It does like to be thorough.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! So after looking at this, I took some time to stress test my local setup and I WAS able to hit this edge-case.

I will provide a fix for it.

How I did it:

  • machine where cursor installer was used as primary mechanism
  • install cursor cli
  • run cursor installer AGAIN to overwrite cursor cli bash script entrypoint with shim

This caused the shim to re-discover itself as the shim only used raw string comparison.

I was then faced with a terminal "hang" as the shim re-executed itself.

Comment on lines +42 to +43
if grep -q "cursor-installer" "$file" 2>/dev/null; then
return 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict shim detection before replacing existing cursor

The non-shim protection is too broad: any executable shell script containing the text cursor-installer is treated as an existing shim and eligible for overwrite. That means user-managed wrappers at ~/.local/bin/cursor can be silently replaced even when they are not this project's shim, which contradicts the safety guarantee in this change.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

@ZanzyTHEbar ZanzyTHEbar Mar 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, also, seems like an edge-case that does not practically exist. When would a user ever have another cursor-installer on PATH?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair honestly

@watzon watzon merged commit 2afb027 into watzon:main Mar 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants