2

I am using the new windows terminal.
I just installed powershell v7.0.2 and starship to make it better.

I want to edit the starship config, so I ran this command:

> starship.exe config
----------------------
Error: editor "vi" was not found. Did you set your $EDITOR or $VISUAL environment variables correctly?
Full error: Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." }

So I went ahead and edited my $PROFILE to set visual studio code as the default editor (code is in the path):

> code $PROFILE
---------------
$ENV:EDITOR = "code"
$ENV:VISUAL = "code"

Now I get the same error but with code instead of vi:

> starship.exe config
----------------------
Error: editor "code" was not found. Did you set your $EDITOR or $VISUAL environment variables correctly?
Full error: Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." }

The reason I ended up running starship config is because after creating the $HOME\.starship\starship.toml config file, starship ignores it, although I've set the path in my profile:

> code $PROFILE
---------------
$ENV:STARSHIP_CONFIG = "$HOME\.starship"

So I ran starhip config to see which is the path that it expects the config file to be in.


I also tried to set the full path to visual studio code in $EDITOR, but it didn't help.

4
  • Perhaps answered here: superuser.com/questions/1110795/… Commented Jul 11, 2020 at 11:05
  • @NicklausBrain I came across that when I was searching, and It did not help me, how would you apply that solution to my problem? Commented Jul 11, 2020 at 11:23
  • Why not just open Explorer, right-click (SomeFileNmae.ps1, SomeFileName.txt, SomeFileName.log, SomeFileName.ini, SomeFileName.config, etc...) the file of the type you want, and change the app association to VSCode, then double-clicking the file will start VSCode with that file or typign what you did to get the same result. Commented Jul 12, 2020 at 2:15
  • @postanote as I explained above, the reason why I am doing this in the first place is because the starship.toml config file (which I created in the documented path) seams to be ignored by starship and I wanted to open in through the starship config command so I can see the actual filename and path that it expects to find the config in. Commented Jul 12, 2020 at 12:07

3 Answers 3

4

I had the exact same issue, and managed to solve it by setting the $EDITOR variable to the absolute path of your editor, so for Visual Studio Code, add this to your $PROFILE:

$ENV:EDITOR = "C:\Program Files\Microsoft VS Code\Code.exe"
Sign up to request clarification or add additional context in comments.

Comments

0

I'm surprised code isn't in your path:

$env:path += ";C:\Users\$username\AppData\Local\Programs\Microsoft VS Code\bin"

1 Comment

code is already in my path. As you can see above, I invoke it from powershell and it works. The problem is when I run starship config having configured $end:editor = code, starship itself does not seam to be able to invoke code and it gives an error.
-1

Do you mean, default program to open ps1? If so it's a registry entry, HKLM and find extension...

1 Comment

No, I mean the default text editor to be used by different tools which require you at some point to edit a file. In my case, it is starship config which should open the starship.toml config file with that default text editor. Other examples are: git config -e and git commit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.