Topics

sounds on wsl commendline

UMIT ERDEM Yigitoglu
 

Hello, 
I have just started to learn about unix commendline with windows subsystem for linux. I use commendline with a braille display and want to sielence nvda. However, I want to be able to know if my commend executed correctly without using review currcer all the time. I was wanderring if there is a tool that will have different tones for different kinds of output and different kinds of error messages? if such programm is possible and it is yet to be done I would love to work on it later when ı advance in programming, I believe it will be very important tool for blind programmers. any ideas?  

Tage Johansson
 

Hello,

I'm glad that you are trying out a unix shell. I've used a linux command line for three years now and I can say that it is very fun. I use less and less graphical programs and use the command line for more and more. Today I only use a mail program (Thunderbird) and a web browser (Firefox) outside the terminal. Command line applications are much more understandable, accessible and customizable than graphical programs. It takes some more time to learn it, but you learn what you are really doing rather than how to use a complicated gui. WSL is also really awsum.


Anyway, on to your question. You want to know if the last commandsucceeded or not, quicly. In unix, the exit status of a command is denoted by a return code. If the return code is 0 the command was successful otherwise it failed. The simplest solution is to customize your prompt string so that it contains the return code of the last command.


I don't know what shell you are using. Most probably you are using bash but you can check that by issuing the command `echo $shell`. If the output is something similar to /bin/bash or /usr/bin/bash, you are good to go.


Now you should edit your .bashrc file located right under your home directory. Paste the following text at the bottom of the file:


__old_ps1=$PS1
__prompt_command() {
    PS1="($?)$__old_ps1"
}
PROMPT_COMMAND=__prompt_command


Save the file and restart your shell. The prompt should now contain the return code in parenthesis at the start of the line.


Feel free to experiment with that code and if you have any questions feel free to ask.


Best regards,

Tage


On 6/22/2020 8:25 PM, UMIT ERDEM Yigitoglu wrote:
Hello, 
I have just started to learn about unix commendline with windows subsystem for linux. I use commendline with a braille display and want to sielence nvda. However, I want to be able to know if my commend executed correctly without using review currcer all the time. I was wanderring if there is a tool that will have different tones for different kinds of output and different kinds of error messages? if such programm is possible and it is yet to be done I would love to work on it later when ı advance in programming, I believe it will be very important tool for blind programmers. any ideas?  

Luke Davis
 

I second all of what Tage said, except the things to paste in .bashrc.

All you really need is to paste the following:

PROMPT_COMMAND='echo -n "($?) "'

To get the same effect, without the obscurity of the function call or the reassignment of $PS1.

Also, technically it is more correct to paste this in .profile, as .profile is only loaded for interactive shells.

Luke

On Mon, 22 Jun 2020, Tage Johansson wrote:

Hello,
I'm glad that you are trying out a unix shell. I've used a linux command line for three years now and I can say that it is very fun. I use less and less
graphical programs and use the command line for more and more. Today I only use a mail program (Thunderbird) and a web browser (Firefox) outside the
terminal. Command line applications are much more understandable, accessible and customizable than graphical programs. It takes some more time to learn it,
but you learn what you are really doing rather than how to use a complicated gui. WSL is also really awsum.
Anyway, on to your question. You want to know if the last commandsucceeded or not, quicly. In unix, the exit status of a command is denoted by a return
code. If the return code is 0 the command was successful otherwise it failed. The simplest solution is to customize your prompt string so that it contains
the return code of the last command.
I don't know what shell you are using. Most probably you are using bash but you can check that by issuing the command `echo $shell`. If the output is
something similar to /bin/bash or /usr/bin/bash, you are good to go.
Now you should edit your .bashrc file located right under your home directory. Paste the following text at the bottom of the file:
__old_ps1=$PS1
__prompt_command() {
    PS1="($?)$__old_ps1"
}
PROMPT_COMMAND=__prompt_command
Save the file and restart your shell. The prompt should now contain the return code in parenthesis at the start of the line.
Feel free to experiment with that code and if you have any questions feel free to ask.
Best regards,
Tage
On 6/22/2020 8:25 PM, UMIT ERDEM Yigitoglu wrote:
Hello, 
I have just started to learn about unix commendline with windows subsystem for linux. I use commendline with a braille display and want to
sielence nvda. However, I want to be able to know if my commend executed correctly without using review currcer all the time. I was wanderring
if there is a tool that will have different tones for different kinds of output and different kinds of error messages? if such programm is
possible and it is yet to be done I would love to work on it later when ı advance in programming, I believe it will be very important tool for
blind programmers. any ideas?  

Sean
 

There are errors in the command line such as syntaks errors and like access errors.
NVDA has no special option for these. This is completely part of Windows.

It is necessary to parse the outputs and it is challenging for this console.
In this case, there is no other option than to examine the errors that occur with virtual cursors.

On 22/06/2020 21:25, UMIT ERDEM Yigitoglu wrote:
Hello, 
I have just started to learn about unix commendline with windows subsystem for linux. I use commendline with a braille display and want to sielence nvda. However, I want to be able to know if my commend executed correctly without using review currcer all the time. I was wanderring if there is a tool that will have different tones for different kinds of output and different kinds of error messages? if such programm is possible and it is yet to be done I would love to work on it later when ı advance in programming, I believe it will be very important tool for blind programmers. any ideas?  
--

Sean

👨‍🦯 I’m student and programmer. I write often Python, sometimes Go and rarely C++.

UMIT ERDEM Yigitoglu
 

thank you for all of you it works. do you have any suggestiond/advice for a biggener comendline user? is there a good resource to learn it more or anything I should be aware of?
Thank you again. 
best regards

Luke Davis
 

The best advice I can give you, is that google is your friend.

If you want to do something, think of how someone else might have asked how to do a similar thing, and google it.

You will find a lot from stackexchange, stackoverflow, and similar forum Q&A sites.

Everyone I know "learned by doing", so I don't really know many "beginner" resources.

One site that you really must know about if you want to work in the bash shell, whether you're a beginner or a long time pro, is this one below. Playing with these examples will teach you a great deal.

http://mywiki.wooledge.org/BashFAQ
And related:
http://mywiki.wooledge.org/BashGuide

This will be my last comment on this thread, as this seems rather off topic.

Luke

On Fri, 26 Jun 2020, UMIT ERDEM Yigitoglu wrote:

thank you for all of you it works. do you have any suggestiond/advice for a biggener comendline user? is there a good resource to learn it more or anything
I should be aware of?
Thank you again.