Comments (8)
Latest release will fix the issue
from shell.
Done a quick test and replacing the existing prompt handler with this seems to work fine.
Shell.Prompt = () =>
var prompt = `starship prompt --status=$Shell.LastExitCode$ --jobs=$Shell.BackgroundProcesses.Count()$`;
return ColorString.FromRawANSI(prompt);
};
from shell.
I appreciate you taking the time to look into this. I tried swapping out the default for your example, but for some reason, I keep getting the following:
zsh > dotnet-shell
An error occured loading core.nsh
StartIndex cannot be less than zero. (Parameter 'startIndex')
# >
I tried to add a few slight checks, but I still end up getting the same result:
core.nsh snippet
// bool? powerline = null;
#region c#
Shell.Prompt = () =>
{
var exitCode = `Shell.LastExitCode`;
if (exitCode == null || exitCode < 0)
{
exitCode = 0;
}
var bgJobs = `Shell.BackgroundProcesses.Count()`;
if (bgJobs == null || bgJobs < 0)
{
bgJobs = 0;
}
var prompt = `starship prompt --status=$exitCode$ --jobs=$bgJobs$`;
return ColorString.FromRawANSI(prompt);
};
// Shell.Prompt = () =>
#endregion
// {
// if (powerline == null && !RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
// {
// var powerlineHelpOut=`which powerline`;
// powerline = !string.IsNullOrWhiteSpace(powerlineHelpOut);
// }
// if (powerline == true)
// {
// string powerLinePrompt=`powerline-render shell left --last-exit-code=$Shell.LastExitCode$`;
// return new ColorString("!", Color.Green, Color.LightBlue) + ColorString.FromRawANSI( powerLinePrompt );
// }
// else
// {
// return new ColorString("!" + Environment.UserName + "@" + Environment.MachineName, Color.Green) + new ColorString(" " + Shell.WorkingDirectory + ">", Color.Blue) + " ";
// }
// };
I just edited core.nsh directly. It seemed like that would be the proper way to go about it, am I mistaken on that?
Thanks,
-MH
from shell.
There are problems:
var exitCode = `Shell.LastExitCode`;
should actually be var exitCode = Shell.LastExitCode;
Putting text in backticks means execute this shell command, take the stdout and put in a variable. But Shell.LastExitCode is already a piece of C# -- see LastExitCode. That means we can just assign it.
Same for the bgJobs variable assigned as well - drop those backticks.
bgJobs and exitCode will also never be null or < 0 so you can drop that check as well.
When executing the starship prompt helper you are correctly using
Make those changes and your code should work.
My guess is that you getting that error as some bash error message is being evaluated when starship is run. Personally I would stick with my code, it works and its a bit more concise.
from shell.
Ah yes, that definitely makes sense. Unfortunately, though, the original code you had shared is what was giving the An error occured loading core.nsh. StartIndex cannot be less than zero. (Parameter 'startIndex')
message. That was the reason I tried to check to make sure one of the values weren't coming back as less than 0. The error message didn't change, though between the original code you shared and the modification I had tried.
from shell.
This is my core.nsh that i've just tested on Ubuntu and works. Could I ask that you give this a go. If there is still a bug there is a much more exciting issue.
from shell.
I have reproduced the issue. The dotnet-shell preprocess isn't taking out all the comments correctly. Removing the large comment blog (as in my paste) will fix your issue.
from shell.
I was just in process of typing that out, you beat me to it. 👍
from shell.
Related Issues (4)
- Linux : Pop!_OS 21.04 - Upon install and attempting to run for the first time: "Unhandled exception. System.ComponentModel.Win32Exception (2): No such file or directory" HOT 2
- Best practice for environment variables / exports? HOT 14
- Using declaration cannot be used as top-level statement or in shell HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shell.