-
-
Notifications
You must be signed in to change notification settings - Fork 25
editors: add Cursor support and improve VSCode-like detection #291
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: master
Are you sure you want to change the base?
Conversation
- Added new `is-cursor` command to detect Cursor editor - Created `is-vscode-like` command to generalize VSCode-like editor detection - Updated various commands to recognize Cursor alongside VSCode - Modified editor selection logic to include Cursor as a preferred editor
im not sure if this has to be in beta first. |
Cool, thank you. I'll review this properly after #281 is merged. |
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.
Todos before merging:
- Remove
is-vscode-like
, change tois-vscode || is-cursor
. - Do the minor changes.
- Document why the numerous checks in
is-cursor
are necessary, if they indeed are. - Open an issue on Cursor's github requesting they change their
TERM_PROGRAM
tocursor
instead ofvscode
, link that created issue in a comment inis-vscode
# Also check if we're in VSCode with Cursor-specific environment variables | ||
if [[ ${TERM_PROGRAM-} == 'vscode' ]]; then | ||
# Check for Cursor in environment variables | ||
if env | grep -q "NAME=Cursor"; then |
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.
What is the point of these checks? Wouldn't it have been caught by the earlier ${NAME-} == "Cursor"
check?
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.
But double conditioning is to make sure. Im not sure if name could be alter by others.
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.
Okay, let's remove this block then, and just do the earlier check. env
will just reflect the current exported variables, which should be what is also shared by our current bash instance. For instance, if our bash instance changed NAME and it is exported, such a change will also happen for the called env. If NAME was no longer exported, same would occur for env. However, NAME could be a local variable, in addition to a parent's export variable, in this case, yes they could diverge, but is-cursor
is running as a subshell command, so this should never be the case.
@@ -46,7 +46,7 @@ function get_terminal_title_support() ( | |||
# Action | |||
|
|||
function __check { | |||
is-ci || is-vscode | |||
is-ci || is-vscode-like |
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.
I think we nuke is-vscode-like
and just change this to is-vscode || is-cursor
, as it could be possible that a vscode-like editor comes out hat doesn't have title support, and this seems to be the only use case of such a vscode-like detection.
@@ -114,7 +114,11 @@ function edit_() ( | |||
local editors=() | |||
if [[ -z $terminal && -z $gui ]]; then | |||
# no terminal or gui preference, determine sensible defaults | |||
if is-vscode; then | |||
if is-cursor; then | |||
editors+=(cursor) |
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.
missing # if running within Cursor, add Cursor as preference
editors+=(cursor) | ||
gui='yes' | ||
terminal='yes' | ||
elif is-vscode; then | ||
# if running within vscode, add vscode as first preference |
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.
change comment to remove first
@@ -233,7 +233,7 @@ function config_edit() ( | |||
esac | |||
done | |||
|
|||
if is-vscode; then | |||
if is-vscode-like ; then |
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.
change to is-vscode || is-cursor
@@ -0,0 +1,53 @@ | |||
#!/usr/bin/env bash |
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.
let's nuke this command
is-cursor
command to detect Cursor editoris-vscode-like
command to generalize VSCode-like editor detection