getcursor / cursor

The AI Code Editor
https://cursor.com
24.57k stars 1.53k forks source link

Launch Cursor from terminal in Ubuntu #1005

Open alessio-vivaldelli opened 1 year ago

alessio-vivaldelli commented 1 year ago

Hi, i can't launch cursor from terminal with command 'cursor', this is frustrating because I have to launch it from .appimage and then open my project folder from GUI. Can someone help me?

jakobFNF commented 1 year ago

Linux command seems to be broken. We're on it! Thank you for your report!

viniciusborgeis commented 1 year ago

Hi @ale99viv and @jakobFNF

I solved this issue with a simple bash script. Basically this script export a function called code that receive the path with a argument, when path exists, then this script run a Cursor Appimage by default application path.

  1. create a file called cursor.sh in your home, the same path as your .bashrc or .zshrc
    
    #!/bin/bash

cursor_app_path=/home//Applications cursor_app_name=cursor_ceb0b7d8edd1edeb6fdff61b2cdde19e.AppImage cursor_complete_app_path=$cursor_app_path/$cursor_app_name

code() { file_or_folder_path=$1 if [ -d "$file_or_folder_path" ] || [ -f "$file_or_folder_path" ]; then $cursor_complete_app_path $file_or_folder_path </dev/null &>/dev/null & else echo -e "\e[1;31m\u26A0 ERROR: Invalid path. Please provide a valid file or directory path.\e[0m" fi }

> a. change `<USER>` with your user
> b. make you sure if your cursor appimage is installed by default in the same directory, for example, in my case I use appimagelauncher for setup my Appimages and by default this store my Appimages inside `/home/<USER>/Applications`.
> c. Finally, check if your `cursor_app_name` is correct, just calling `ls /home/<USER>/Applications` and compare with the script above.

