Is this BASH tweak possible? (Formatting the output)
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is this BASH tweak possible? (Formatting the output)
I have two questions..
Question one (easier to answer, I think):
When I edit my .bashrc file to change PS1 (bash prompt), it only changes it in gnome terminal, not in the virtual terminals (tty1,tty2, not sure the official name for them).
Why is this, and how could I make the prompt change there too?
or
[12:33] $ Command
[12:34] Standard output goes here!
[12:35] Woo!
As you can see, I'm inserting stuff before every output line. It might make copying output with copy/paste annoying, but sometimes I wish I could get the text a little farther away from the left side for easier reading. I'm just curious as to whether it's possible.
Hi.
I'm not sure about formatting the output but you can make the bashfile display some text before or after the command.
F.ex.
echo "This is describing text for the command"
unSpawn,
Normally I wouldn't suggest symlinking the two, but as long as neither .bashrc nor .bash_profile echo messages out to the terminal (and they usually don't by default), Rob00's fine. I know one is for non-interactive login and the other for interactive login, but the short of the long is;
His session manager (xterm, eterm, konsole, whatever) is not starting bash properly, but rather than get into the dynamics of that, linking the two is fine.
Heck, the compile options for bash can be tweaked to change the default behavior.
Typically I would suggest putting the following at the bottom of the .bashrc file;
Cue the Quick-n-Dirty Intro to Shell Scripting black arts as previously mentioned....
Code:
## Are we on a terminal?
/usr/bin/tty -s
if [ $? -ne 0 ]; then
## Do we have an interactive configuration for bash?
if [ -r ~/.bash_profile ]; then
## Source it - (Note: make sure it's sane, no printing to the term!)
. ~/.bash_profile
fi
fi
But I'm taking the "safe" route and suggesting the ln command rather than vi (or...emacs).
Bash startup files are explained here. They divide into "login/not login" and "interactive/not interactive". ~/.bashrc is for interactive shells that are not login shells. When you log in at virtual terminal it's a login shell so ~/.bashrc is not used; instead bash uses /etc/profile and the first of ~/.bash_profile, ~/.bash_login and ~/.profile that is available.
A common way to apply the same customisation to login shells as is applied to non-login interactive shells is to add this line to /etc/profile or whichever of ~/.bash_profile, ~/.bash_login or ~/.profile is used
Code:
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
I favour ~/.bash_login because it is per-user rather than system-wide and the name reminds when it is used.
or
[12:33] $ Command
[12:34] Standard output goes here!
[12:35] Woo!
As you can see, I'm inserting stuff before every output line. It might make copying output with copy/paste annoying, but sometimes I wish I could get the text a little farther away from the left side for easier reading. I'm just curious as to whether it's possible.
there's might be a dirty way to do that in the virtual console. you can hack the vc manager (whatever it is) in the kernel to always insert a custom string on every line.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.