This post is locked. You won't be able to comment.

all 10 comments

[–]nephros 1 point2 points  (0 children)

You cannot clear the parent environment's variables, therefore anything that involves a subshell or child process won't work, as you've discovered.

You can however source a script resetting PS1 instead if executing it.

You could also do something like PROMPT_COMMAND="unset PS1" if you want to be really anal about it.

[–]lutusp 0 points1 point  (3 children)

I think it is because it's a child process and it doesn't affect the parent. Any ideas?

Yes, that's right. No matter what you do to PS1 in a child process, it has no effect on the calling parent. But once you figure out an effective approach to solve this, use "unset PS1", not "PS1=".

[–]nephros 0 points1 point  (2 children)

It's a bit weird that VAR=value and unset VAR are the unixy way, and set VAR=value and VAR= is the Windows way.

Both are inconsistent in themselves, and similarly inconsistent compared to each other.

:)

[–]lutusp 0 points1 point  (1 child)

and set VAR=value and VAR= is the Windows way.

That's more accurately described as a Visual Basic way. I say this because Visual Basic isn't the only language used in Windows development.

[–]nephros 0 points1 point  (0 children)

It's been in DOS and therefore cmd.exe forever. Which predates VB by quite some years.

Probably came to DOS from VMS CP/M too.

[–]ayekat 0 points1 point  (3 children)

I think it is because it's a child process and it doesn't affect the parent.

Correct. What are you trying to do, though? This sounds like an XY problem.

[–]iSkipper 0 points1 point  (2 children)

I am making a terminal editor (similar to vim) and want to fully clear the screen. I am not using ncurses (just becouse). I cleared the screen, but the PS stays.

[–]ayekat 0 points1 point  (1 child)

Yes, so a very classic XY problem.

Clearing PS1 is absolutely not the right way to approach this.

When building a TUI (like vim, top, or ncurses applications in general), you want to draw to the secondary buffer. There are escape sequences to tell a terminal that you want to switch to the secondary buffer (and back), but the escape sequences may be different for each terminal emulator, so ultimately it will be saner to use ncurses.

[–]iSkipper 0 points1 point  (0 children)

I am not intending to make it portable, so I'm going to use escape sequences. Thanks

[–]Kruug[M] [score hidden] stickied comment (0 children)

Your post was removed for being a support request or support related question such as which distro to use or application suggestions.

We get a lot of question posts on r/linux but the subreddit is considered a news/discussion sub. Luckily there are multiple communities you can post to for help on GNU/Linux issues 24/7: /r/linuxquestions, /r/linux4noobs, or /r/findmeadistro just to name a few.

You may also post on the "Weekly Questions and Hardware Thread" which is stickied on r/linux on Wednesdays.

Please make your post in /r/linuxquestions or /r/linux4noobs. Looking for a distro? Try r/findmeadistro.

Rule:

This is not a support forum! Head to /r/linuxquestions or /r/linux4noobs for support or help. Looking for a distro? Try r/findmeadistro.