2. set a executation permission for this file with this command: `sudo chmod +x ~/cursor.sh`
3. finally, import this script in your default bash with the code bellow:
```bash
echo '. "$HOME/cursor.sh"' >> ~/.bashrc # if your default shell is bash
...
echo '. "$HOME/cursor.sh"' >> ~/.zshrc # if your default shell is zsh

if you make this like i'm, the final result is a new method inside your terminal called code that you use for open code for a folder or file!

I hope this can help! :smile:

kasi-x commented 11 months ago

Hello @alessio-vivaldelli and @jakobFNF, @viniciusborgeis

Inspired by your discussion, I've created an advanced script for Cursor AppImage, incorporating some of the command-line options familiar to users of Visual Studio Code.

Key features of this script include:

  1. Handling Non-Existent Paths: Unlike the original script, this version can open non-existent files or directories, which might be useful in certain scenarios.

  2. Diverse Option Support: Supports file comparison (-d), adding directories (-a), jumping to specific locations (-g), open a new window (-n) and reuse an existing one (-r). However, some options such as --help and --version do not seem to work with the Linux AppImage, as tested on cursor-0.15.5-build-231115a5mv63u9f.AppImage. I didn't tested all options yet. (cf. The Visual Studio Code command-line interface)

    code() {
    run_app() {
    /opt/cursor.appimage "$@" </dev/null &>/dev/null &
    }
    
    case "$1" in
    -d|--diff)
      run_app --diff "$2" "$3"
      ;;
    -a|--add)
      run_app --add "$2"
      ;;
    -g|--goto)
      run_app --goto "$2"
      ;;
    -n|--new-window)
      run_app --new-window
      ;;
    -r|--reuse-window)
      run_app --reuse-window
      ;;
    -w|--wait)
      run_app --wait
      ;;
    --locale)
      run_app --locale "$2"
      ;;
    --user-data-dir)
      run_app --user-data-dir "$2"
      ;;
    *)
      if [ -z "$1" ]; then
        run_app
      else
        run_app "$@"
      fi
      ;;
    esac
    }

    Best regards and happy coding! 😄

itsnull12 commented 6 months ago

image

another reference, create shortcut to desktop

  1. chmod u+x filename.AppImage
  2. sudo mv filename.AppImage /opt/
  3. sudo mv cursor.png /opt/
  4. sudo nano /usr/share/applications/Cursor.desktop
  5. input code below [Desktop Entry] Name=Cursor Exec=/opt/cursor-0.32.2-build-240417ab4wag7sx-x86_64.AppImage Icon=/opt/cursor.png comment=IDE Type=Application Terminal=false Encoding=UTF-8 Categories=Utility;

the icon of Cursor download here

LukaErnestini commented 3 months ago

@kasi-x, I modified your script to work with Fish shell. Might come in useful for someone.

function code
    function run_app
        /opt/cursor.appimage $argv </dev/null &>/dev/null &
    end

    switch $argv[1]
        case -d --diff
            run_app --diff $argv[2] $argv[3]
        case -a --add
            run_app --add $argv[2]
        case -g --goto
            run_app --goto $argv[2]
        case -n --new-window
            run_app --new-window
        case -r --reuse-window
            run_app --reuse-window
        case -w --wait
            run_app --wait
        case --locale
            run_app --locale $argv[2]
        case --user-data-dir
            run_app --user-data-dir $argv[2]
        case '*'
            if test (count $argv) -eq 0
                run_app
            else
                run_app $argv
            end
    end
end
johnnykoo84 commented 2 months ago

I'm very frustrated how to install cursor editor on ubuntu 24.04 I have done @itsnull12 suggested, but how do i use "cursor" command in the terminal?
Thanks for sharing your experience all.

Ziaeemehr commented 2 months ago

I'm very frustrated how to install cursor editor on ubuntu 24.04 I have done @itsnull12 suggested, but how do i use "cursor" command in the terminal? Thanks for sharing your experience all.

I followed this page and finally for terminal access used this:

sudo ln -s /opt/cursor.appimage /usr/local/bin/cursor

but I don't like that it does need to keep terminal open.

pehcastro commented 1 month ago

if you want to make the cursor command to work;

Rename cursor downloaded image to cursor.AppImage (I'm assuming it is on Downloads if you're using ubuntu) if you use zsh > nano ~/.zshrc if you use bash > nano ~/.bashrc

go to the end of the file and add (change youruser to your user)

alias cursor='/home/youruser/Downloads/cursor.AppImage'

then reload your edited terminal file source ~/.bashrc or source ~/.zshrc

if you want a different way to open, just change the alias name;

if you open / close the terminal or restart the computer it will work.

vkolagotla commented 1 month ago
cursor() {
    /opt/Cursor.AppImage "$@"
}

assuming you have the appimage in /opt/ that should work. add it to your .zsh_functions or .bash_functions file and source it or else just put it in .bashrc or .zshrc and it will behave just like code alias

kasi-x commented 1 month ago

Please refer to my previous comment on this thread. I believe it answers your question.

Hello @ale99viv and @jakobFNF, @viniciusborgeis

Inspired by your discussion, I've created an advanced script for Cursor AppImage, incorporating some of the command-line options familiar to users of Visual Studio Code.

Key features of this script include:

  1. Handling Non-Existent Paths: Unlike the original script, this version can open non-existent files or directories, which might be useful in certain scenarios.
  2. Diverse Option Support: Supports file comparison (-d), adding directories (-a), jumping to specific locations (-g), open a new window (-n) and reuse an existing one (-r). However, some options such as --help and --version do not seem to work with the Linux AppImage, as tested on cursor-0.15.5-build-231115a5mv63u9f.AppImage. I didn't tested all options yet. (cf. The Visual Studio Code command-line interface)
code() {
  run_app() {
    /opt/cursor.appimage "$@" </dev/null &>/dev/null &
  }

  case "$1" in
    -d|--diff)
      run_app --diff "$2" "$3"
      ;;
    -a|--add)
      run_app --add "$2"
      ;;
    -g|--goto)
      run_app --goto "$2"
      ;;
    -n|--new-window)
      run_app --new-window
      ;;
    -r|--reuse-window)
      run_app --reuse-window
      ;;
    -w|--wait)
      run_app --wait
      ;;
    --locale)
      run_app --locale "$2"
      ;;
    --user-data-dir)
      run_app --user-data-dir "$2"
      ;;
    *)
      if [ -z "$1" ]; then
        run_app
      else
        run_app "$@"
      fi
      ;;
  esac
}

Best regards and happy coding! 😄

honeymaro commented 1 month ago

Do they read the issues on GitHub? I think they don't.

abd3lraouf commented 4 weeks ago

Fish Config

function cursor
    # Start the Cursor AppImage in the background, suppressing output
    nohup ~/Applications/cursor.AppImage $argv --no-sandbox > /dev/null 2>&1 &
end

just put it in ~/.config/fish/config.fish

abd3lraouf commented 4 weeks ago

Bash or zsh

cursor() {
    # Start the Cursor AppImage in the background, suppressing output
    nohup ~/Applications/cursor.AppImage "$@" --no-sandbox > /dev/null 2>&1 &
}

just put it in ~/.config/fish/.bashrc or ~/.config/fish/.zshrc