ZSH prompt starts with a percent sign on Hyper terminal - terminal

I'm using Hyper as my terminal on Linux Mint 19.2 and I've just installed ZSH with Oh My ZSH. when I open Hyper, a percentage sign appears before the prompt.

That reverse-video % indicates an output that did not end with a newline:
/home/ekalin $ echo 'Hello, World'
Hello, World
/home/ekalin $ echo -n 'Hello, World'
Hello, World%
/home/ekalin $
So there must be something that's outputting a line without a newline. If it happens in every prompt, it should be in your prompt definition; if it happens only on session startup, it should be something from ~/.zshrc (or in a file sourced from there).

Related

-echoctl not being ackonowledged in forked program

Please,
I have a terminal application that requires no echoing of control characters back to the terminal.
I can happily issue 'stty -echoctl' at a terminal, run my application and obtain the result I am after. Further, I can include 'stty -echoctl' in .bashrc and everything is fine. (I have also added it to .profile but that seems to bring in .bashrc anyway)
I can then open another terminal (type 'konsole/gnome-terminal/xterm' in the original console and again I get the result I expect.
The problem I have (and this is in preparation of forking the program form another application) is that if i try
$ xterm -e ./V2.13
or even
$ xterm -e bash -c ./V2.13
the control characters are in fact echoed back to my app.??
EDIT:Additionally is there any need (benefit) in executing bash to execute my application ?

Failure in executing shell script producing output on Ubuntu on Windows

I have had a hard time in executing my shell scripts on bash on Ubuntu on windows 10. The script is very simple:
# file name: submission.sh
echo "Hello world" > output.txt
When I executed it with a command sh submission.sh, it gave me an error:
$ sh submission.sh
: Directory nonexistentssion.sh: cannot create output.txt
However, when I changed the script into
# file name: submission.sh
echo "Hello world"
and executed it with the same command sh submission.sh, it gave me the right output
$ sh submission.sh
Hello world
It seems like bash on Ubuntu on Windows cannot get it right when the script involves directing the output to a file. Is there any solution or workaround to this?
EDIT:
Details on my system:
Program: "Bash on Ubuntu on Windows"
OS: Windows 10 Version 1709
EDIT:
Typing the command directly on the terminal works, i.e.
$ echo "Hello world" > output.txt
$ cat output.txt
Hello world
I still wants to put the commands on a file and execute the file instead of writing the command directly to the terminal, and this is still unsolved.
You appear to have mangled text in nonexistentssion.sh: and No such file or directorytput.txt which suggests you might have Windows line-endings in the file \r. If you created the script using a Windows program (like Notepad) then that could be the case.
If you have dos2unix then run it on your script and try again.
By the way for future reference, running sh is not the same as running bash. In this case it would have made no difference, but sh is a POSIX shell, full bash has many extensions which will not work under sh.
Some platforms run sh as a symbolic link to bash which fools people into thinking they are the same, but bash detects this and switches to POSIX mode when running as sh. It is a common issue here.
In your submission.sh file, is better to add a shebang as first line.
Another thing you want to consider if you want to use sh instead of bash is to replace echo with printf, for portability
Your code should look something like:
#!/bin/bash
printf "Hello world!\n" > output.txt
You can call it simply by ./submission.sh and because of the shebang, your terminal will know how to open it [:
P.S. Keep in mind that because of the standard umask in Ubuntu, you might want to execute chmod u+x submission.sh before running it.
Also, notice that your error is probably caused by a permissions issue.
Try adding write permissions in the folder you are launching the script.

command in shell buffer in emacs in gnu screen

The excellent answer to the question How do I define an Emacs List function to spawn a shell buffer with a particular command executed in the shell weirdly does not work in a Gnu "screen" session. In the context of a screen command, instead of the command I tell it to execute,
echo 'test1'\n
, Emacs is called recursively! The would-be shell buffer contains the familiar "emacs: Terminal type "dumb" is not powerful enough to run Emacs" message.
How can I make this work? Here's what I did:
On the command line:
~ srn#basil{1}% screen -s run-emacs2
Here is the shell script run-emacs2:
#!/bin/bash
EMACS=/usr/bin/emacs23-x
export NO_AT_BRIDGE=1 ## suppress annoying gtk>2 warning
exec "$EMACS" -nw --load init.el.test -f spawn-shell
NOTE: If on the command line I say:
~ srn#basil{1}% run-emacs2
...everything works fine. The problem appears to be some interaction with Gnu screen.
Here is init.el.test (almost verbatim from the answer linked above):
(defun spawn-shell ()
"Invoke shell test"
(pop-to-buffer (get-buffer-create (generate-new-buffer-name "gzo")))
(shell (current-buffer))
(process-send-string nil "echo 'test1'\n"))
It is expected behavior. According to the screen manual, the -s option is where to look:
-s program
Set the default shell to be program. By default, screen uses the value of the environment variable $SHELL, or /bin/sh if it is not defined. This option is equivalent to the shell command (see Shell).
The screen program sets the $SHELL variable to program (as part of opening a new window), and it is inherited in the subprocess, which in turn runs whatever $SHELL happens to be. Since you do not want that, the fix would be to modify the emacs script to reset $SHELL back to /bin/sh before running a "shell".

How can I change default directory in screen when I have defshell set to bash?

I know that you can usually use chdir in your screenrc file to change directory before running a screen command. However, this doesn't work for me if I have defshell -bash set. Here's a sample file that doesn't work:
defshell -bash
defscrollback 100000
hardstatus on
hardstatus alwayslastline
hardstatus string "%w%=%m/%d %c"
chdir /Users/myuser/work
screen -t "work"
$ screen -c testrc
$ pwd
/Users/myuser
Commenting out the first line does the trick, but I'd like to run bash shells in my screens. This is on OSX if that's relevant. My screen command is not aliased.
The problem is that your defshell specifies a login shell, which makes it go to the home directory. According to screen's manual
shell command
Set the command to be used to create a new shell. This overrides the value of the environment variable $SHELL. This is useful if you'd like to run a tty-enhancer which is expecting to execute the program specified in $SHELL. If the command begins with a '-' character, the shell will be started as a login-shell.
If you change that to
defshell bash
it should not do that.

Compact cygwin terminal

I'm looking for a way to make the cygwin terminal more compact, or an alternate terminal that is more compact. Currently, every command I enter has a header line above it with username and pwd, and there is a blank line trailing every command. For instance:
username ~
$ cd tmp
username ~/tmp
$
3 lines for every 1 line of command. I frequently work on a small screen, which makes all this wasted space quite irritating. Is there a setting somewhere I can alter to prevent all this wasted space? Or, perhaps another terminal?
Thanks in advance.
That's the default shell prompt set by Cygwin.
To use a smaller prompt in your current terminal:
PS1='$ '
To make the change permanent, put that command in your ~/.bashrc file.
You can set the prompt to just about anything you like, as explained by the bash manual (there are several variables that control different prompts; $PS1 is the main one).
It's important to remember than in Cygwin (as in Linux and Unix), the terminal program is a separate program from the shell that runs in it. The prompt is controlled by the shell; bash is the default. The graphical display is controlled by the terminal emulator, which could be rxvt, mintty, xterm, or even the Windows terminal that normally runs a DOS-like shell.
What you're seeing there is the prompt, as stored in the environment variable PS1
echo $PS1
will show you how it's created. By the way, that prompt is managed by the bash shell, not by the terminal.
export PS1=$
will give you just a $ prompt
export PS1="$ "
will leave some room behind the prompt. There are many more possibilities, here is a nice tutorial.
bash reads its settings from a file called ~/.bashrc aka a file called .bashrc in your home directory. Note that due to the initial dot in the name ls won't show the file by default, ls -a or ls -la will.
I would Recommend we go with modern terminals using Cygwin-X as shown in the below interactive menu
I love Xfce Terminal which allows creating tabs and new windows with font options and color options

Resources