I find it very difficult to read the command line, and am I wondering if there is a way to force 2 carriage returns after I press the Enter key, to space it out more.
I am using Windows 7 command line, but also ssh into a virtual box running linux.
I find the git outputs esp hard to read.
Thanks
You can set up on Linux variable PS1 for example as
PS1='\n `echo -n \[\e[1\;33m\]` \t`echo \[\e[0m\]` \h \$'
or just add newline in the beginning of the PS1 variable in your .bashrc:
PS1="\n$PS1"
Not sure if this helps with your virtual linux and git output, but you can define the PROMPT to issue a newline before the standard c:\path> prompt.
prompt $_$P$G
Related
Sometimes when you ctrl-v with bash it will run the command even though you didn't intend to run it yet - is there a way to paste a command into the bash shell / terminal making sure you don't actually run any of the command(s)?
if you could set what was on the terminal prompt programmatically, you could do this with bash on MacOS:
export BASH_PROMPT="$(pbpaste)"
which ties into my other question that I just asked:
How to change the value that's in the prompt
There is a Readline variable:
enable-bracketed-paste
When set to On, Readline will configure the terminal in a way that will enable it to insert each paste into the editing buffer as a single string of characters, instead of treating each character as if it had been read from the keyboard. This can prevent pasted characters from being interpreted as editing commands. The default is off.
To turn this on, put something like
set enable-bracketed-paste on
into your ~/.inputrc.
This was introduced in Bash 4.4 / Readline 7.0.
Use ^X^E aka Ctrl+X Ctrl+E in bash to open your $EDITOR for command entry.
Paste and/or edit as much as you want, across as many lines as you want. When you're done, save and exit, and bash will run it.
(In vi mode, the shortcut is v)
I am working on a windows 10 machine using Emacs and plink to connect to a Linux development server.
I am able to start a shell in Emacs using M-x shell
and ssh to the server with plink server
When I press enter on my keyboard it's like I have pressed enter twice rather than once
username#server>ls<enter>
file1 file2 file3
username#server>
username#server>
I initially thought this had something to do with extraneous escape characters for the terminal as other questions have indicated. Opening a windows command prompt and ssh'ing to the server with plink output these extraneous characters and I was able to remove them with the following variables in my bashrc:
export PROMPT_COMMAND=""
export PS1="\u#\H:\W>
export TERM=""
The windows command prompt now properly displayed the plink session with no extraneous escape characters. Despite this, the Emacs shell still seemed to press enter twice for one press.
Next, I assumed there was a problem with the characters that were being sent by the enter key.
running showkey -a seems to explain the problem:
In a real putty window and in the Windows command prompt I got the following showkey output while in a ssh connection to the server:
showkey -a
Press any keys - Ctrl-D will terminate this program
^M 13 0015 0x0d
in the Emacs shell I get this output
showkey -a
Press any keys - Ctrl-D will terminate this program
^M^J 13 0015 0x0d
10 0012 0x0a
It seems that the Emacs shell is sending a carriage return as well as a line feed when I press enter (the DOS line ending format). It makes sense then that enter is "pressed twice." Is there any way to change this behavior in the shell? I have seen the use of set-buffer-file-coding-system to tell Emacs to use Unix, Windows or Mac line endings. but this doesn't seem to work for me since I am in a shell.
For each inferior process, Emacs applies independent coding systems for the process input and process output.
In your case the coding system for input to the process will be a "dos" system, resulting in the CRLF pair being sent to the process for EOLs.
You can use M-x set-buffer-process-coding-system to change these input/output coding systems interactively for the current buffer. Bound by default to C-xRETp
You could also use a hook to do so automatically for certain modes. e.g.:
(add-hook 'shell-mode-hook 'my-shell-mode-hook)
(defun my-shell-mode-hook ()
"Custom `shell-mode' behaviours."
(set-buffer-process-coding-system 'utf-8-unix 'iso-latin-1-unix))
As per the interactive prompts, the first argument is "Coding-system for output from the process" and the second is "Coding-system for input to the process".
See C-hig (emacs)Communication Coding for more information.
I have installed Cygwin on my machine and I would to know if there exist a way to use full power of sort command also with the normal DOS prompt.
I have read this question: Unix Sort with Tab Delimiter
and the command to sort a tabbed file using the second column is:
sort -t $'\t' -k 2 file.txt
If I launch the command inside the Cygwin environment it works like expected, if I launch it from the normal Windows prompt (I have renamed sort.exe into xsort.exe to avoid conflicting with native Windows sort command) it doesn't works, it not recognize the $ operator and it see \t like two distinct characters and operation fails.
Is it possible to make it working also from the DOS prompt?
This is regulated by PATH environment variable.
Under DOS prompt run the following:
echo %PATH%
You will see the path C:\cygwin\bin after c:\Windows\system32.
This means that Windows's sort.exe will be used for command sort.
You will need to edit environment variable PATH for your Windows to move c:\cygwin\bin to the left of C:\Windows\system32.
Try this (in Windows a tab is '^t' rather than '\t'):
sort -t'^t' -k2 file.txt
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
Currently in my Terminal, every shell prompt looks like ComputerName: FooDir UserName$. The UserName part simply wastes too much space out of my precious 80 columns. Is there a way to suppress it?
The prompt is defined by the environment variable PS1 which you can define in .bash_profile.
To edit it, open or create the (hidden) file .bash_profile:
nano .bash_profile
and add a line that says
export PS1=""
Between the quotation marks, you can insert what you would like as your terminal prompt. You can also use variables there:
\d – date
\t – time
\h – hostname
\# – command number
\u – username
\W – current directory (e.g.: Desktop)
\w – current directory path (e.g.: /Users/Admin/Desktop)
The default prompt for common Linux distributions would be \w $, which evaluates to ~ $ in your home directory or e.g. /Users $ somewhere else. There are also website (like this one) that can help you with building your prompt.
If you want to remove the UserName part, your choice would be \h: \w$.
Once you made your changes, save the file with Control+o, Return, Control+x.
Here's an excellent article with a full list of Variables and Colors:
Customize your Shell Command Prompt
For a simple, minimalistic prompt, you can try this. Add the following line to your .bash_profile or simply test it first by running it in your terminal:
export PS1="\[\033[0m\]\w\$ "
It'll look something like this:
Here's my Prompt (source), also very simple:
export PS1="\[\033[1;97m\]\u: \[\033[1;94m\]\w \[\033[1;97m\]\$\[\033[0m\] "
2019 onwards, MacOS default shell is Z Shell. To customize command prompt, add a file named .zshrc in user home and put following line that sets a PS1 environment variable with desired prompt format:
export PS1="[%n]%~> "
Open new terminal
This is result of following format expansion:
%n User name
%~ Current directory
See full list of available expansions here.
Your answer can be found right here:http://www.hypexr.org/bash_tutorial.php#vi at about the middle of the page. :)