Hot answers tagged

29

What is $TERM for? The $TERM variable is for use by applications to take advantage of capabilities of that terminal. For example, if a program want's to display colored text, it must first find out if the terminal you're using supports colored text, and then if it does, how to do colored text. The way this works is that the system keeps a library of known ...


19

VT100 terminals (which all modern terminal emulators emulate to some extent) supported a number of problematic commands, but modern emulators or distributions disable the more problematic and less useful ones. Here's a non-exhaustive list of potentially risky escape sequences (not including the ones that merely make the display unreadable in some way): The ...


16

The TERM environment variable is a way that you, the user, can tell programs (e.g., emacs, grep, less, ls, and vim) what kind of terminal they are running on, so they will know its parameters, including what capabilities it has and what escape sequences they need to issue to access them.  This exists because it’s too hard, in general, for the software to ...


14

A long time ago, there was a window manager called twm—actually, it still exists and runs perfectly well. Instead of minimizing a window to a bar at the bottom of the screen (or similar) like MS Windows, Mac OS X, and many modern window managers, it shrunk them to labeled icons ("iconfify"). The Wikipedia twm article has some nice pictures, such as: The ...


11

Xterm is configured via X resources. This is how you might configure it for white on black, with a lighter blue than the default (adjust the color as you see fit, obviously): XTerm.VT100.background: Black XTerm.VT100.color0: Black XTerm.VT100.color1: Red XTerm.VT100.color2: Green XTerm.VT100.color3: ...


11

(Inspired by this SU answer) You can combine a couple bash tricks: If you trap a DEBUG signal, the handler is called before each command is executed The variable $BASH_COMMAND holds the currently executing command So, trap DEBUG and have the handler set the title to $BASH_COMMAND: trap 'printf "\033]0;%s\007" "${BASH_COMMAND//[^[:print:]]/}"' DEBUG ...


11

The TERM environment variable indicates the terminal type, not the terminal application. TERM has a specific purpose: it tells applications running in that terminal how to interact with the terminal. Applications interact with terminals by writing escape sequences — sequences of characters that include nonprintable characters and have effects such as moving ...


11

The TERM environment variable should be set by the application that is acting as your terminal. This is the whole point of the thing: letting programs running inside them know what terminal is being used and hence what sort of features it supports. Zsh is not a terminal. It is a shell. It might care what your TERM is set to if it wants to do special things, ...


10

Problem solved! To enable native xterm mouse scrolling in tmux, a lot of wiki, Q & A site, blog post suggest adding a line like: set -g terminal-overrides 'xterm*:smcup@:rmcup@' to ~/.tmux.conf. And it is the culprit. To allow xterm titles in terminal window, you also need to add the XT flag, something like this: set -g terminal-overrides ...


10

Basically, you need: trap 'printf "\033]0;%s\007" "${BASH_COMMAND//[^[:print:]]/}"' DEBUG at the end of your .bashrc or similar. Took me a while to work this out -- see my answer here for more information :)


9

The value of the environment variable TERM is used by the server (in system V, or BSD, derived OSes) to control how input is recognized by the system, and what capabilities exist for output. Some terminal types are similar enough that they can be interchanged while still remaining usefull, while others could make the system unusable until you open a new ...


9

ls don't outputs colors by default, usually it is an alias to ls --color=auto setted in .bashrc. Check if you're invoking ls directly or through an alias with type ls. If it outputs ls is /bin/ls maybe your .bashrc wasn't loaded when you created the tmux session. If so, try to reload it with source ~/.bashrc.


9

