[raspberry-vi] Re: Did you know...?

  • From: Mike Ray <mike@xxxxxxxxxxxxxxx>
  • To: raspberry-vi@xxxxxxxxxxxxx
  • Date: Fri, 5 Aug 2016 14:39:56 +0100


Here's a trick for your prompt...

A fragment from my .bashrc:

temp=$(tty)


if [ "$color_prompt" = yes ]; then
    PS1='${temp:5}
${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$
'
else
    PS1='${temp:5} ${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

That will put the name of the tty in the beginning of the prompt string.
 So you can see where you are:

pts/0 mike@intruder:~$

Which shows me it's the first SSH connection to intruder.

Or you get:

tty0 mike@intruder:~$

If it's local.

That way if you have several sessions on the same machine, or if you
have multiple virtual consoles open, you can always tell which it is.

Mike



On 05/08/2016 14:32, Jeffery Mewtamer wrote:

cd - sounds like one of those tiny, but infinitely useful tricks I
wish I had learned years ago.

In returns, here's a little trick I've learned recently(though I'll
admit I still use the more cumbersome method out of habit):
ctrl+l will clear the terminal. Not that useful, but it's still many
fewer keystrokes than typing the clear command.

Also, PS1=STRING will change the command prompt to STRINg. PS1=$ is
usually the first command I type when launching a fresh terminal since
my terminal screenreader likes to repeat the prompt every time a new
empty prompt is displayed, I tab complete more than one character, or
cycle through my command history and I don't need constant reminders
of my user and host names and if I forget what directory I'm currently
in, I have pwd for that. Though, if anyone knows what config file I
need to alter to make $ the default prompt, or go a step further and
make the prompt say tty followed by the active terminal number, that
would be great.



-- 
Michael A. Ray
Analyst/Programmer
Witley, Surrey, South-east UK

Eyes-free Linux:
http://eyesfreelinux.ninja/

Raspberry VI:
http://www.raspberryvi.org/

=========================================================== 
The raspberry-vi mailing list 
Archives: //www.freelists.org/archives/raspberry-vi
Administrative contact: <mike.ray@xxxxxxxxxxxxxx>
-----------------------------------------------------------
Raspberry Pi and the Raspberry Pi logo are trademarks of the Raspberry Pi 
Foundation.

This list is not affiliated to the Raspberry Pi Foundation and the views and 
attitudes expressed by the subscribers to this list do not reflect those of the 
Foundation.

Mike Ray, list creator, January 2013

Other related posts: