How can make screen sessions to use same settings as original terminal - linux

When I run 'screen' command after logging into the linux terminal from putty,
I see font color of folders got changed.
earlier folders are shown with different color(blue)'
Now all files are in same color.
How can I make sure even screen sessions also use same font settings as original terminal?

There really isn't enough information to answer this question, but here's a couple things you could do to troubleshoot.
Make sure that the $SHELL in screen is the same as the $SHELL in the original terminal (Run echo $SHELL before and after starting screen and compare the results). Perhaps screen is running a different shell and thus not reading your preferred .*rc file.
Also, try starting screen with a specific TERM value. Set screen's term value to $TERM before when starting screen like so:
screen -T $TERM
I would also recommend trying to replace $TERM with xterm if $TERM doesn't solve it.

Related

Changing gnuplot x11 output defaults

I am using gnuplot over ssh (-X) and due to different screen resolution issues, my x11 output window has minuscule fonts. I want to access the .Xdefaults file as mentioned in documentation but cannot locate it. This question GNUPLOT_DRIVER_DIRECTORY pointed towards some solution but I don't want to input it every time. Can someone help me find a permanent fix for font sizes?
What is your default terminal ? I think it shoulds be xterm, to have x11 as defaults.
shell> echo $TERM
What is yout default gnuplot terminal display ?
gnuplot> show term
Instruction in ~/.Xdefaults have a special syntax (some example in linuxcertif.com/man/1/gnuplot/ ). But i think that's not what you want to do. This is more for 'fine tuning'. And i think it will only be effective if your default terminal is allready x11.
gnuplot*pointsize: 2
gnuplot*background: white
gnuplot*textColor: black
Anyway, it is better to use gnuplot with a text file : file.gp where you put your commands. Then just put in the beginning of your file :
set term x11 font "arial,15"
And execute your file with :
shell> gnuplot file.gp -
do not forget the 'dash' '-' at the end of the command, so that you can continue to put command in the gnuplot prompt to debug additional command.

Is there any way I can change only a specific directory color in linux?

I only need to set a color that will only effect a particular directory not globally.
If you are using Bash in a terminal that supports colors and would like to change the default color for text output to the terminal (not specifically the output of ls) while inside this directory, there is one thing you could do.
The PROMPT_COMMAND variable can be set to execute a command just before printing the prompt. You could use that to check for the current directory and change the terminal color (for instance by assigning the PS1 variable with a prompt that contains non-displayable special codes for selecting a color or echoing said special codes).
PROMPT_COMMAND is documented in the Bash manual: https://www.gnu.org/software/bash/manual/bashref.html
As for how to assign colors, you should look that up if interested.
This solution may not be what you are looking for, will probably have side effects, and generally speaking, I am not sure it will be that useful changing terminal colors depending on the current directory. The usual solution is to have a prompt that shows the current directory path (or at least the last portion of the path).
I use something similar to the above to change text color depending on which machine I am executing Bash on, as I use ssh a lot from one machine to another over several terminal windows, and color (on a black background) is a good way to remember what machine any given window is connected to.

Unicode and 256 colors in Raspberry Pi Terminal Environment

I'm working with a bunch of Raspberry Pi 2s running Raspbian, building interactive puzzles for a performance installation. The puzzles are meant to be played on the command line. My background is in web development, so while I'm very comfortable on the Linux command line, I don't have a lot of experience tailoring a local terminal environment. I have a number of distinct requirements and I can never quite fulfill all of them at once. Namely:
I would like the game to be loaded from the kernel console, without starting LXDE. This is mostly because in a terminal environment, I can catch any keystrokes that someone would use to try to exit the game, and put a password up to prevent it. Also, I have not yet determined whether I could start a terminal window in LXDE and hide all the windowing chrome to make the game appear to be CLI only.
I need 256 color display.
The game is played in English, but contains some Cyrillic characters, so I need unicode support. A sample of the characters used:
0x1440
0x1437
0x143d
I can get the 256 color display in xterm using TERM=xterm-256color, but ONLY if I launch it in a window in LXDE. Same goes for Unicode support. When I try starting xterm from the kernel console, I can pass a number of options to customize the display of the terminal (-fg, -bg, -fa), but can't make it display 256 colors or unicode characters. I've tried using a .Xresource file and loading it with xrdb -merge ~/.Xresource, but it doesn't seem to have any effect at all. Currently, I have a .xinitrc file that contains
`which xterm` \
-fg white \
-bg black \
-fa *-fixed-*-*-*-18-*
-en en_US.UTF-8
-tn xterm-256color
and I launch xterm by simply running xinit. When I do so, xterm starts and respects the foreground, background, and font properties, but only displays 8 colors and won't display unicode characters. Can anyone offer any insight for how to meet all three of my requirements above? I would also accept an answer that shows how I can simply start the game from an LXDE window, but full-screen that window with absolutely no chrome, and prevent the user from being able to exit that environement (there will not be a mouse attached to the machine)
Thanks!
It's a shame, someone posted an answer here and pointed out that I had a typo in the .xinitrc that I posted (missing \ characters after a couple of the lines). After going back and double checking, that did turn out to be part of the problem. He or she or someone else apparently took down the answer though, so I can't give credit.
The other part of the problem was that the unicode characters I'm trying to display are not Cyrillic, but are rather part of the Unified Canadian Aboriginal Syllabics block, which simply wasn't part of any of the terminal fonts I was using. After some digging, I found what appears to be the only monospaced font that contains these characters, Everson Mono. I installed that to /usr/local/share/fonts, and amended my .xinitrc file thusly:
`which xterm` \
-fg white \
-bg black \
-fa 'Everson Mono' \
-en en_US.UTF-8 \
-tn xterm-256color
...and now I can load xterm with xinit and run my app and all is right with the world.

How do I get GNU screen to read .bash_profile/.bash_rc changes?

After I make changes in .bash_rc or .bash_profile, when I start GNU screen, it doesn't recognize those changes.
I can
source ~/.bash_profile
and it works for the current screen window I have open, but I have to do that for every screen window I have open.
How do I get screen to read my latest changes in my bash configuration?
If you want screen to always treat your shell as a login shell, and source the same files that would be read if just started a new shell normally, add the following to ~/.screenrc (or maybe ~/.byobu/.screenrc, as pointed out in the comment):
shell -$SHELL
This way, you don't need to manually tell it to source your files each time you start a new screen. Though you would have to if you just made changes and wanted those changes to be reflected in your current screen.
The documentation for this (and lots of other screen details) can be found here. Basically, shell is a command to screen telling it to run the following when it needs to create a new shell. $SHELL is the usual variable holding the path to your preferred shell. And the dash - in front of $SHELL indicates that it should be run as a login shell (which will typically mean it sources your ~/.bash_profile, etc.).
It's worth pointing out, however, that screen defaults to just inheriting most environment variables from the shell where you start screen; and a login sub-shell may alter some environment variables in unexpected ways. I ran into a situation where elements of my $PATH were basically permuted. I solved the problem thanks to this particularly excellent answer on superuser.
You may notice the source command available. It's important to note that this sources a file of screen commands, rather than shell commands. Other relevant (screen) commands include eval and exec.
You have to do it in each screen that you have open since they are all different shells. If you need the change every time a new shell is opened, I suggest you put the changes in ~/.bashrc instead.
Apparently, you can send a command to all windows at once using this syntax:
C-a :
at "#" stuff "source ~/.bash_profile^M"

How to change colors programmatically in Konsole based on current directory?

I currently use a color scheme based on which directory that I'm working in. I manually open up a Konsole shell and then cd into a directory and got to Settings and change the color scheme.
What I would like to do is have Konsole automatically set its foreground and background colors based on which directory I'm in. Basically if I'm in any subdirectory below /home/me/src/java then I would like to use text white, background blue, for example. If I'm below /home/me/src/documentation I want text black, background white, for example. I would like the color change to occur automatically, programmatically, when I call the "cd" command.
Is this possible? If so, can you provide me some direction as to how?
The way I see it I will need to be able to do a couple of things:
Be able to detect which Konsole the shell process (bash) is running in.
Be able to tell Konsole, probably via API call, to change the color scheme on the fly.
To get you started, here's a little information about using D-Bus to script Konsole.
You don't say which shell you're using, but if it's Bash you may want to use the $PROMPT_COMMAND variable which holds a command to be executed each time the $PS1 prompt is issued. The Z shell has a similar facility that's probably a bit more powerful (see man zshmisc for chpwd and precmd).
Otherwise, you might be able to use xterm escape sequences.
Context
Actually, Konsole has support for what they profiles. A profile is a group of settings (not only background), which you can manually define under Settings | Manage Profiles and around.
Also, there exists a command line utility called konsoleprofile which allows for programmatic changing of the profiles.
Actual answer
Go to Settings | Edit Current Profile... | Appearance
Define new Color Scheme for each of the directories you want to have special background for, e.g. myprofile1, myprofile2, mystandard
Make sure you can manually call konsoleprofile ColorScheme=myprofile1, konsoleprofile ColorScheme=standard, etc.
Plug in the calls to konsoleprofile into your $PROMPT_COMMAND, e.g. add this to your .bashrc:
PROMPT_COMMAND='[[ "$PWD" = /home/me/src/java* ]] && konsoleprofile ColorScheme=myprofile1 || konsoleprofile ColorScheme=mystandard'";$PROMPT_COMMAND"

Resources