This is probably the urgency hint which can be set on windows. This hint is recognized by most window managers. Most terminals can be configured to set the urgency hint when receiving a bell. (u)xterm for example has the bellIsUrgent option and (u)rxvt has urgentOnBell. To ring the bell in a terminal just run tput bel or echo "\a" (depending on the shell ...


9

you don't see actual terminals all that often anymore, but for instance the Linux text consoles on (CTRL +) ALT + F1 through F6 are considered terminals. xterm is a terminal emulator for systems running the x-window system and a graphical user interface. It provides only a single terminal, typically running a single process (an interactive shell by ...


8

If using bash, the following should do the trick: TOLASTLINE=$(tput cup "$LINES") PS1="\[$TOLASTLINE\]$PS1" Or (less efficient as it runs one tput command before each prompt, but works after the terminal window has been resized): PS1='\[$(tput cup "$LINES")\]'$PS1 To prevent tput from changing the exit code, you can explicitly save and reset it: ...


8

Update: It's nVidia Stephen Dowdy responded to the Debian bug report and suggested it may be an nVidia bug. where it is corrupting signal masks. Some searching found Debian Bug #728743, and indeed switching to Nouveau/MESA (the open-source driver) has fixed the problem. Note that downgrading to an older nVidia driver did not, which likely means that its ...


8

You do it with X resources. I have a file, .Xresources, that contains these xterm-related resources: XTerm*VT100.cutNewLine: false XTerm*VT100.cutToBeginningOfLine: false XTerm*VT100.charClass: 33:48,35:48,37:48,42:48,45-47:48,64:48,95:48,126:48 In my .xinitrc file, I have some line that merge in those resources: if [ -f $userresources ]; then ...


8

If you meant to distinguish interactive from noninteractive shells, use test's inbuilt support for detecting it (not sure if ksh has it, but the binary from coreutils supports it too): test -t 0 # will return 0 for interactive shells If you really meant whether you're on a tty/pty/pts or something else, parse the output from tty: $ tty # konsole ...


8

When you say "for only this bash session", I assume you mean the bash session that is calling the script. When you execute your script, it gets a new shell environment. Thus when you export variables, you are exporting it to the new shell environment and not its parent environment. As far as I know, there is no way to access the parent environment. ...


7

Xterm puts the variable WINDOWID in the environment of its subprocess. Its value is the window ID of the xterm window. There is no POSIX way of querying the environment of a process based on its PID; here's a Linux way of querying the environment of process $pid and extracting the WINDOWID variable: </proc/$pid/environ gawk -v 'RS=\0' -F = ...


7

Each line of the file contains the string ^M 1 twice. That is, <carriage-return><tab>1 ^M^I1 \r\t1 (Those are three different representations of the same control characters) When this is sent directly to your terminal, as cat will do, the terminal interprets this as an instruction to move back to the beginning of the line, move over 8 ...


7

VT100s responded to character sequences sent to them as output. So echo'ing characters works because the terminal sees it as output. Typing characters is input; the terminal will respond only if the characters are echoed by the receiving computer. Your typical shell doesn't echo ESC, it interprets ESC as the prefix for some interactive input command. Run ...


7

The Liberation font doesn't seem to have this symbol. But using XTerm*faceName: DejaVu Sans Mono (which is also a truetype font) allows ☠ to be displayed. EDIT: Do not use LibreOffice or OpenOffice to determine whether a glyph is supported in a font, as it silently falls back to another font: OpenOffice bug 45128.


7

The environment variable TERM does not mean the terminal you are using. Quoting gnu.org: The environment variable TERM contains a identifier for the text window's capabilities. You can get a detailed list of these cababilities by using the > ‘infocmp’ command, using ‘man 5 terminfo’ as a reference. When producing text with embedded color ...


7

From the perspective of what's similar between xterm and screen: Both are emulations of the real hardware device "terminal", like this VT100: VT100 - Wikimedia commons xterm emulates one terminal showing it as a GUI window on screen screen emulates multiple terminals, but does not actually emulate the output part - it behaves like a program that ...


7

Yes, finally found my mistake. It seems like you need to install the package rxvt-unicode-256color to get 256 color support. sudo apt-get install rxvt-unicode-256color is the answer to my problems.


6

The reason is that in your xterm, ^H is the erase character, and tmux apparently translates the erase character to the corresponding control character (^?) for the terminal it emulates, so that erasing works as expected in cooked mode (for instance, what happens when you just type cat). The translation is needed in case you use a terminal with ^? as the ...


6

The above is a bitmap font (looks very much like -misc-fixed-*-r-semicondensed). What you need is to enable TrueType fonts in XTerm. Provided your XTerm has been compiled with TrueType support, you want to set the xterm*renderFont property to true in your ~/.Xdefaults (or wherever you may have it). XTerm*renderFont: true Alternatively you can do it in the ...


6

You can get xterm's dimensions via the environmental variables $COLUMNS and $LINES. You can then set the title via certain escape codes documented e.g. in Bash Prompt HOWTO. Here is a one-off command to set title: # The title text is the stuff between ; and \a printf "\e]0;${COLUMNS}x${LINES}\a" I don't know if there is a way to update the title when the ...


6

The feature seems to be called 'alternate screen' or switching between normal and alternate screen. You can explore it using an xterm. For example type man man in an xterm and exit man. Now you can switch to the alternate screen via Ctrl+Mouse2 (middle click) -> 'Show alternate screen'. Alternatively you can directly enter the xterm control sequences, e.g.: ...



Only top voted, non community-wiki answers of a minimum length are eligible