Comments (24)
from oh-my-posh.
on pwsh on windows the method to move the cursor to the end of the line is borked because it reflows on resize which gets me this:
from oh-my-posh.
#87 helped with this issue. At least now I can have the same json theme for powershell and nushell. For anyone facing the same problem, this is the theme that works for me. Thanks @JanDeDobbeleer for working on this.
nushell (i have no clue why the shell says cmd)
{
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "time",
"style": "plain",
"foreground": "#E5C07B",
"properties": {
"time_format": "2006-01-02 3:04:05.000 AM",
"prefix": "",
"postfix": ""
}
},
{
"type": "root",
"style": "powerline",
"powerline_symbol": "î°",
"foreground": "#100e23",
"background": "#ffe9aa",
"properties": {
"root_icon": "īĒļ"
}
}
]
},
{
"type": "newline"
},
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "path",
"style": "powerline",
"powerline_symbol": "î°",
"foreground": "#ffffff",
"background": "#3364a1",
"properties": {
"home_icon": "~",
"folder_icon": "ī",
"windows_registry_icon": "īą",
"folder_separator_icon": " îą ",
"style": "short"
}
},
{
"type": "shell",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#0077c2",
"properties": {
"prefix": " \uFCB5 "
}
},
{
"type": "git",
"style": "powerline",
"powerline_symbol": "î°",
"foreground": "#000000",
"background": "#95ffa4",
"properties": {
"branch_icon": "î ",
"branch_identical_icon": "âŖ",
"branch_ahead_icon": "â",
"branch_behind_icon": "â",
"branch_gone_icon": "âĸ",
"branch_untracked_icon": "\u2262",
"local_working_icon": "ī",
"local_staged_icon": "ī",
"rebase_icon": "īŋ ",
"cherry_pick_icon": "î ",
"detached_icon": "ī š ",
"tag_icon": "ī§¸",
"display_stash_count": true,
"stash_count_icon": "\uF692 ",
"merge_icon": "\uE726 ",
"display_upstream_icon": true,
"github_icon": "\uE709",
"bitbucket_icon": "\uE703",
"gitlab_icon": "\uE296",
"git_icon": "\uE702"
}
},
{
"type": "python",
"style": "powerline",
"powerline_symbol": "î°",
"foreground": "#100e23",
"background": "#906cff",
"properties": {
"prefix": " îĩ "
}
},
{
"type": "exit",
"style": "powerline",
"powerline_symbol": "î°",
"foreground": "#ffffff",
"background": "#ff8080",
"properties": {
"prefix": "î"
}
}
]
}
],
"final_space": true
}
from oh-my-posh.
The only way this can happen is that nushell counts the escape characters as well to define where the cursor is. To fix this, we need to escape those in a way that nushell expects. I'll read their docs to check if that's listed somewhere (hopefully). If not we'll need to raise a bug/question on their end.
from oh-my-posh.
nushell doesn't escape characters so it may not have any knowledge of what is an escape and what is not. Nushell uses rustyline
as a line editor so rustyline could be involved too. Thanks for the quick response.
Nushell https://www.nushell.sh/
Nushell Github https://github.com/nushell/nushell
Rustyline https://github.com/kkawakam/rustyline
from oh-my-posh.
@fdncred what you could maybe try as a first approach is to remove the newline
block and add a new segment to the first block with a \n
{
"type": "text",
"style": "plain",
"foreground": "#ffffff",
"properties": {
"text": "\n",
"prefix": "",
"postfix": ""
}
}
On some prompts this works (zsh, bash), but it doesn't work on PowerShell on MacOS for example which is why the default is ANSI escape sequences to change the line rather than \n
. If this reduces the line length, something is off with counting the prompt length at nushell for which I'll have to acquire some rust knowledge (long time goal). Curious to see what the effect is of this change, it might bring us closer to finding a cause.
EDIT: I just setup and entire dev env and installed nushell so we'll see for how long I can postpone that goal đ
from oh-my-posh.
I'll add that to the shell configs in that case. That way the newline block will work as expected. Nonetheless, nushell still needs to interpret those ANSI characters correctly (even though that's also an issue at zsh,...).
from oh-my-posh.
If you can point me to the line(s) of code in your code base that is spitting out ansi characters that nushell is ignoring, I may be able to work on this issue for nushell. I just need to be able to pinpoint what is coming in from the prompt and how nushell/rustyline is failing. Thanks for all your help.
from oh-my-posh.
The default prints "\x1b[1000C "
which moves the cursor all the way to the right with 1 space meaning it starts on a new line. That's what's causing the issue here.
from oh-my-posh.
maybe \x1b[E
is better suited for newline then?
from oh-my-posh.
maybe
\x1b[E
is better suited for newline then?
That actually works! I always thought (due to some info I found) it needed a number to tell the amount of lines down e.g. \x1b[1E
. I'm submitting a PR with that change, looking forward to seeing the effect.
from oh-my-posh.
fwiw - the prompt position is still far to the right in nushell, as first reported, even with 3.20.1, but the work-around still works.
from oh-my-posh.
I'm reverting this fix as it breaks Powershell as well. Line breaks are challenging đ
from oh-my-posh.
how does it breaks?
seems to work fine here
from oh-my-posh.
Depends on the shell. Don't get me started.
from oh-my-posh.
@fdncred should be fixed with v3.20.3
from oh-my-posh.
Still shows up at the right with nushell. when i type, the text appears in the right spot but the blinking prompt is still to the right. Also, every character I type creates a new prompt before the newline.
Kind hard to describe so here's a gif.
from oh-my-posh.
Ow, can you add a shell segment so I can see the name? On OSX it's nu
, but it might also be nushell
here (in which case the fix won't work)
from oh-my-posh.
I added this:
{
"type": "shell",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#0077c2",
"properties": {
"prefix": " \uFCB5 "
}
},
and got this with nushell, which i don't really understand.
from oh-my-posh.
@LuanVSO the whole newline thing on Powershell is strange and this is the only way I could make it work consistently with this disadvantage. You can use \n
in the shell directly and it will work, but it always gives really weird behavior when the exact same string is used in the prompt function and I have no idea why.
These are the sequences I tried which give a bad result when used in the prompt function:
\n
`n
\x1b[E
from oh-my-posh.
and got this with nushell, which i don't really understand.
@fdncred that's rather strange as on OSX it displays nu
in nushell. I already strip the .exe
so in theory setting this for cmd
as well should resolve the issue. CMD isn't supported anyways as it can set a prompt but not update it on the fly using an executable. However, might be interesting to see why nushell's executable reports itself as cmd
.
from oh-my-posh.
I honestly don't think it should've been this hard and Powershell should just accept \n
in prompt functions too. I have one final thing I want to try and then I'm actually going to ask a Powershell professional over at the repo. Because I'm either not aware of something, or they have a bug.
from oh-my-posh.
Please let me know if you'd like me to test. I've had to revert to my old prompt in nushell because I discovered another problem. When I paste anything, I get many lines like in the gif above when typing. I could open a separate issue if you like.
from oh-my-posh.
Not sure if that's related to oh-my-posh. On other shells that's because the length of the prompt isn't calculated properly. On ZSH and Bash I have to escape certain sequences so it can count correctly and cursor placement is accurate. I couldn't find this information for nushell and I'm quite sure there's still something going on on that end.
Feel free to create a separate issue for that one. We can still link back to nushell if needed.
from oh-my-posh.
Related Issues (20)
- A changelog file with breaking changes would be nice HOT 1
- Prompt is often rendered in black and white HOT 3
- Oh My Posh not starting for cmd HOT 1
- 20+ second boot time HOT 2
- Allow transient prompt alignment (segments or left/right_template or whatever...) HOT 1
- Invoke-Expression is used HOT 1
- Android AArch64 build HOT 1
- iTerm2 shell integration HOT 1
- Ability to not process the command in `command`
- I always lost my customize when I open the new tab HOT 1
- The git segment doesn't render correctly when switching to a shorter branch name HOT 6
- plugin system like "oh-my-zsh" HOT 1
- python segment not working
- Firebase segment does not work on child folders HOT 2
- Line wrapping the time to 2nd line HOT 4
- Loss of appearance when resizing window HOT 1
- Difference between JSON themes schema and documentation HOT 1
- New segment request: Talosctl current context HOT 6
- Improve performance for git prompts (on PowerShell) HOT 6
- shell config error
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 oh-my-posh.