date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,424,268,416,000
Editing text file using Emacs will make Emacs make a companion file for its own purpose. For example, after first editing a file called test.c, Emacs will leave a file called test.c~ in the same directory. This can be a little annoying when visualizing all files cluttered with the ~ files in a console Any way to get rid of seeing these ~ files in a console, like the Gnome Terminal? Update Thanks to @don_crisst's comment below: use ls -B to hide the ~ files when displaying file names. The command line switches, -B or --ignore-backups, do not list implied entries ending with ~.
Use ls -B to hide the ~ files when displaying file names. The command line switches, -B or --ignore-backups, do not list implied entries ending with ~.
Gnome Terminal---hide the tilde files produced by Emacs
1,424,268,416,000
I have a script that starts my vagrant machine, opens up multiple terminals and connects to the vagrant machine via ssh in every newly opened terminal. My problem is that I need about five terminals, and I don't want to type in the password for each terminal manually. Is there a way to get prompted for the password only once in the main terminal, and use the same password for the ssh command? #!/bin/bash cd /home/kkri/public_html/freitag/vagrant vagrant up for run in $(seq 1 $1) do gnome-terminal --window-with-profile=dark -e "ssh vagrant@localhost -p 2222" --$ done gnome-terminal --window-with-profile=git clear echo "~~~ Have fun! ~~~"
In general (ignoring vagrant or other system-specific details) your best bet is to set up authentication with SSH keys, and run ssh-agent. Then open the ssh sessions with something like: # load the key to the agent with a 10 s timeout # this asks for the key passphrase ssh-add -t10 ~/.ssh/id_rsa for x in 1 2 3 ; do ssh .... done Or, if you can't use keys, you could rig something up with sshpass. read -p "Enter password: " -s SSHPASS ; echo for x in 1 2 3 ; do sshpass -e ssh ... done unset SSHPASS Though with the terminal in the middle, this would leave the password set in the terminal's environment. To work around that, you could save the password temporarily in a file: read -p "Enter password: " -s SSHPASS ; echo PWFILE=~/.ssh/secret_password cat <<< "$SSHPASS" > "$PWFILE" unset SSHPASS for x in 1 2 3 ; do sshpass -f "$PWFILE" ssh ... done shred --remove "$PWFILE" This still isn't optimal since there's a chance the password hits the disk, so keys would be better.
How to type in password for multiple windows?
1,424,268,416,000
openSUSE Leap 42.2 Gnome Terminal 3.20.2 I have a terminal window open. If I type the following command: gnome-terminal as a non-root user it successfully launches a new terminal. However if I run the command as root I get the following error message: Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: The connection is closed If I try to launch the terminal with dbus-launch gnome-terminal then it works. What is preventing the gnome-terminal command launching the terminal as root? And is dbus-launchan acceptable workaround or likely to cause unforeseen issues (I don't really understand what it is doing)?
Remember how Windows applications mainly worked back in the Win16 days before Win32 came along and did away with it: where there were hInstance and hPrevInstance, attempting to run a second instance of many applications simply handed things over to the first instance, and this made things difficult for command scripting tools (like Take Command) because one would invoke an application a second time, it would visibly be there on the screen as an added window, but as far as the command interpreter was concerned the child process that it had just run immediately exited? Well GNOME has brought the Win16 behaviour back for Linux. GNOME Terminal is now a client-server application. The gnome-terminal program is just a client that constructs Desktop Bus messages to a server, passing along its command line options, environment, working directory, and arguments, and then simply exiting. The server is gnome-terminal-server which registers as org.gnome.Terminal on the Desktop Bus and which is responsible for all of the actual terminal emulation and displaying the window(s) on the GUI(s). A Desktop Bus client like gnome-terminal locates the Desktop Bus broker via an environment variable, which usually points to socket in a per-user directory such as /run/user/1001. Alternatively, the environment variable specifies to look in "the current user's runtime directory" and a path similar to the aforementioned is constructed from the client process's effective user ID. This directory in either case is conventionally private to the individual user, and inaccessible to other (unprivileged) users. Hilarity ensues when people attempt to run gnome-terminal as another user via sudo and suchlike. If the environment variable points to an explicitly-named runtime directory, an unprivileged client cannot connect to the per-user Desktop Bus. If the environment variable points to "the current user's" runtime directory, it looks for the wrong Desktop Bus broker, often the one for a user that does not currently have a Desktop Bus broker running because the user has not logged in and started up that user account's per-user services. (Per-user Desktop Bus brokers are run by a per-user service manager. The per-user service manager is either started explicitly or, in the case of some service management softwares, by some rather ugly hooks into the user authentication process employed by the likes of the login, su, and SSH server programs.) The reason that dbus-launch worked for you as the superuser is that dbus-launch explicitly launched another Desktop Bus broker, running as the superuser, which gnome-terminal was able to talk to. Luckily, the system was also configured to demand-start the gnome-terminal-server server when the client attempted to connect to it via the broker. (This is not necessarily the case, and nowadays such demand-starting is seen as an inferior mechanism as it ends up with lots of Desktop Bus server processes that aren't running under any kind of service management. Indeed, not having the broker itself under service management is considered inferior too. It's also generally not considered a good idea for the superuser account to have these sorts of services running, as many of them do not expect to be running with superuser privileges because they expect to be running under the aegides of ordinary user accounts.) Further hilarity ensuses if, as the questioner at "How can I launch gnome-terminal remotely on my headless server? (fails to launch over X11 forwarding)" does, people attempt to run gnome-terminal when even the original user does not have a Desktop Bus broker running. This happens when, for example, one has logged in via SSH but the SSH login process does not start up the per-user service manager, which in turn means that the per-user Desktop Bus broker is not run, and the gnome-terminal-server server cannot be reached over a Desktop Bus. (According to how the system is configured, graphical login could still trigger starting the per-user service manager, and hence one might observe that logging in graphically as the same user magically makes things work. And again dbus-launch would explicitly start a non-service-managed Desktop Bus broker.) Yet more hilarity ensues when one has one of the service managers that has the hooks into login, su, and the SSH server. These hooks usually implement the semantics of starting up per-user service management, and all of the per-user services that it starts, at first log-on for that user; and stopping them all at last log-off for that user. If one has a lot of short-lived and non-overlapping SSH sessions, then there can be a lot of overhead generated uselessly starting up and shutting down the entire per-user service management system (and all of its auto-start services) at the starts and ends of each of those SSH sessions. systemd, one such service manager, has an imperfect "linger" mechanism that only really half addresses this. It means that per-user service management "lingers" after the final log-off, but it does not stop the per-user service management from being started at all. Further reading Jonathan de Boyne Pollard (2016). /run/user/jim/dbus. "Gazetteer". nosh Guide. Softwares. jdebp.eu. Jonathan de Boyne Pollard (2016). "per-user user services". nosh Guide. Softwares. jdebp.eu. Run true multiple process instances of gnome-terminal Make user systemd service persistent https://unix.stackexchange.com/a/323700/5132
"error constructing proxy..." when trying to launch gnome-terminal as root
1,424,268,416,000
While investigating a problem described in a question at stackoverflow I simplified it down to a test case demonstrating that in non-interactive mode bash seems to clear the X system clipboard before exiting. The test opens a gnome terminal and runs a bash script in it that places (via xclip) some text in the X system clipboard. While the terminal is open, querying the clipboard returns the text that was placed in it regardless of whether bash is run in interactive or non-interactive mode. However, after the terminal is closed, the clipboard contents survives if bash was run in interactive mode, but is lost if bash was run in non-interactive mode. $ cat xclip_test #!/usr/bin/env bash set -x gnome-terminal -x bash -i -c "echo abc|xclip -selection clipboard; sleep 3" sleep 1 xclip -o -selection clipboard sleep 4 xclip -o -selection clipboard gnome-terminal -x bash -c "echo 123|xclip -selection clipboard; sleep 3" sleep 1 xclip -o -selection clipboard sleep 4 xclip -o -selection clipboard $ ./xclip_test + gnome-terminal -x bash -i -c 'echo abc|xclip -selection clipboard; sleep 3' + sleep 1 + xclip -o -selection clipboard abc + sleep 4 + xclip -o -selection clipboard abc + gnome-terminal -x bash -c 'echo 123|xclip -selection clipboard; sleep 3' + sleep 1 + xclip -o -selection clipboard 123 + sleep 4 + xclip -o -selection clipboard Error: target STRING not available #!!!!!!!!!!!!! I am on Ubuntu 16.04, using default GNU bash (version 4.3.46(1)-release (x86_64-pc-linux-gnu)) with no customizations to bash rc files. I checked .bash_logout just in case and found a call to clear_console utility. However clear_console doesn't seem to deal with the clipboard; besides, the example doesn't run bash as a login shell. Is this something having a sensible explanation? EDIT The problem persists when replacing gnome-terminal with xterm: gnome-terminal -x ... --> xterm -e ... & Also it is not unique to bash - it is reproduced with dash, too.
The author of the original question on Stackoverflow has identified this to be a problem in xclip. Using xsel instead of xclip for manipulating the X clipboard eliminates the issue (note that xclip was replaced with xsel only when placing data into the clipboard, and not when reading from the clipboard): $ cat xclip_test #!/usr/bin/env bash set -x xterm -e bash -c "echo abc|xclip -selection clipboard; sleep 3"& sleep 1 xclip -o -selection clipboard sleep 4 xclip -o -selection clipboard $ cat xsel_test #!/usr/bin/env bash set -x xterm -e bash -c "echo abc|xsel --input --clipboard; sleep 3"& sleep 1 xclip -o -selection clipboard sleep 4 xclip -o -selection clipboard $ diff xclip_test xsel_test 3c3 < xterm -e bash -c "echo abc|xclip -selection clipboard; sleep 3"& --- > xterm -e bash -c "echo abc|xsel --input --clipboard; sleep 3"& $ ./xclip_test + sleep 1 + xterm -e bash -c 'echo abc|xclip -selection clipboard; sleep 3' + xclip -o -selection clipboard abc + sleep 4 + xclip -o -selection clipboard Error: target STRING not available # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $ ./xsel_test + sleep 1 + xterm -e bash -c 'echo abc|xsel --input --clipboard; sleep 3' + xclip -o -selection clipboard abc + sleep 4 + xclip -o -selection clipboard abc Both xclip and xsel work by detaching from the terminal and spawning a child process that is responsible for supplying the selection(s) on demand (until a new selection is made): $ ps -H PID TTY TIME CMD 24307 pts/12 00:00:01 bash 27476 pts/12 00:00:00 ps $ echo qwerty|xclip -selection clipboard $ ps -H PID TTY TIME CMD 27481 pts/12 00:00:00 xclip <-- !!!!!! 24307 pts/12 00:00:01 bash 27482 pts/12 00:00:00 ps The problem with xclip seems to be that, when launched from a non-interactive shell, it doesn't become fully independent of the controlling terminal and dies when the terminal process exits.
xclip works differently in interactive and non-interactive shells
1,424,268,416,000
I start a new process from GNOME Terminal and then this process fork a child. But when I killed the parent process the orphaned process's parent id became something other than 1 which represent init --user pid. When I do this in virtual terminals, the parent pid is 1 which represent init process. How can I execute new process from GNOME Terminal so that when it is died, the child process's parent pid became 1 and not pid of init --user process? Thanks a lot.
I already answered a similar question a few months ago. So see that first for technical details. Here, I shall just show you how your situation is covered by that answer. As I explained, I and other writers of various dæmon supervision utilities take advantage of how Linux now works, and what you are seeing is that very thing in action, almost exactly as I laid it out. The only missing piece of information is that init --user is your session instance of upstart. It is started up when you first log in to a session, and stopped when you log out. It's there for you to have per-session jobs (similar, but not identical, to MacOS 10's user agents under launchd) of your own. A couple of years ago, the Ubuntu people went about converting graphical desktop systems to employ upstart per-session jobs. Your GNOME Terminal is being started as a per-session job, and any orphaned children are inherited by the nearest sub-reaper, which is of course your per-session instance of upstart. The systemd people have been, in recent months, working on the exact same thing, setting up GNOME Terminal to run individual tabs as separate systemd services, from one's per-user instance of systemd. (You can tell that your question is about upstart, not systemd, because on a systemd system the sub-reaper process would be systemd --user.) How can I execute a new process from GNOME Terminal so that the child process's parent PID becomes 1 and not the PID of the ubuntu session init process? This is intentionally hard. Service managers want to keep track of orphaned child processes. They want not to lose them to process #1. So the quick précis is: Stop trying to do that. If you are asking solely because you think that your process ought to have a parent process ID of 1, then wean yourself off this idea. If you erroneously think that this is an aspect of being a dæmon, then note that dæmons having parent process IDs of 1 has not been guaranteed (and on some Unices, not true across the whole system) since the advent of things like IBM's System Resource Controller and Bernstein's daemontools in the 1990s. In any case, one doesn't get to be a dæmon by double-forking within a login session. That's a long-since known to be half-baked idea. If you erroneously think that this is a truism for orphaned child processes, then read my previous answer again. The absolutism that orphaned children are re-parented to process #1 is wrong, and has been wrong for over three years, at the time of writing this. If you have a child process that for some bizarre reason truly needs this, then find out what that bizarre reason is and get it fixed. It's probably a bug, or someone making invalid design assumptions. Whatever the reason, the world of dæmon management changed in the 1990s, and Linux also changed some several years ago. It is time to catch up. Further reading "Session Init". upstart Cookbook. Ubuntu. James Hunt, Stéphane Graber, Dmitrijs Ledkovs, and Steve Langasek (2012-11-12). "Respawning user jobs and PID tracking". Ubuntu Raring upstart user sessions. Ubuntu. Nathan Willis (2013-04-17). Upstart for user sessions. LWN. systemd. systemd manual pages. freedesktop.org.
Orphan process's parent id is not 1 when parent process executed from GNOME Terminal
1,424,268,416,000
I'm looking to use the terminal more and more, and I'd like to find a terminal calendar app that can sync with Google calendar. I'm running ubuntu 14.04
Take a look at: gcalcli, and also: remind , which has PHP scripts to convert iCAL entries to Remind format.
Google calendar in the terminal
1,424,268,416,000
I am running ubuntu 12.04.5 lts. When I do a mouse double click selection I would like to select only a current word. For example in a line like: /home/xx/asdf right now the whole line gets selected when I doulble click on "xx". Also in a line like: $asdf= I would like to select the 1st five characters - include $ in the selection. Right now it selects asdf= - 5 characters including the equal sign. UPDATE: The answer I accepted no longer works since Ubuntu 15 it seems. The following answer works in Ubuntu18: Double click selection in Gnome Terminal
For gnome-terminal: In the menu bar, under Edit : Profile Preferences, tab General you will find Select-by-word chatacters. If you want the terminal to consider / to be a word boundary for selection purposes, remove / from the list of characters.
gnome classic terminal mouse double click selection
1,466,555,813,000
I recently started using Ranger as my default file manager, and I'm really enjoying it. Right now, I've managed to change rifle.conf so that when I play audio or video from Ranger, mpv opens in a new xterm window and the media starts to play. However, if possible, I would like Ranger to open the gnome-terminal instead of xterm. In /.config/ranger/rifle.conf, it says that using the t flag will run the program in a new terminal: If $TERMCMD is not defined, rifle will attempt to extract it from $TERM I tried setting $TERMCMD in both my .profile and .bashrc files, but even though echo $TERMCMD would print "gnome-terminal", Ranger would still open xterm. I also messed with setting $TERM to "gnome-terminal", but that was messy and I decided to leave it alone. Any suggestions? Thanks!
As of 2017, the source-code (runner.py) did this: term = os.environ.get('TERMCMD', os.environ.get('TERM')) if term not in get_executables(): term = 'x-terminal-emulator' if term not in get_executables(): term = 'xterm' if isinstance(action, str): action = term + ' -e ' + action else: action = [term, '-e'] + action so you should be able to put any xterm-compatible program name in TERMCMD. However, note the use of -e (gnome-terminal doesn't match xterm's behavior). If you are using Debian/Ubuntu/etc, the Debian packagers have attempted to provide a wrapper to hide this difference in the x-terminal-emulator feature. If that applies to you, you could set TERMCMD to x-terminal-emulator. Followup - while the design of the TERMCMD feature has not changed appreciably since mid-2016, the location within the source has changed: Refactor and improve the TERMCMD handling moved it to ranger/ext/get_executables.py That is implemented in get_term: def get_term(): """Get the user terminal executable name. Either $TERMCMD, $TERM, "x-terminal-emulator" or "xterm", in this order. """ command = environ.get('TERMCMD', environ.get('TERM')) if shlex.split(command)[0] not in get_executables(): command = 'x-terminal-emulator' if command not in get_executables(): command = 'xterm' return command which uses x-terminal-emulator as before. There is a related use of TERMCMD in rifle.py, used for executing commands rather than (as asked in the question) for opening a terminal. Either way, the key to using ranger is x-terminal-emulator, since GNOME Terminal's developers do not document their command-line interface, while Debian developers have provided this workaround. Quoting from Bug 701691 – -e accepts only one term; all other terminal emulators accept more than one term (which the developer refused to fix, marking it "not a bug"): Christian Persch 2013-06-06 16:02:54 UTC There are no docs for the gnome-terminal command line options.
Ranger file manager - Open gnome-terminal instead of xterm
1,466,555,813,000
If I execute the following command in LXTerminal: gnome-terminal & gnome-terminal gets opened. But as soon as I close the LXTerminal, gnome-terminal will be closed as well because it's a child process. Is there any way to open the second process independently?
It's not possible to start a process without it being the child. When you execute an external command, under the hood the shell calls fork() followed by execvp(). You can prevent it from getting killed when the parent shell dies. One way is to use nohup: nohup gnome-terminal & Another option if you are using bash is to disown the process: gnome-terminal & disown
How to open a process from terminal without becoming child process? [duplicate]
1,466,555,813,000
I use the gnome-terminal and most of my editors with a white on black theme as I find its easier on the eyes. One of my labs requires screenshots of the terminal (with the process) to be submitted along with program code. So, is there a way to temporarily change the terminal to a black on white colour scheme, preferably from within the terminal itself ? If not, is there a way to launch a child terminal with the inverted colour scheme, without affecting the parent terminal ?
You can use gconftool-2 - GNOME configuration tool. First, you can list all your gnome profiles with: $ gconftool-2 --get /apps/gnome-terminal/global/profile_list [Default,Profile0] Now you can print values for selected profile: $ gconftool-2 -a "/apps/gnome-terminal/profiles/Default" Store value of foreground and background color: $ gconftool-2 --get "/apps/gnome-terminal/profiles/Default/foreground_color" #000000000000 $ gconftool-2 --get "/apps/gnome-terminal/profiles/Default/background_color" #EEEEEEEEECEC Now you can turn off using theme colours: $ gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_colors" --type bool false And set your own colours: $ gconftool-2 --set "/apps/gnome-terminal/profiles/Default/foreground_color" --type string "#EEEEEEEEECEC" $ gconftool-2 --set "/apps/gnome-terminal/profiles/Default/background_color" --type string "#000000000000"
Is there a way to temporarily change the terminal colour?
1,466,555,813,000
I have a line in my .bashrc that sets a color-scheme: eval $(dircolors colorfile) This works as expected, setting LS_COLORS with the right string generated from 'colorfile'. When I use screen, the bashrc file is read again, but I lose my colors. Testing, I ran dircolors colorfile in the commandline in screen, and get LS_COLORS=''; export LS_COLORS I can work-around this pretty easily, but I'm curious what's causing dircolors to act differently in screen vs not. I thought it just blindly parsed the file and outputed the string. But it must be checking some env variable or something? Any clues? Here's some extra info: My .screenrc is blank, I'm using gnome-terminal. Dircolors version is 8.25. I used the which command to make sure I wasn't using two different binaries (I wasn't). I checked the value of $? after running dircolors, it was 0 in both cases.
The value of $TERM is different inside screen. Accordingly your colorfile file should probably begin with TERM screen* TERM xterm*
dircolors myfile sets LS_COLORS to empty string in screen
1,466,555,813,000
In Emacs no window mode, the background is automatically the same as the terminal (gnome-terminal). When I look at (frame-parameters) I see that (background-color . "unspecified-bg"). Well, for me, the background happens to be black. Is there a way to find out what the actual background color is for an Emacs session?
If you know how to find out from the terminal, you can use that selfsame command to find out from Emacs. In my case, I'd make a script like this: #!/bin/zsh cat .Xresources | grep 'URxvt\*background\:' | cut -d" " -f2 (Note: -d is to set the field delimiter, -f is to set what field is to be shown: the first field is 1, not 0) The command looks the way it does because .Xresources, the file that sets the background color, looks like this: # ... URxvt*background: black # ... Make the script executable (chmod +x), and put it in your PATH (echo $PATH). If the script is called what_bg, in Emacs, M-x shell-command RET what_bg. Edit (in response to comment): See if this works. I tested it from Emacs, and in urxvt, xterm, and rxvt. While it is more portable than the first script, it assumes .Xresources configuration (which is, while not uncommon, obviously not everywhere). I'm starting to wonder, though, why you need this to begin with? And, if you indeed need it, can't you just look on the window to determine its color? Anyway, the script: #!/bin/zsh terminal_emulator_parents=`pstree -As $$` tep_list=`echo $terminal_emulator_parents | tr -s "-" | tr "-" " " \ | tac -s' ' | tr '\n' ' '` found="false" for process in `echo $tep_list`; do if [[ $process =~ ("urxvt"|"xterm"|"rxvt") ]]; then # here: add all found="true" # terminal emulators break # configurable fi # (and *configured*) done # in ~/.Xresources if [[ $found == "true" ]]; then echo -n "$process: " cat ~/.Xresources | grep -ie ^$process'\*background\:' \ | tr -s " " | cut -d" " -f2 else echo "Couldn't determine the terminal emulator." fi
How to get background color in Emacs?
1,466,555,813,000
xterm: $ echo $TERM xterm-256color $ stty -a speed 38400 baud; rows 52; columns 91; line = 0; intr = ^C; quit = ^\; erase = ^H; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; -parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel iutf8 opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke gnome-terminal: $ echo $TERM xterm-256color $ stty -a speed 38400 baud; rows 57; columns 100; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; -parenb -parodd -cmspar cs8 hupcl -cstopb cread -clocal -crtscts -ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany imaxbel iutf8 opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke When outside tmux, Ctrl-v Ctrl-h outputs ^H. Inside tmux, I start getting ^? if run from xterm. Inside screen run from xterm it still outputs ^H. What's the reason behind this? Should it output ^H or ^?? How to remedy this?
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 erase character (generated by the Backspace key), then resume the session with a terminal that uses ^H as the erase character (generated by the Backspace key). Unfortunately this has visible side effects in some cases, e.g. if you type Ctrl+H. The only good remedy is to make sure that all your terminals (real or in tmux) use the same erase character, which should be ^? (this is standard nowadays). It seems that your xterm is badly configured. This is not the default configuration, AFAIK. In any case, you need to make sure to use a TERM value for which kbs=\177. However this is not the case for xterm-256color from the official ncurses. So, you either need to select a different TERM value or you need to fix the kbs entry for xterm-256color (this can be done by the end user with: infocmp > file, modify file, then tic file). Some Linux distributions do not have this problem; for instance, Debian has fixed this problem via a debian/xterm.ti file in its ncurses source package, giving: $ infocmp xterm-256color | grep kbs kbs=\177, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, You should also have: $ appres XTerm | grep backarrowKeyIsErase: *backarrowKeyIsErase: true Note that you can do stty erase '^?' in xterm (before doing anything else), but this is just a workaround (and it may break the behavior of the Backspace key). You should actually have erase = ^? (as shown by stty -a) by default! In case problems with Backspace and/or Delete remain, I recommend the Consistent BackSpace and Delete Configuration document by Anne Baretta.
Why pressing Ctrl-h in xterm + tmux sends "^?"?
1,466,555,813,000
I find useful the gnome-terminal feature of editing (and creating) profiles with the option of holding the terminal open after the command exists. (I like to use context menu file manager to run commands to display info about a file in a terminal, to show info in a terminal while processing, etc.) I wasn't able to find the same feature in other terminals, so I have to install gnome-terminal even when it's not the default terminal. Are there other terminal emulators with this feature? Is there a command to be used in a given terminal that would have the same effect? I want, with a single line (to be added as context menu entry), to open the terminal, run a command and display info in the terminal window that stays open. Example: in pantheon-files (elementary os) I add a context menu entry for media info using a contractor file with a line like Exec=xterm -hold -e "mediainfo -i %f" (according to a comment below) or Exec=gnome-terminal --window-with-profile=new1 -e "mediainfo -i %f".
You can achieve this in any terminal emulator by the simple expedient of arranging for the program not to exit without user confirmation. Tell the terminal to run terminal_shell_wrapper which is a script containing something like #!/bin/sh if [ $# -eq 0 ]; then "${SHELL:-sh}"; else "$@"; fi echo "The command exited with status $?. Press Enter to close the terminal." read line If you want any key press to close the terminal change read line to stty -icanon; dd ibs=1 count=1 >/dev/null 2>&1
How to hold terminal open (excepting gnome-terminal)?
1,466,555,813,000
The picture on top you can see my xterm, the picture under is the gnome-terminal. Ok This is what I want to get: I use the same font in both but looks different: Xterm*faceName: DejaVu Sans Mono Bold:size=11:antialias=true how can I fix this? //EDIT add more info of my xterm: ldd `which xterm` | grep -E '(freetype|fontconfig)' libfontconfig.so.1 => /usr/lib64/libfontconfig.so.1 (0x00007f07bcbcc000) libfreetype.so.6 => /usr/lib64/libfreetype.so.6 (0x00007f07bb2f3000) my .Xdefaults !XTerm*background: #2D2D2D XTerm*background: #FFFFDD !XTerm*foreground: #D2D2D2 XTerm*scrollBar: off XTerm*vt100*geometry: 88x24 Xterm*faceName: DejaVu Sans Mono Bold:size=11 XTerm*renderFont: true
I believe it's just a typo. Try changing Xterm*faceName: DejaVu Sans Mono Bold:size=11 to XTerm*faceName: DejaVu Sans Mono Bold:size=11 (XTerm rather than Xterm)
Can I make text in xterm looks and feels like gnome-terminal?
1,466,555,813,000
In Linux Mint (Debian-based) how can I edit what the shortcut Ctrl+Alt+t launches? For example, I would like to issue gnome-terminal with the --maximize option, and to have it launch tmux instantly.
You can modify the /desktop/gnome/applications/terminal/exec key in GConf (using gconf-editor), which is described as "the default terminal application to use for applications that require a terminal". Alternatively, I propose a little more flexible solution: if you use Compiz, you can use the Commands plugin to define keyboard shortcuts for your own commands. This way, you can keep the default shortcut to launch a windowed terminal, and define an other shortcut for a fullscreen terminal. (Sidenote: in the Compiz configuration tool, you can change directly the terminal command and shortcut in the Gnome Compatibility plugin.)
How do I edit the terminal launch command in Linux Mint?
1,466,555,813,000
When I try and open the gnome terminal, by clicking the 'terminal' icon in apps, I get a loading and then nothing happens. Is there some way of seeing the background output of trying to open it to try an ddebug it? UPDATE 1: So I was able to open xterminal and tried starting the gnome terminal like this: gnome-terminal This resulted in this output, sorry if it is slightly wrong I had to manually copy it since I couldn't work out how to copy and paste in xterminal: Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: Error calling StartServiceByName for org.gnome.Terminal: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.gnome.Terminal exited with status 8 UPDATE 2: So I got it working again by using google fu to find this thread which got me to enter: locale-gen and reboot which seemed to fix it.
As Ipor Sircer suggests, if you can open another terminal, you can run gnome-terminal from there. Alternatively, you can dump gnome-terminal's output to a file: assuming you're running GNOME, press AltF2 and enter sh -c "gnome-terminal > ~/gnome-terminal.log 2>&1" Then you'll find all the output in ~/gnome-terminal.log.
Gnome Terminal not opening
1,466,555,813,000
I have got a strange problem with gnome-terminal after upgrading from Linux Mint 17.3 to 18.3. Now, --working-directory does not work anymore. Eg: gnome-terminal --working-directory=/home/user/Desktop/ instead opens in my home directory. This also means that "Open in terminal" from Nautilus file manager does not work. If I create a new user and log in with that account, it works. So it must have something to do with gnome-terminal's configuration. However, uninstalling and reinstalling gnome-terminal does not fix the problem, even with apt-get purge. I have also tried looking for something with dconf-editor. Since this behavior breaks some of my important scripts, I would very much like to know how to fix it.
This is a known bug, and unfortunately has yet to be fixed. If you have specified a custom command rather than your default shell to be run upon Gnome Terminal's startup, a potential fix is disabling the custom command: Open the Gnome Terminal settings window and uncheck "Run custom command instead of my shell" to disable the option. This fix was mentioned by Jonathan Hartley in the comments section of the bug report, and fixed the issue for him.
Gnome-terminal cannot open in working directory
1,466,555,813,000
Input file: output of Tower of Hanoi in Brainfuck (some codepoints may not render properly in your browser). The file basically uses escape codes (more specifically ^[[m;nH) to rewrite lines. Running the command (you may need to do sudo apt-get install pv or equivalent) cat hanoi.b.out | pv -l -L 10 -q gives output like if the window size is big enough. If not, the output looks like where the image starts "scrolling down." Naturally, this begs the question: why does this (mis-)behaviour happen when the window size is too small?
Not all of the output is cursor-addressing. Some of it is line-feeds, which will (when the cursor happens to be on the bottom row) cause the terminal to scroll up. Here's a visible rendering using unmap of the beginning of the output: look for the \n (newlines are "line-feeds"); \E[H \E[2J \E[2;27HTowers of Hanoi in Brainf*ck \E[3;15HWritten by Clifford Wolf <http://www.clifford.at/bfcpu/> \E[14;43H----------------------------------- \E[24;23H----------------------------------- \E[14;3H----------------------------------- \E[13;3HxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx \E[12;5HxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx \E[11;7HxXXXXXXXXXXXXXXXXXXXXXXXXXx \E[10;9HxXXXXXXXXXXXXXXXXXXXXXx \E[9;11HxXXXXXXXXXXXXXXXXXx \E[8;13HxXXXXXXXXXXXXXx \E[7;15HxXXXXXXXXXx \E[6;17HxXXXXXx \E[5;19HxXx \E[5;19H \E[13;59HxXx \n \E[1;1H \E[6;17H \E[23;37HxXXXXXx \n \E[1;1H \E[13;59H \E[22;39HxXx \n \E[1;1H \E[7;15H \E[13;55HxXXXXXXXXXx When you use a smaller screen-size, the line-feeds that didn't cause scrolling are more likely to be on the bottom row, so you'll see it scroll up.
Animation inside terminal with escape codes
1,466,555,813,000
This is kind of a followup to another question. I use a custom command in my gnome-terminal profile (/usr/bin/fish). When using Ubuntu 14.04 a Ctrl-Shift-N opened a new gnome-terminal window in the same directory as the current terminal. With 16.04 this changed and now it always opens in $HOME. I want the old behavior. This has nothing to do with sourcing /etc/profile.d/vte.sh. Fish does this correctly as I can observe directory changes in the title bar. If I uncheck the custom command box in my gnome-terminal profile, the new terminal window correctly uses the current directory. However, it use my system default shell: bash. I cannot change my system shell (chsh), because this is shared across other machines, where fish is not available. I don't see a way to fix this from fish, since the terminals current directory is not available. Edit: Since this a regression in Ubuntu, I also reported this as #1609342 to Ubuntu.
As Gilles mentioned in a comment, setting the SHELL variable works as well. It does not have downside of my other answer. Here are the details: Create .xsessionrc in your home directory with contents: SHELL=/usr/bin/fish Disable custom command in gnome-terminal profile options. Log out and in again. Gnome-terminal should respect the variable and use that custom command. It does for me on Ubuntu 16.04.1 and solves the working directory problem.
Gnome-terminal custom command and dynamic working directory
1,466,555,813,000
I am trying to install some key sequence bindings but I have trouble. My shell is bash, my terminal is gnome-terminal, and my system is Ubuntu 14.04 in graphic mode. Edit : my keyboard is french azerty with the numeric pad and ctrl,fn,super,alt. Edit: a bash guide, readline chapter I want to add contol+alt+space, but this exact sequence does not work while similar other sequences work fine. My goal is to run shell-expand-line readline but i tried upcase-word to compare. --Let's analyze my goal's installation effect. This is my ~/.inputrc added (ctrl+meta+space): "\e\C- ": shell-expand-line This is the new result of bind -p : "\e\C-@": shell-expand-line Of course I started a couple terminals, one before installation and one after every installation in order to compare thoroughly. --Some experiments to ensure control+alt works in place of control+meta. The system should emulate Meta with Alt and bash should emulate Meta with Escape, both using the byte '\033'. I tried both Alt and Esc to conclude it works fine. I tested some ctrl+meta+letter sequences to be sure. By the way, the individual samples of Ctrl+Alt are simple : expanding an isolated tilde '~' (shell-expand-line) or changing case in random lowercase words (upcase-word) with ctrl+meta+e or ctrl+meta+v. Ctrl+meta+e is already binding to shell-expand-line so i just mixed the bindings with the useless ctrl+meta+v. --Some more intricate observations... I read '^@' illustrates 'NUL' character. Why this escape? I tested xev and pressed ctrl+alt+space : the character reported is 'NUL' character. I saw alt+space usually open the window menu of gnome-terminal while alt enables menus, of course without control key. A conflict seems to come from the system, but I am a newbie. I just read most of the bash manual (especially readline chapter) and one forum advice about xev. --Question Is there more to say or to correct? Why the sequences are rewritten? How can I make my ctrl+alt+space work with bash and gnome-terminal ? Edit : I found that '@' is transformed in 'NUL' because of a bitwise mask applied when escaping, but i do not see any reason why Alt+space gives 'NUL'.
Your gnome-terminal (actually the underlying vte-0.34) emits the wrong sequence for ctrl+Alt+space. The bug (https://bugzilla.gnome.org/show_bug.cgi?id=710349) was fixed in vte-0.36. If you're not afraid of hacking a little bit and you're able to safely revert things in case of trouble, you can try to install vte-0.36 on your Ubuntu 14.04. You'll get many other fixes and improments along with this one. You might find a PPA or a package in Gnome3 staging, or compile it for yourself. Upgrading to this version of vte doesn't require touching any other software components. A complete restart of gnome-terminal is required (close all the windows).
bash - wrong key sequence bindings with control+alt+space
1,466,555,813,000
I am connecting to an embedded Linux board using screen over a serial link and trying to change the terminal type, as the default vt100 is pretty restrictive in terms of colours and scrolling etc. The screen manual suggests the configuration option termcapinfo but using that doesn't fix the issue. On the host machine, TERM is set to xterm-256color and when I connect to the target, using the termcapinfo setting in my .screenrc, TERM is still set to vt100. I am thinking maybe I should set something on the target machine?
It's the remote machine that sets $TERM to vt100, because it cannot know what terminal emulator your connecting with. vt100 is a safe value as the majority of modern terminals and terminal emulators (including screen) are compatible. To tell the applications over there what your terminal actually is, you have to set $TERM explicitely: TERM=screen You can do: find $(infocmp -D) -printf '%f\n' | sort -u | grep screen to see if there are more appropriate entries like screen-256color.
Change terminal type for screen over a serial connection
1,466,555,813,000
When I hit the <s-f2> key to execute my nnoremap <s-f2> :set number! mapping Vim opens its "Insert" mode above (O) and types the 1;2Q string. In order to see the entire terminal key code – not eaten up half-way by the "Normal" mode – I hit <c-v><s-f2> in "Insert" mode and get ^[O1;2Q, where ^[ is the <esc> character. Even after reading the "Mapping fast keycodes in terminal Vim" I don't understand why the ^[O1;2Q terminal key code is not mapped to the <s-f1> Vim code. Therefore I defined the following function in my ~/.vimrc file: function! s:Mod_fix_shift_fkey() let a=0 let b='PQRS' while a < 4 exec 'set <s-f' . (a + 1) . ">=\eO1;2" . b[a] let a+=1 endwhile endfunction By calling it I fix the shifted function keys from <s-f1> to <s-f4> and the mapping bound to <s-f2> suddenly works. Can someone explain? Also I had to fix the shifted function keys from <s-f5> to <s-f12> like: "... let a=5 let b='1517181920212324' let c=0 while a < 16 exec 'set <s-f' . a . ">=\e[" . b[c : c + 1] . ';2~' let a+=1 let c+=2 endwhile "... And from <c-s-f1> to <c-s-f4> and <c-s-f5> to <c-s-f12> the control-shifted function keys like: " ... exec 'map <esc>O1;6' . b[a] ' <c-s-f' . (a + 1) . '>' " ... exec 'map <esc>[' . b[c : c + 1] . ';6~ <c-s-f' . a . '>' " ...
You can use a special wildcard syntax with :set <Key> to let Vim automatically recognize xterm-style modified keys: if &term =~ '^gnome' execute "set <xUp>=\e[1;*A" execute "set <xDown>=\e[1;*B" execute "set <xRight>=\e[1;*C" execute "set <xLeft>=\e[1;*D" execute "set <xHome>=\e[1;*H" execute "set <xEnd>=\e[1;*F" execute "set <PageUp>=\e[5;*~" execute "set <PageDown>=\e[6;*~" execute "set <F1>=\eOP" execute "set <F2>=\eOQ" execute "set <F3>=\eOR" execute "set <F4>=\eOS" execute "set <xF1>=\eO1;*P" execute "set <xF2>=\eO1;*Q" execute "set <xF3>=\eO1;*R" execute "set <xF4>=\eO1;*S" execute "set <F5>=\e[15;*~" execute "set <F6>=\e[17;*~" execute "set <F7>=\e[18;*~" execute "set <F8>=\e[19;*~" execute "set <F9>=\e[20;*~" execute "set <F10>=\e[21;*~" execute "set <F11>=\e[23;*~" execute "set <F12>=\e[24;*~" endif See :help xterm-function-keys and :help xterm-modifier-keys.
How to fix the shifted function keys in vim in xterm in gnome-terminal?
1,466,555,813,000
I am on Linux Mint 19.03 First of all, I can assure you that I have read most of the possible questions you might think this question of mine is a duplicate of. Now, I basically want to type something in my terminal window to open a new terminal window and execute the commands. Something like this: [the part I am asking of] "echo $PATH; read" This code should do open a new terminal, the $PATH variable should be displayed and read is just for halting the terminal. I tried x-terminal-emulator -e or x-terminal-emulator -c or -x but I could never achieve to do this correctly. All answers on this SE on the similar questions are both old answers and were using -e or -x but it says that those options are deprecated. So, what is the most proper way of achieving this? Thanks.
x-terminal-emulator doesn't start a shell by itself. This leafs just executables to be started with the -e option. While echo is available as an executable (/bin/echo), read as a bash internal command will fail without bash. Therefore the output in the new window is done faster than it takes to open the window and as read fails, the window is closed before you see it. This will do the trick: x-terminal-emulator -e "bash -c 'echo $PATH; read'" Now x-terminal-emulator starts a bash shell which then will execute echo $PATH; read. As echo and specially read now are available as bash internal commands, the read command will not fail and wait for an input, which keeps the window open until a key is pressed.
What is the command structure to open a new terminal and execute the given set on commands on this new terminal?
1,466,555,813,000
I have a script that I want to monitor its results and write them to a log file. I run the following: gnome-terminal -x bash -c "script logfile.log; ssh user@IP" But this command execute first the first command and after that the 2nd. Can I do them like in series without any input from me? to execute first the script command to write the logfile I want and after that the ssh without I need to do something else? I tried the way it is and it doesn't do what I want.
Have you tried having script be the outer part gnome-terminal -x script -c "ssh user@IP" logfile.log
Open a new terminal, monitor it and execute a script
1,466,555,813,000
I am using Debian Linux and I am setting some shortcuts on it. So in keyboard window I went to shortcut, added gnome-terminal, and set Ctrl + t as the keys. But in Debian we also have "Root Terminal" so we can open a terminal session as root. I want to set a shortcut for this. What command I should allocate to it?
Go to Keyboard window and in the Custom Shortcut part the command is: gksu gnome-terminal
Openning root terminal by keyboard shortcut
1,466,555,813,000
I'm in gnome-terminal on Linux Mint 13. (Mate) Whatever color scheme I set for the terminal overrides the color scheme i have set for Vim. How can i stop that from happening? I have read this: http://vim.wikia.com/wiki/256_colors_setup_for_console_Vim at 'Overriding the terminal's default terminfo', but it's very fuzzy and I simply can't use it to solve this. What is it that I actually do to override the terminal's color settings?
The important part of that wikia link is: :set t_Co=256 Entering this in normal mode (or putting it in your ~/.vimrc) will force vim to try to use 256 colors, which should override gnome-terminal's color scheme. Apparently, while gnome-terminal is capable to 256 colors, it doesn't advertise that fact in a way that vim can detect, which is why setting t_Co manually is often necessary. See also the vim help file for t_Co: http://vimdoc.sourceforge.net/htmldoc/term.html#t_Co
gnome-terminal overrides Vim color setting
1,466,555,813,000
To the disappointment of many, tab/window title can't be set anymore with --title I use bash. I have had a few aliases I have used to connect to remote servers with. alias c:prod='gnome-terminal --hide-menubar --profile=Production \ --title="Production Server" -e "ssh <url>" &' I found a workaround for GNOME 3.14+ to set title which works well in the command line once put in .bashrc function set-title() { if [[ -z "$ORIG" ]]; then ORIG=$PS1 fi TITLE="\[\e]2;$@\a\]" PS1=${ORIG}${TITLE} } However, this only seems to be effective if placed and called in the remote server's .bashrc i.e. I can only change the title after login. It has no effect, whatsoever if I attempt to change the title of the new window before connecting: alias c:prod='gnome-terminal --hide-menubar --profile=Production \ -e "bash -c \"source ~/.bashrc;set-title Production;ssh <url>\"" &' Setting window title on the remote feels wrong, when the terminal is running on my box, and I cannot make it work on servers either where my user does not happen to have a home directory to put a .bashrc in. Is there a forest I can't see for the trees?
Append set-title function to ~/.bashrc: function set-title() { if [[ -z "$ORIG" ]]; then ORIG=$PS1 fi TITLE="\[\e]2;$@\a\]" PS1=${ORIG}${TITLE} } Install expect, if you don't have it: sudo apt-get install expect Create ProductionServer.sh with content: #!/usr/bin/env expect spawn bash expect -re $ {send -- "set-title \"Production Server\"\rclear\rssh [email protected]\rclear\r"} interact exit Exec gnome-terminal with arguments: gnome-terminal --hide-menubar -e ~/ProductionServer.sh Maybe that process can be optimized, but problem already solved.
GNOME 3.14+ launch new gnome-terminal and set title
1,466,555,813,000
I am using a fairly recent version of Cinnamon (5.4.12), with desktop theme Adwaita-dark (and Adwaita sometimes). When I start a gnome-terminal window, it has a very thin (1px?) white border all around it. But as I like black terminals, I configured a black background to it, but now, I cannot see the window borders anymore. This also happens with other dark background applications. It can be very confusing to know which is which when terminal windows are overlapping, or even just next to one another. I tried to change this colour with no success: by searching in the theme files in /usr/share/themes/Adwaita, by playing with ~/.config/gtk-3.0/gtk.css to override some configuration, by reading other similar questions, but they are either outdated or not applying to my use case. So, how can I change the border colour of gnome-terminal (and possibly all other) windows to white?
What worked for me is adding this to the gtk.css file (which for me is located in ~/.config/gtk-3.0) decoration { border: 1px solid grey; background : grey; } It makes the border of the windows grey (or any color you want) instead of black. It applies to all GTK 3 apps, not just the terminal, but it does solve the terminal problem! The theme I'm running is Mint-Y Dark on Cinnamon 5.6.8 After modifying the file, reloading cinnamon will make the settings take effect: Alt-F2 | r | Enter
Change border color around window (edit GTK theme)
1,466,555,813,000
I am using tmux, and recently found out that the same vim colorshemes inside and outside of tmux have different colors Left is tmux in gnome-terminal, right is plain gnome-terminal, gnome-terminal has default colors: EDIT: At closer look, the style does change too (look at bold etc). Both terminals are 256-colored ones (gnome-terminal indicates himself as xterm-256color, tmux as tmux-256color, see ncurses-term package), vim sees that too (:set t_Co gives 256). I compared their color representations via for i in `seq 0 255` ; do echo -e "$i: \e[48;5;${i}m \e[0m"; done And got the same palettes: I think tmux should just pass these colors to gnome-terminal, but when why vim changes? Can I fix this? I think gnome-terminal ones are better, and want tmux to use them.
For some reason, it was just a Vim issue: when started in tmux, it loaded default colorsheme, but when started from plain terminal, it loaded desert colorscheme but still calling it default when asked via :colorsheme. Forcing :colorsheme default resolved an issue, so I added colorsheme line in my ~/.vimrc and now it's OK. I have no idea why Vim was doing that stuff, but forcing desired colorsheme works fine.
Different vim colors and styles in Tmux and Gnome
1,466,555,813,000
Vim scripts sometimes resize the whole shell (in my case the Taglist plugin). I don't want this behavior, which is possible with the shell command resize, too. Is there a way to suppress the whole resizing in shell windows? Any .*rc files to tune? I'm using gnome-terminal.
To fix your Taglist issue, add the following somewhere in your .vimrc: let Tlist_Inc_Winwidth=0 From the VIM documentation: Window resizing with xterm only works if the allowWindowOps resource is enabled. On some systems and versions of xterm it's disabled by default because someone thought it would be a security issue. It's not clear if this is actually the case. To overrule the default, put this line in your ~/.Xdefaults or ~/.Xresources: XTerm*allowWindowOps: true (note: this actually ENABLES it, you want to DISABLE, ie: false) And run "xrdb -merge .Xresources" to make it effective. You can check the value with the context menu (right mouse button while CTRL key is pressed), there should be a tick at allow-window-ops. From my own experience with the Xresources, if you drop the 'XTerm' part, and just lead with the asterisk, it should also apply for any gnome terminals too. The gnome terminal has it's particular prefix, but I don't know it, maybe someone could comment with that info, but the *allowWindowOps: false line should help.
How can I disable terminal resizing
1,466,555,813,000
I would like to have a command or script that opens a new gnome-terminal window with bash and loads a history file and stays open. I searched for how to open a terminal and execute a command without it closing, and the answers I found are essentially summarized in this stackoverflow answer. Based on these methods, I tried running the following command: gnome-terminal -e "bash -c 'history -r ~/history.txt; exec $SHELL'" However, the history that appears in the new window is not the one in history.txt but the one in the default file, .bash_history. I thought since after the history -r command I am executing bash, and that sources the .bashrc file, maybe .bashrc is doing something that affects the history I loaded. Based on that, I tried the rcfile option in the answer linked above, so that I can include commands after .bashrc, resulting in the following rcfile: FILE=~/.bashrc && test -f $FILE && source $FILE history -c && history -r ~/history.txt However, when I run the following command: gnome-terminal -e "bash --rcfile rcfile" The history in the new terminal is still the one from .bash_history. If I add the history command to the rcfile it shows that the history from history.txt was loaded, so something after the rcfile is overwriting the history I load. I also found that if I unset the HISTFILE variable with export HISTFILE='' at the end of the rcfile, the history from history.txt is not overwritten and works. However, I do not want to unset HISTFILE because I do want the history to be saved to .bash_history when I use the newly opened terminal. Finally, I found the -o option in bash, so I tried doing what I want with that. I changed my rcfile to: FILE=~/.bashrc && test -f $FILE && source $FILE history -c && history -r ~/saved/history.txt set -o history and ran the following command: bash --rcfile rcfile.txt +o history I was hoping that running bash with +o history would prevent the history from history.txt from being overwritten, while the set -o history command in the rcfile would reactivate the bash history. However, this also does not work as intended, as the history is the one from history.txt but then there is no more history logging and I have to manually enter set -o history for it to work. So basically, everything I tried brings me back to the same question: how do I open the new terminal with bash and then execute a command, as if a user were entering it? Additionally, I would like a better understanding of what is happening after the rcfile is executed, as I wasn't able to find any other relevant file that was being sourced. And is there a way of disabling that behavior from the command line?
I managed to find a workaround using the PROMPT_COMMAND variable and the rcfile.txt file mentioned in the question. You can run the command gnome-terminal -e "bash --rcfile rcfile.txt" Where the contents of rcfile.txt are the following: FILE=~/.bashrc && test -f $FILE && source $FILE my_init_func() { # Insert desired commands here. In my case, history -r history.txt PROMPT_COMMAND=`echo $1` eval $PROMPT_COMMAND unset -f $FUNCNAME } PROMPT_COMMAND="my_init_func \'$PROMPT_COMMAND\'" What this does is source the default .bashrc if it exists in order to keep any other terminal configurations. Then, it defines a function that will run once when calling the PROMPT_COMMAND used in bash, then will unset itself and restore the original PROMPT_COMMAND.
How do I open a terminal window and execute a command after the shell has opened?
1,466,555,813,000
I suddenly cannot open a gnome-terminal window in Linux Mint. I installed xterm and guake too now looking for a replacement, but none of them will open either. When I do try to open gnome-terminal by any method, the window will flash on the screen, but then it instantly closes before I can really see anything. My .xsession-error file is completely full of different messages, but the following is an example of what seems to be triggered directly when I try to open gnome-terminal. Window manager warning: Log level 16: /build/buildd/glib2.0-2.36.0/./gobject/gsignal.c:2593: instance `0xacf1710' has no handler with id `17056' Window manager warning: Log level 16: /build/buildd/glib2.0-2.36.0/./gobject/gsignal.c:2593: instance `0xacf1710' has no handler with id `17057' Window manager warning: Log level 16: /build/buildd/glib2.0-2.36.0/./gobject/gsignal.c:2593: instance `0xaa1ae80' has no handler with id `17102' Window manager warning: Log level 16: /build/buildd/glib2.0-2.36.0/./gobject/gsignal.c:2593: instance `0xaa1ae80' has no handler with id `17103' JS ERROR: !!! Exception was: Error: got a _calcWindowNumber callback but this._appButton is undefined JS ERROR: !!! Exception was a String JS LOG: AppTrackerError: get_window_app returned null and there was no record of metaWindow in internal database Guake behaves similarly. With xterm, I see nothing at all... no window and no new error messages. The eshell inside emacs and the command executer associated with Alt+F2 both seem to be working fine.
I eventually found the answer on my own. I had done something to my /etc/passwd/ file, without really understanding what I was doing. Restoring that seems to have fixed the problem.
Suddenly cannot open any terminal on Linux Mint
1,466,555,813,000
I want to be able to name a terminal tab so I can keep track of which one is which. I found this function (here) and put it in my .bashrc: function set-title() { if [[ -z "$ORIG" ]]; then ORIG=$PS1 fi TITLE="\[\e]2;$*\a\]" PS1=${ORIG}${TITLE} } and now when I call set-title my new tab name the tab name is changed as expected to "my new tab name". The problem is that I want to open a new tab and name it using set-title. The way I have tried to do this, is like this: gnome-terminal --geometry=261x25-0+0 --tab -e "bash -c 'set-title tab1; sleep 10'" --tab -e "bash -c 'set-title tab2; sleep 10" However, now I get the following error message: bash: set-title: command not found And I think this is to do with the new gnome tab not knowing about the .bashrc function yet. How can I get this to work?
Instant of using function set-title you can create command with this functionality, so remove function set-title() that you add from ~/.bashrc and create a file /usr/local/bin/set-title: #!/bin/bash echo -ne "\033]0;$1\007" Add chmod: chmod +x /usr/local/bin/set-title. And after you re-open terminal you can use this command by: set-title TEST (If you have /usr/local/bin/ in your $PATH). And then you can use it when creating new tab by this way: gnome-terminal --geometry=261x25-0+0 \ --tab -e "bash -c 'set-title TAB1; sleep 10'" \ --tab -e "bash -c 'set-title TAB2; sleep 10'" If you somehow don't have /usr/local/bin/ in your $PATH, you can try with absolute path to the set-title command: --tab -e "bash -c '/usr/local/bin/set-title TAB1; sleep 10'"
Call a .bashrc function from a bash shell script
1,466,555,813,000
I'm trying to have transparency working for Gnome Terminal. However this is what I get when I try to edit the profile of gnome-temrinal: there's no background tab where I can set the opacity !? I am using NixOs, this is what I have in my pkgs.nix file: environment.systemPackages = with pkgs; [ # ... gnome3.gnome_terminal gnome3.gconf # I have put it just in case it could help ] Any idea what I should install or configure so as to unlock the background transparency option ?
The GNOME terminal FAQ states: How can I make the terminal transparent? Since version 3.7 (NixOS master currently contains version 3.26) this option has been removed from the Preferences dialogue. You can however still get the same effect by setting the _NET_WM_WINDOW_OPACITY X property, for example with the Devil's Pie or Devil's Pie II tools. E.g., set up Devil's Pie to start automatically with the session, and create the file ~/.devilspie/gnome-terminal.ds with these contents: (if (matches (window_name) "gnome-terminal-window-*") (opacity 90) ) You can also use this shell script that however only works for existing terminal windows and not automatically for newly created ones. - https://wiki.gnome.org/Apps/Terminal/FAQ#How_can_I_make_the_terminal_transparent.3F
Background transparency for Gnome Terminal
1,466,555,813,000
I use neovim in tmux in gnome-terminal on Fedora 25. Here I found out, that I do not have true color support because terminal is not linked to some libvte of correct version. Since many nvim color schemes need true color support (and also I want this from a general perspective) I'd like to activate it! However, the posted site only refers to the ppa (which as I imagine are ubuntu-repos). So my question: How do I activate true colors in gnome-terminal on fedora 25?
Those instructions do not actually provide the correct test for the version of libvte used on Fedora, since our gnome-terminal-server is in /usr/libexec. Instead, I'd suggest $ rpm -qR gnome-terminal|grep vte libvte-2.91.so.0()(64bit) vte291(x86-64) >= 0.46.0 Here, we see that 0.46.0 is greater than the 0.36 your tutorial says is required, so this is not your problem. In fact, check this out: $ echo $COLORTERM truecolor TrueColor is already enabled out of the box on Fedora 25 Workstation. $COLORTERM is also truecolor inside of tmux. In fact, this blog post has a simple test script with which I verified that TrueColor is in fact working both outside and inside tmux with no further configuration. So, this is down to neovim configuration. To make it work in current versions, you need set termguicolors in your ~/.config/nvim/init.vim. (In versions before May 2016, set the environment variable NVIM_TUI_ENABLE_TRUE_COLOR to 1.) This is documented in the neovim log of "breaking changes".
Enable true color for neovim in Fedora 25
1,466,555,813,000
I'm new to Linux and so far,I have come to understand that if we open a new process through a gnome-terminal eg: gedit & "& for running it in background", then if we close the terminal, gedit exits as well. So, to avoid this ,we disown the process from the parent terminal by giving the process id of gedit. But, I've come across one peculiarity; If we open a gnome-terminal from within a gnome-terminal(parent) with gnome-terminal & and now, if we close the parent terminal, the child terminal doesn't close even if I haven't disowned it. Why is it? And if there is an exception, what is the reason for making it an exception and where can I find the configuration file(if accessible) where this exception has been mentioned?
When you close a GNOME Terminal window, the shell process (or the process of whatever command you instructed Terminal to run) is sent the SIGHUP signal. A process can catch SIGHUP, which means a specified function gets called, and most shells do catch it. Bash will react to a SIGHUP by sending SIGHUP to each of its background processes (except those that have been disowned). Looking at your example with gedit (with some help from pstree and strace): When the GNOME Terminal window is closed, gedit is sent SIGHUP by the shell, and since it doesn't catch SIGHUP (and doesn't ignore it), gedit will immediately exit. ─gnome-terminal(31486)─bash(31494)──gedit(31530) [31486] getpgid(0x7b06) = 31494 [31486] kill(-31494, SIGHUP) = 0 [31494] --- SIGHUP {si_signo=SIGHUP, si_code=SI_USER, si_pid=31486, si_uid=0} --- [31494] kill(-31530, SIGHUP) = 0 [31530] --- SIGHUP {si_signo=SIGHUP, si_code=SI_USER, si_pid=31494, si_uid=0} --- [31530] +++ killed by SIGHUP +++ [31494] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=31530, si_status=SIGHUP} --- [31486] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=31494, si_status=SIGHUP} --- But when you type the gnome-terminal command and there is an existing GNOME Terminal window, by default GNOME Terminal will do something a bit unusual: it will call the factory org.gnome.Terminal.Factory via D-Bus, and immediately exit; there is no background job for the shell to see for more than a fraction of a second. As a result of that factory call, the new window you get after typing gnome-terminal is managed by a new thread of the same GNOME Terminal process that is managing your existing window. Your first shell is unaware of the process id of the second shell, and cannot automatically kill it. ─gnome-terminal(9063)─┬─bash(39548) │ └─bash(39651) ├─{gnome-terminal}(9068) └─{gnome-terminal}(9070) On the other hand, if you type gnome-terminal --disable-factory &, it won't call the factory, and process-wise it will behave just like gedit did in your example. ─gnome-terminal(39817)──bash(39825)──gnome-terminal(39867)──bash(39874) │ ├─{gnome-terminal}(39868) │ └─{gnome-terminal}(39819) Closing the first terminal window will close both the first and the second terminal windows.
closing parent process(terminal) doesn't close a specific child process
1,397,869,062,000
I am starting a process in a tmux window in a terminal window. When I close the terminal window, the process not killing automatically but If I kill tmux window before close terminal window, the process killing. How can I kill related tmux window when the terminal window closed ? Can we bind commands the close event of the terminal window ?
This is a bit of a hack but you could add this to your interactive shell configuration: alias tmuxn='tmux new-session -s $$' _trap_exit() { tmux kill-session -t $$; } trap _trap_exit EXIT Then you can use tmuxn to start a new session. The session will be named as your shell's PID. When your shell exits, the session will be killed.
How to kill tmux window automatically when terminal window closed?
1,397,869,062,000
When running an interactive shell application, how can I send it a key (or key combination) which would normally be intercepted by GNOME Terminal? In this particular instance it's the F10 key which is intercepted. Bonus points for a general-purpose solution which would work for things like Alt, PgUp and Alt-Tab (might be useful for a shell script to configure shortcut commands) or in other terminals as well.
You can try disable the gnome shortcuts in Edit -> Keyboard shortcuts, so the window won't eat up the function keys. There seems to be a known gnome-terminal bug relating to this. Alternatively if this doesn't work, you will have to use another terminal that explicitly sends function keys as control codes to the terminal. rxvt is one I can recommend, or xterm.
How to bypass GNOME Terminal when sending keyboard input?
1,397,869,062,000
I use ZSH and after I type cd command and press Tab I get '@' symbol after some particular entries Why is it so?
What you're seeing is the effect of the LIST_TYPES shell option. From the Completion section of man zshoptions: LIST_TYPES (-X) <D> When listing files that are possible completions, show the type of each file with a trailing identifying mark. The "trailing identifying mark" appears to follow the same convention as the -F option of ls (aka --classify in GNU ls) i.e. @ indicates that the completion is a symbolic link. You'll find it also happens by default in completion listings in the tcsh shell from which zsh borrowed a few interactive features. You can turn off this behavior using unsetopt list_types or set +o list_types if you prefer the standard way to turn options on/off.
In ZSH @ symbol appears during autocompletion of cd command
1,397,869,062,000
I have several reasons to think that my terminal behaves like a console. I use GNOME Terminal 3.18.3. When I open vim from my terminal on fedora 23, the following warning is emitted: "Vim: Warning: Output is not to a terminal". When I open the manual for a command, it does not switch the terminal in "reading" mode. What I mean by that is that it does not put me on the manual page where I could scroll using HJKL and quit using q. Instead, it just prints the content of the manual as the result of a command like ls in one fell swoop. Commands like ls are not colored. I think this happened after I tried using my computer using Ctrl+Alt+F3 (from the console). How can I set my terminal back to its previous state?
You are likely (attempting) to redirect the output of your shell to a file, e.g., something like bash -i | tee foo $ vim Vim: Warning: Output is not to a terminal While you can read (most) commands from the keyboard via that approach, the output is no longer a terminal. You can recover by closing that shell and capturing output in a different way: the script command can capture output sent to a terminal without interfering with it. For example script -c bash foo will write all of the text sent to the terminal while running that bash command, and the output will still be a terminal (rather than a pipe or a file). Further reading: script - make typescript of terminal session
Vim in Gnome-terminal says “Output is not to a terminal”
1,397,869,062,000
I forked an open source project to work on but one of the folder names I want to cd into starts with an emoji. How can I enter into it? I know I can use the GUI to look through the folder but I rather prefer using the terminal. I'm using Ubuntu 18.04.4 LTS
Option 1: type the emoji Simple typing cd '🔥 100 DISTRICT ATTORNEYS 🔥' will suffice. Searching up "how to insert emoji in X" is usually more than enough to get you started on typing emojis in your environment. If you don't want to set up emoji insertion, you can always copy-paste from the web (searching "fire emoji" is all you need). Option 2: wildcard In all honesty, nobody expects you to make a search every time you want to insert a special character. You can also use the wildcard character like so: cd *'100 DISTRICT ATTORNEYS'* Which will search for a file/folder that has "100 DISTRICT ATTORNEYS" in the middle and any characters on the sides. In this case, the only directory that matches is the one you want to enter. Read more about the * wildcard here, and more about all the types of wildcards in bash here. Option 3: tab completion Okay, we're getting pretty desparate here, but tab completion is worth a mention. Although it may not be viable for your specific situation, in a directory that looks like so (and a situation in which you'd like to enter the ENTER 🔥 directory): | A | B | C | ENTER 🔥 Simply typing: $ cd E<tab> will autocomplete (validly) to the only directory that starts with the letter E. In reality, I like to type a few letters in before pressing tab, for good measure. Read more about tab completion here.
cd into folder name that starts with an emoji
1,397,869,062,000
I wrote this script to create multiple tabs in the same terminal window and run commands in them: #!/bin/bash #Use the commands as: #--tab-with-profile=Default --title=<SPECIFY THE TAB TITLE HERE> -e "bash -ic \"<SPECIFY THE COMMAND YOU WANT TO RUN HERE>; bash\"" \ #The ampersand in the end of this file makes sure that the gnome-terminal command is run as a background process echo "Setting up simulator environment"; service mysqld start; gnome-terminal \ --tab-with-profile=Default --title=PROG1 -e "bash -ic \"clear;ls;./prog1; bash disown\"" \ --tab-with-profile=Default --title=SIMULATOR -e "bash -ic \"clear;ls;./simulator; bash disown\"" \ --tab-with-profile=Default --title=PROG2 -e "bash -ic \"clear;ls;./prog2; bash disown\"" \ --tab-with-profile=Default --title=DATA -e "bash -ic \"./data -f \"/home/user/NetBeansProjects/data3.txt\" -p \"6785\"; bash disown\"" \ --tab-with-profile=Default --title=PROG3 -e "bash -ic \"cd /home/user/NetBeansProjects/simulator;./prog3; bash disown\"" \ & Problem is, when any of those programs finish running or if I press Ctrl+c to stop any of those programs, the tab closes. I don't want the tab to close. I want the tab to remain open and the bash terminal to be shown so that I can run some other command in the tab. Is there a way to make that happen?
There are two problems; The first one is that inside each bash -ic command (which by the way doesn't spawn an interactive shell because -c overrides -i, so -i it's safe to be dropped) you're calling bash disown instead of bash, which means nothing and immediately exits on error; so there's no interactive shell keep running that keeps gnome-terminal opened at the end of the outer bash -c command; (Also mind that you could use exec bash instead of bash at the end of the command, to save some processes.) The second one is that Ctrl+C SIGINTs all the processess in the same group of the killed process, including the parent bash instance which is supposed to spawn the interactive shell at the end of the command; To fix this, you can use bash's trap built-in to set bash to spawn another interactive bash instance upon the reception of a SIGINT signal. In short, this should work: gnome-terminal \ --tab-with-profile=Default --title=PROG1 -e "bash -c \"trap 'bash' 2; clear;ls;./prog1; exec bash\"" \ --tab-with-profile=Default --title=SIMULATOR -e "bash -c \"trap 'bash' 2; clear;ls;./simulator; exec bash\"" \ --tab-with-profile=Default --title=PROG2 -e "bash -c \"trap 'bash' 2; clear;ls;./prog2; exec bash\"" \ --tab-with-profile=Default --title=DATA -e "bash -c \"trap 'bash' 2; ./data -f \"/home/user/NetBeansProjects/data3.txt\" -p \"6785\"; exec bash\"" \ --tab-with-profile=Default --title=PROG3 -e "bash -c \"trap 'bash' 2; cd /home/user/NetBeansProjects/simulator;./prog3; exec bash\"" \ &
Run commands in a terminal, then let me type more commands
1,397,869,062,000
When I enter a command with a long output such as locate linux, the output is too long to show on the current terminal screen, and so the terminal will scroll right to the end of the output. How can I disable this behavior, such that window stays on the first line of the output? Alternatively, is there a way to get the window back to the last $ line without having to actually look for where that line is? I have tried Edit > Profile Preferences > Scrolling and disabling Scroll on output, although this does not achieve what I am trying to do.
Short answer: you can't, at least not exactly the way you want. More useful answer: you can achieve what you want by piping the output to something like more or less , for example : locate linux | less This will pause the output scroll at the end of each page, where the page length is defined as the terminal height.
How can I disable auto scrolling in gnome terminal?
1,397,869,062,000
I tried using crontab -l from my terminal as root, it showed no crontab for root. So I tried crontab -e, it returns the following no crontab for root - using an empty one 888 and then the cursor starts blinking. I am not able to quit or save the file.
When you run the command crontab -e it typically defaults to the vi or vim editors. If you type the command Shift+Z+Z you can save any changes in this editor and exit. To add entries to your crontab using this method you'll need to learn how to use this editor more extensively, which is beyond the scope of this question, and should be easy to find many tutorials on the internet. If vi/vim is too much of a learning curve you can instruct crontab to use a different editor. Another console based editor that's easier for new people to Linux is nano, it's typically installed on most distros that I'm familiar with. $ EDITOR=nano crontab -e NOTE: To use nano's menu all the carets (aka ^X) commands at the bottom require the use of the Ctrl key. So to exit, Ctrl+X, for example. You can of course use any editor here. A easy GUI based editor, if you're using a GNOME based desktop, would be gedit: $ EDITOR=gedit crontab -e This last one might be a challenge to use, for a different set of reasons, if your primary desktop is being run by a user other than root, which it likely is, so I would go with nano for starters.
Crontab suspicious activity
1,397,869,062,000
I am on arch-linux and just upgraded to the latest version of gnome-terminal. I used to have both the terminal colour and theme set by gnome-tweak-tool having Global Dark Theme turned on. Does anyone know how to change this back without downgrading my terminal. You can see here what the terminal now looks like, and a window that looks correct. I downgraded my terminal to the last one that did not do this, so the problem is somewhere between: gnome-terminal 3.12.0-1 and 3.10.2-1 (3.10.2-1 is the working one, these are from the arch package manager).
Have you set gnome-terminal to use dark theme in the preferences of it?
Why did an update to gnome-terminal break my system-colours and how do I fix it?
1,397,869,062,000
Is it possible to set a custom icon for gnome-terminal, maybe dependent on the profile. I often have many terminal windows open and it gets a bit tricky to distinguish between them.
No. The icon for gnome-terminal is set at the C level and does not provide for any customization. You will need to use xseticon to change it externally.
Set a custom icon for gnome-terminal
1,397,869,062,000
I use the vim-mark plugin, which allows me to make multiple highlights of different colours. It has some default key maps that uses the numeric keypad (<k1> ... <k9> and <C-k1> ... <C-k9>), which allows me to jump back and forth among occurrences of highlights. Currently, the key maps only work in gvim, but gvim comes with its own rendering quirks, which I will not expand on. If I try to use the numeric keypad in plain vim in GNOME Terminal, vim receives keycodes of the digits above the letters on the keyboard and doesn't do the jumps among highlight occurrences. Is there a way to make GNOME Terminal send the real numeric keypad keycodes to vim? I really don't want to change the default key maps of the plugin because any other key maps will either be less memorable or pretty much guarantee the need for more key presses.
GNOME Terminal, as every terminal emulator maps the keysyms it receives from X (or whatever display server you are using) into characters or escape sequences. Unfortunately it has a fixed mapping with no space for configuration. The keypad can work in two modes: when it is in normal mode it sends the same characters as the digits in the upper row. However, if it is in application mode it send escape sequences. GNOME Terminal's mapping for both modes is the same, whereas vim expects to see the following escape sequences (check with :set termcap): t_KC <k0> ^[O*p t_KD <k1> ^[O*q t_KE <k2> ^[O*r t_KF <k3> ^[O*s t_KG <k4> ^[O*t t_KH <k5> ^[O*u t_KI <k6> ^[O*v t_KJ <k7> ^[O*w t_KK <k8> ^[O*x t_KL <k9> ^[O*y In order to use those shortcut keys you need a terminal, which correctly sends escape sequences when in application mode. You might for example use xterm and switch it into VT220-style function keys, by adding: XTerm.sunKeyboard: true to your ~/.Xresources. Edit: If you want to recompile libvte you should probably modify the entries to something like: static const struct _vte_keymap_entry _vte_keymap_GDK_KP_0[] = { {cursor_all, keypad_all, 0, "0", 1}, {cursor_all, keypad_app, VTE_NUMLOCK_MASK, "0", 1}, {cursor_all, keypad_app, 0, _VTE_CAP_SS3 "p", -1}, {cursor_all, keypad_all, 0, X_NULL, 0}, }; and send the patch to GNOME.
Make GNOME Terminal send correct numeric keypad keycodes to vim
1,397,869,062,000
When I use a link in my terminal emulator (I am using Gnome Terminal), it's being highlighted as link and if I click it it is opened in the browser. Is it possible to have a text (e.g. Hello World) and when I click it to open an url (e.g. http://example.com)? Is it possible to do this with some ANSI black magic?
No. Those links are created by Gnome Terminal when it notices certain patterns in the terminal buffer - e.g. patterns for http:// or ftp:// etc URLs.
Does ANSI support links on text?
1,397,869,062,000
Here is what I am trying to do: open Gnome terminal launches with my command prompt ssh into work via VPN launch screen create two screen windows try to use F3 and F4 as "prev" and "next" with no luck. try to use F6 and F7 as "prev" and "next" works fine. Here is my .screenrc hardstatus on hardstatus alwayslastline hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a " defscrollback 5000 startup_message off #bind uppercas x to remove region bind X remove bind ^X lockscreen # Bind F3 and F4 (NOT F1 and F2) to previous and next screen window bindkey -k k3 prev bindkey -k k4 next # Bind F5 to switch to next focus bindkey -k k5 focus bindkey -k k6 prev bindkey -k k7 next #split window bindkey -k k8 split bindkey -k k9 remove What's strange is the following works: Works 1: Doing this via putty works fine Works 2: using the exact same .screenrc works fine if I am on my local machine Doesn't work: using lxterminal has the same issue My thoughts are that ssh may be causing this but not sure. EDIT: Here are the outputs of some terminal related commands: Local Machine: $ echo $TERM xterm $ infocmp -1 | grep kf.= kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, Work Machine: $ echo $TERM xterm $ infocmp -1 | grep kf.= kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, Work Machine using screen: $ echo $TERM screen $ infocmp -1 | grep kf.= kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
I think I know what it is. xterm used to send different escape sequences for the F1 to F4 keys. From the xterm documentation: Older versions of xterm implement different escape sequences for F1 through F4. These can be activated by setting the oldXtermFKeys resource. However, since they do not correspond to any hardware termi- nal, they have been deprecated. (The DEC VT220 reserves F1 through F5 for local functions such as Setup). screen used (and you've got quite an old versions, though we would blame you as the newer ones are not official releases) to come with a default /etc/screenrc with: termcapinfo xterm 'k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~' That is that tell screen that F1 -> F4 are actually what they used to be in ancient xterms. You should comment out that line in your /etc/screenrc, so that screen takes it from the terminfo/termcap database as expected.
How do I fix this strange behavior with ssh, gnome terminal and gnu screen where function keys F1 through F4 are not accepted?
1,397,869,062,000
I find the manuals very difficult to read using the terminal. Is there a way to highlight specific text on the terminal? I tried piping to gedit using man man | gedit, but it opens a blank file instead. Perhaps there's some way to find text within a man page and have it highlighted?
Dumping to clear text You can use this technique to dump a man page out to a text file. $ man -P cat ls > manpg_ls.txt The above technique is just changing what pager man uses. Here we're telling it to use the cat command instead. We then get the man page for the ls command dumped to a file in clear text. Example Here's the first 10 lines of the ls man page. $ man -P cat ls | head -10 LS(1) User Commands LS(1) NAME ls - list directory contents SYNOPSIS ls [OPTION]... [FILE]... Searching Another approach is to use alternative pager commands and functions to search through man pages. Several techniques are covered in this U&L Q&A, titled: Reading and searching long man pages.
How to highlight some text on a man page? [duplicate]
1,397,869,062,000
I have a zip base.zip and inside the file there is 2 subdirectory. base.zip ├── subA │ └── fileA1.txt │ ├── subB │ └── fileB2.jpg │ └── k.jpg I want to add a file in the subA without extract the base.zip and create a new one zip file, i need to do in the terminal. I read that I can update a zip file with the command zip -ur base.zip test.txt But with this command the file is just add to the main directory in the zip file. How can I do from terminal?It's possible to do because one time I just added a file in a sub directory but with the Archivie Manager on the desktop.
Create a subdirectory named subA in your current directory. Put the file you want to add in that subdirectory. mkdir subA cp -p file-to-add.txt subA Then execute: zip base.zip subA/file-to-add.txt
Add file in a sub directory of a zip
1,397,869,062,000
I just installed a fresh copy of Debian 8.4 in VirtualBox 5.0.20. I am now attempting to install the "Guest Additions" CD. To do so I had to change my fstab so I am able to execute things from the CD, so this is already fixed. But now I get the following error: root@debian:/media/cdrom# ./autorun.sh Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: The connection is closed Can someone please help?
Change the permissions in fstab back to the default. As a normal user: sudo apt-get update && sudo apt-get upgrade && sudo apt-get install build-essential module-assistant sudo m-a prepare Mount the Guest Additions CD using the VirtualBox Menu (sudo mount /media/cdrom) sudo sh /media/cdrom/VBoxLinuxAdditions.run If the error you noted still occurs, make sure your Virtual Network Adapter is Enabled, like so:
"Error constructing proxy" on gnome terminal
1,397,869,062,000
On Ubuntu 14.04, in bash under gnome terminal, Why are files especially directories colored in different ways? The green colors hide the text to me (How about to you?). Is it done by terminal or bash? Is it a design for some purpose? Can we change the color that hide the text?
The colours are set by ls, using the LS_COLORS environment variable. To change the colours, you can use dircolors. dircolors --print-database outputs the current source settings, which you can store in a file and adapt; then dircolors ${file} will output the processed LS_COLORS value for you using the settings in ${file}. Strictly speaking ls outputs colour codes, and these are mapped to colours by the terminal; there's a more-or-less standard palette (see Wikipedia for details) but there are slight differences from one terminal to another. So you can change the codes ls outputs using dircolors, and you can often adjust the terminal's palette as well, but that would affect all colour-using programs you'd run in the terminal. As to the design, I suppose the default colours are those the ls maintainers like...
Why are files and directories colored in different ways? [duplicate]
1,397,869,062,000
I source vte.sh in my .bashrc. One thing this does is it causes Bash to echo "\033]7;file://$HOSTNAME$PWD\007" as part of PROMPT_COMMAND. This uses the escape sequence "OSC 7" to send a value like file://mylocalbox/home/kerrick to the terminal, telling it what the current hostname and directory are. When you open a new tab in GNOME Terminal, it uses the information from OSC 7 to open the terminal in the same directory as the previous tab. I would like to configure GNOME Terminal so that if the current tab is running a SSH session, launching a new tab will SSH into the same host and change to the same directory. In other words, if the OSC 7 value is something like file://myremotebox/foo/bar, it will run exec ssh -t myremotebox 'cd /foo/bar && exec bash -l' instead of a default terminal session. How can I configure GNOME Terminal to do this?
It doesn't support this feature, you'd need to modify its source code. It's probably a reasonably straightforward task, if you're somewhat used to touching foreign C++ code. Note: While you can certainly come up with a patch that works in a significant amount of cases, there will always be cases that cannot be handled 100% reliably. Maybe the remote username differs from the local one. The username is not part of the OSC 7 sequence, so you cannot tell what the remote username is. Maybe the remote hostname (as the remote host calls itself) cannot be used on the local host to resolve to its address. Maybe the site was reached via multiple ssh hops. Maybe sshd is running on a nondefault port. Maybe it's not ssh but old-fashioned rsh / telnet or something alike. Probably there's more... Cases like these would hardly make such a feature eligible for mainstream inclusion, it would just break too often (especially the username mismatch is a valid concern in practice). OSC 7 gives you partial information about where you are, whereas what you'd need is how to get there.
How can I configure GNOME Terminal to launch new tabs with the same SSH host and directory as the current tab?
1,397,869,062,000
I'm working in a remote server that uses Scientific Linux (version=7.6 (Nitrogen)). I did a simple web application in Python3, and I found myself constantly opening a Mate Terminal (though, any terminal works), and writing bash python3 my_app.py So, I can check if my app works locally in my browser. I want a way to make this easier, and just click a shell script that opens a terminal windows and runs the commands mentioned. After that, the terminal window should remain open and I should be able to check my web application in the browser. I wrote a shell script with this line: gnome-terminal --tab --title="tab 1" --command="bash -c 'python3 my_app.py; $SHELL'" As recommended here, in the case of Ubuntu: https://askubuntu.com/questions/46627/how-can-i-make-a-script-that-opens-terminal-windows-and-executes-commands-in-the (Note: I tried all other answers and they didn't work, Gabriel Staples answer was the only one that almost worked). I also allowed the file to be executed as program. There are 2 problems with this solution. First, the terminal does not remain open. Second, when I click the file I received the following message (before terminal is closed): ModuleNotFoundError: No module named 'flask'. This is because the script is using the wrong version of python3 in this server. There is one installed by the admin, and the anaconda version installed by me in my home directory. I've been getting around this problem by writing bash before using python3 my_app.py. It seems that after I use bash the file .bashrc in my home directory is used, and the variable $PATH gives priority to my version of python3 (I checked that $PATH is different before and after I write bash in the terminal). I was wondering if there is a way to make a script (on Scientific Linux) that opens a terminal window and executes commands in them, and after that remains open. I also was wondering if there is a way that the web application automatically pops up in my browser after this.
The terminal will close after the command is completed. To leave the terminal open, I generally prevent the script from completing, e.g. with a prompt as follows: while [[ \$response != q ]]; do read -n 1 -p [q]uit? response; echo; done Hence, for your script, append this to the end of the bash -c command. gnome-terminal --tab --title="tab 1" --command="bash -c 'python3 my_app.py; $SHELL'; 'while [[ \$response != q ]]; do read -n 1 -p [q]uit? response; echo; done'" For the wrong python being used, you can either load ~/.bashrc by using bash -i, or you could explicitly specify the python version with /path/to/python3 instead of plain python3 in your command. Hence, your final command is either gnome-terminal --tab --title="tab 1" --command="bash -ci 'python3 my_app.py; $SHELL'; 'while [[ \$response != q ]]; do read -n 1 -p [q]uit? response; echo; done'" or gnome-terminal --tab --title="tab 1" --command="bash -c '/path/to/python3 my_app.py; $SHELL'; 'while [[ \$response != q ]]; do read -n 1 -p [q]uit? response; echo; done'"
How can I make a script that opens terminal window, executes commands in it and remains open on Scientific Linux?
1,397,869,062,000
I have some binaries and some .c extension files in my directory. Here the output using ls arrays.c basic0 basic0.c fromfb fromfb.c oute oute.c segmen.c simp simp.c Here i want to filter binary files only , so I use ls |grep -v .c This command list all files, Then using grep I get files, except those file not ending with .c What I expect is basic0 fromfb oute simp But What i got fromfb oute simp basic0 binary file missing. What is the problem with this?
As per man grep The period . matches any single character. thus grep .c match any character followed by c You might be looking for grep -v \.c or better grep -v '\.c$' where \. escape special meaning of . c $ end of line (when piped to ls output one file name par line) as suggested by wildcard, you can also use grep -vF .c The -F flag tells grep to use arg as simple string, not regular expression.
grep with special expressions [duplicate]
1,397,869,062,000
After I add the following command to my ~/.tcshrc: echo "\033]0;${PROJECT_NAME}\007" The less command in a new gnome-terminal stops working properly. But more command is not affected. This is what I see when trying to run less command: less log ESC]0;MYPROJ^G log (END)
Your less is probably configured to pipe its output through lesspipe or a similar script. This happens if environment variable LESSOPEN and/or LESSCLOSE is set, or an equivalent setting is used in the ~/.lesskey file. The output from your ~/.tcshrc is mixing in with the piped data and causing confusion. Your ~/.tcshrc apparently runs the command you added also when executed for a shell that does not have a TTY. This causes the problem you're seeing, and may also cause problems with scp, rsync or many other commands. If you want to add a command that produces screen output to your .tcshrc or similar shell startup script, you should always make the command conditional so that it runs only on sessions that are interactive and/or have a TTY. The easiest way to fix it is to restrict any output in your ~/.tcshrc to interactive shell sessions only. i.e. ones that will display a shell prompt. You can do it by making the output conditional, i.e. replacing the single line you added to .tcshrc with: if ($?prompt) then echo "\033]0;${PROJECT_NAME}\007" fi Add this before setting any custom prompt. Another way would be to silently test the validity of the TTY first: tty -s && echo "\033]0;${PROJECT_NAME}\007"
less command stops working after setting terminal title in .tcshrc
1,495,801,914,000
Why would a file show up surrounded by double quotes with a character surrounded by single quotes within it? "insight_automation.log'.'2024-03-13" I am using Ubuntu Server 22.04.3 LTS. A service desk management program (Atlassian Jira Data Center 9.12.4 if that is relevant) installed on the server writes to various log files. Some of the files are rotated, and after an update some of the log files display as shown above when I execute ~$ ls /var/[application-directory-path]/log Other log files display without any quotes. Some examples: atlassian-jira.log atlassian-jira.log.1 insight_audit.log insight_audit.log.2024-03-05 insight_automation.log There are many posts about single and double quotes in Unix systems, especially with the GNU developers adding single quotes around files with spaces. I am somewhat familiar with the nuance surrounding these characters and Unix, but this is new to me, and I can't find an explanation anywhere online (likely because it is difficult to phrase the problem). I looked at the logging configuration files and nothing appears different between the delinquent insight_automation.log rotate settings and the other log files. My only guess is that the dot in the name is a different Unicode character that is escaped similar to the way spaces in file names are. Maybe One Dot Leader, Interpunct, or Bullet? I am sure I can fix the issue simply, but knowing why it is displayed like this would help a lot.
(I'll just answer this here so you don't need to read all the whining about that feature in the linked answer.) Recent versions of GNU ls by default wrap filenames with special characters in quotes, when printing to a terminal, for the purpose of making the output unambiguous, and e.g. making any trailing spaces visible. In most cases, they use single quotes, but if the name itself contains single quotes, they might use double-quotes to wrap the whole name. Assuming you're using one of those versions of ls (which is likely if your system isn't old), then your filename is insight_automation.log'.'2024-03-13, and ls prints it quoted as "insight_automation.log'.'2024-03-13". The output should be suitable as input to the shell (well, to Bash anyway), so you can check with e.g. ls "insight_automation.log'.'2024-03-13" which, if it works, should find your file. Or, if you want ls to print the filename without any extras, run ls -N instead. Or ls -N *\'* or such to match just filenames that have single quotes in them. As to why you'd have a filename with quotes, we can't know without seeing the rest of your system.
Why is a filename surrounded by double quotes with single quotes around a character when displayed in terminal?
1,495,801,914,000
I am trying to use variables to construct the --command arg for gnome-terminal. My shell script look like this: buildId="aa-bb-cc" versionCode="123456" daily="daily" gnome-terminal -e 'sh -c "while true; do python acra.py $versionCode $buildId 0 $daily sleep 600 # 10 mins done"' But when I run this script, new terminal open but it cannot recognize these variables, I'm only receive sys.argv = ['acra.py', '0'] inside my python script, so I guess the cmd was executed just like: python acra.py 0 So how can I use variable in this case?
Assuming that gnome-terminal behaves like xterm: gnome-terminal -e sh -c 'some commands here' sh "$variable1" "$variable2" "etc." The strings at the end of the command line will be available inside the sh -c script as $1, $2, $3, etc. The first argument to the script, the string sh, will be placed in $0 and used in error messages by the shell. In your case: #!/bin/sh buildId="aa-bb-cc" versionCode="123456" daily="daily" gnome-terminal -e sh -c ' while true; do python acra.py "$1" "$2" 0 "$3" sleep 600 done' sh "$versionCode" "$buildId" "$daily" This assumes that the acra.py script is available in the current working directory.
How to pass variables to gnome-terminal command
1,495,801,914,000
Given a text message, I need to programmatically generate a bash command to open terminal emulator and show this text in it. For example, for HelloWorld input string I need to return the following output string: gnome-terminal -e "$SHELL -c echo\ HelloWorld;exec\ $SHELL" The problem is that my input messages may consist of arbitrary symbols. By trial and error, I have ascertained that different symbols are required to be escaped different number of times: "A" must be converted to "A" (0 times to be escaped) " " must be converted to "\ " (1 times to be escaped) "(" must be converted to "\\\(" (2 times to be escaped) "\" must be converted to "\\\\\\\\" (3 times to be escaped) For example, \(o o)/ must be inserted in the command as \\\\\\\\\\\(o\ o\\\)\\\/: gnome-terminal -e "$SHELL -c echo\ \\\\\\\\\\\(o\ o\\\)\\\/;exec\ $SHELL" Actually, I don't know bash at all, so I don't have full understanding of the logic behind that. Could you please tell me the general rule: how to convert any symbol from ASCII subset (10,32-126)? Edit: To bring more clarity on what I'm doing. I'm trying to write a function (in some programming language) that receives a string InputText and returns another string, which is a correct bash command. Currently, I'm trying to implement this function as simple concatenation of: 1) constant prefix gnome-terminal -e "$SHELL -c echo 2) inner part which depends on InputText 3) constant suffix ;exec\ $SHELL" The problem is with the inner part. I'm trying to calculate it as concatenation of each InputText's symbol converted. But I don't know how to convert arbitrary symbol. Edit 2: Thanks to choroba for the idea of using single quotes to avoid mass escaping. I've learned a lot about bash. )) This is a modified version of choroba's answer. The same idea, but without "backslashies backslashes tandems", implemented in Lua: function run_terminal(text) local function q(s) return "'"..s:gsub("'","'\\''").."'" end os.execute( 'gnome-terminal -e "$SHELL -c "'..q(q("echo "..q(text)..";exec $SHELL")) ) end run_terminal "Some Text" Edit 3: Thanks to Gilles for mentioning "-x COMMAND" option of gnome-terminal. Quoting is not required with this option, so we can reduce level of quoting inside generated commands: function run_terminal(text) local function q(s) return "'"..s:gsub("'","'\\''").."'" end os.execute("gnome-terminal -x sh -c "..q("echo "..q(text)..";exec $SHELL")) end run_terminal "Some Text"
Quote the string, and you'll only have to backslash the quotes. If you quote twice, you need to escape both quote types. Update: Gnome terminal needs triple quoting. Just escape the single quotes twice in the string, and use quoted single quotes around the inserted string. You need to backslash the backslashes in the original string, too. Proof: I used the following Perl script: #!/usr/bin/perl use strict; use warnings; use feature qw{ say }; chomp( my $msg = <> ); $msg =~ s/\\/\\\\/g; # Quis backslashies backslashes tandem? $msg =~ s/'/'\\''/g for 1, 2; # Replace ' by '\'' twice. $msg =~ s/"/\\"/g; # Backslash double quotes. system q(gnome-terminal -e 'bash -c "echo '\\'') . $msg . q('\\''; exec bash"');
Escaping in bash
1,495,801,914,000
I'm looking to run two independent parallel gnome-terminal windows with some parameters, from one shell script. So far I've got this: #!/bin/sh gnome-terminal -e window1.sh & gnome-terminal -e window2.sh & exit However, upon running this, the screens flash up and disappear. I was expecting both to appear, wait for key input, then continue working as normal terminal windows would, i.e., I should be able to continue typing commands into them both. Here's the code for window1.sh + window2.sh: #!/bin/sh echo window read -p "press any key to continue" I don't understand why they aren't even respecting the 'read' and waiting for input.
Run the script on its own. ./window1.sh You will get this output. window press any key to continue./window1.sh: 3: read: arg count This is because read is a bash command, but not a sh command.
How to run two parallel gnome-terminal windows?
1,495,801,914,000
For closing terminal without killing script/command we use & operator at last while calling command. Like: gedit & Here I used gedit as an example command Same thing I want to do on another terminal (from current terminal). I am using following command(s) to run script/command onto another terminal: gnome-terminal -e 'gedit' gnome-terminal -x bash -c 'gedit' But here if I close new opened terminal, then script/program runnung by [command] also killed. So I've tried using & as follows: gnome-terminal -e 'gedit' & gnome-terminal -x bash -c 'gedit' & But none of above is working. So, How can I achieve this : From current gnome-terminal, Execute command in another gnome-terminal and close that (new-opened) terminal after launching command without killing running command.
Combining nohup & screen, Al last I achieved what I want. By kirill-a, the command : gnome-terminal -e "nohup bash gedit" is suggested. However by using above command, I can run command and can close new opened gnome-terminal without killing running command, BUT I've to manually close new opened gnome-terminal window. And I want it to be closed automatically after launching command. By Dimitar Dimitrov screen command is suggested. At-last I used screen with nohup and my Final command becomes: gnome-terminal -e 'screen nohup gedit' gnome-terminal -x bash -c 'screen nohup gedit' By using either of above command(s) I get: command launched in new terminal window and after launching command, new opened terminal closed without killing running command.
Execute command in another terminal and closing it without killing command
1,495,801,914,000
When I insert, for example, unix.stackexchange.com followed by Enter in terminal, I get the following error: unix.stackexchange.com: command not found This is ok and as I expected. But when I insert http://unix.stackexchange.com, I get another error message: bash: http://unix.stackexchange.com: No such file or directory I do not ask about why I get errors. I want to know why these are different and, eventually, which process/function handles them?
As also ewhac pointed out, the error messages differ because the latter command line contains forward slashes (/), which causes your shell to interpret it as a file path. Both errors originate from your shell, which in this case is bash (which is evident from the second error message). More specifically, the first error originates from the execute_disk_command() function defined in execute_command.c in the bash-4.2 source code. The execute_disk_command() function calls search_for_command() defined in findcmd.c, which, in case the specified pathname does not contain forward slashes, searches $PATH for the pathname. In case pathname contains forward slashes, search_for_command() does not perform this lookup. In case search_for_command() does not return a command, execute_disk_command() will fail with the command not found internal error. The second error originates from the shell_execve() function, also defined in execute_command.c. At this point in your scenario,search_for_command() would have returned successfully because there would not have been any lookup needed, and execute_disk_command() has called shell_execve(), which in turn performs the execve() system call. This fails, because the file execve() attempts to execute does not exist, and execve() indicates this by setting errno appropriately. When execve() fails, shell_execve() uses strerror() to report the corresponding file error message (No such file or directory) and exits the shell immediately on the error.
Different error messages when using different strings in terminal
1,495,801,914,000
I'm trying to get gnome-terminal to run on my system.  I've tried various installation methods...  Unfortunately, all of them come up BLANK.  They also don't accept input. Wondering if anyone has any knowledge or ideas about this? Here is a screenshot:
I had the same problem this morning. Chances are good that your profile is displaying black text on a black background. Edit -> Profile Preferences -> (change color scheme.)
gnome-terminal comes up blank
1,495,801,914,000
I'm new to dwm (suckless.org) and also to GNU/Linux. I know a bit of the C language but don't really understand the config.h file. SYS-CONFIG I use Ubuntu 18.04 (installed with netinstaller + vanilla gnome...) and recently I wanted to try dwm 6.2. HOW I INSTALLED IT I downloaded the tar.gz file from the suckless.org website and for install I just typed make in terminal in that folder (without any error) and I also installed the dwm via Ubuntu repository and finally created a symbolic link in ~/bin/ thereafter, I created a .xinitrc in home folder and put exec dwm in that. then I rebooted, and logged in. I didn't change the config file. PROBLEM The default keybinding, Shift+Alt+Enter doesn't open gnome-terminal. config.h /* key definitions */ #define MODKEY Mod1Mask #define TAGKEYS(KEY,TAG) \ { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, /* helper for spawning shell commands in the pre dwm-5.0 fashion */ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } /* commands */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *termcmd[] = { "st", NULL }; static Key keys[] = { /* modifier key function argument */ { MODKEY, XK_p, spawn, {.v = dmenucmd } }, { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, { MODKEY, XK_i, incnmaster, {.i = +1 } }, { MODKEY, XK_d, incnmaster, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, { MODKEY, XK_Return, zoom, {0} }, { MODKEY, XK_Tab, view, {0} }, { MODKEY|ShiftMask, XK_c, killclient, {0} }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, { MODKEY, XK_comma, focusmon, {.i = -1 } }, { MODKEY, XK_period, focusmon, {.i = +1 } }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, TAGKEYS( XK_1, 0) TAGKEYS( XK_2, 1) TAGKEYS( XK_3, 2) TAGKEYS( XK_4, 3) TAGKEYS( XK_5, 4) TAGKEYS( XK_6, 5) TAGKEYS( XK_7, 6) TAGKEYS( XK_8, 7) TAGKEYS( XK_9, 8) { MODKEY|ShiftMask, XK_q, quit, {0} }, };
Here is the problem: static const char *termcmd[] = { "st", NULL }; The dwm build from suckless.org uses st as default terminal emulator therefore Alt+Shift+Enter is mapped to st which is not installed on your system. You need to change st to gnome-terminal or whatever other terminal emulator you want (and which is installed on your system). Once you edited the configuration file run make and make install to apply the changes to your system.
The default keybinding for opening a terminal in dwm does not work
1,495,801,914,000
Some how, gnome-terminal able to get some environment which are not set in any of shell init files(sytem-wide/user-level) env -i DISPLAY=":1.0" /usr/bin/gnome-terminal $> env gives many other variables, where as xterm only give a few as below env -i DISPLAY=":1.0" /usr/bin/xterm $> env DISPLAY=:1.0 TERM=xterm WINDOWID=37748770 XTERM_VERSION=X.Org 6.8.99.903(253) XTERM_LOCALE=C LOGNAME=bkatkam XTERM_SHELL=/bin/csh HOSTTYPE=x86_64-linux VENDOR=unknown OSTYPE=linux MACHTYPE=x86_64 SHLVL=1 PWD=/home/bkatkam USER=bkatkam GROUP=inv HOST=inv2 But, These are getting cleared in new VNC session. I suspect, vnc session is storing environment somewhere. I couldn't able to figure out where it has stored them. I have also went through, csh: Terminal inherits environment variables from an unknown location, But root cause was not found in this question. Edit: env -i command is now giving proper environment, after closing all open gnome-terminals. But still if I open terminal normally(without env -i), unrelated environment are getting inherited
After debugging, got to know that gnome-terminal inherits environment from it's parent Xvnc process Xvnc in-turn gets environment from terminal on which vncserver was executed to create VNC. So, to ensure VNC with clean environment. I have created it with command env -i PATH="/usr/bin:/bin" HOME="/home/bkatkam" vncserver -geometry 1920x1080
gnome-terminal inherits some environment even with 'env -i' on a vnc session
1,495,801,914,000
I fiddled with this for a couple of hours and couldn't find a solution... Lets say I print this to a terminal (tested with bash and zsh in a genome-terminal in a VM running a fresh Linux Mint): python3 print("\033[41mFOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO\033[0m BAR") \033[41m enables a red background for the text that follows. \033[0m resets the background to the default. Assume that there are enough O's to generate an output which fills exactly one and a half lines in the terminal. In a fresh terminal the output looks like this (like I expected): |FOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO| |=================================| |OOOOOOOOOOOOOO BAR | |============== | | | Every char that is underlined with a = has a red background. | Defines the border of the terminal. So we see FOO... with a red background and BAR without a red background. If I run the command again I get this: |FOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO| |=================================| |OOOOOOOOOOOOOO BAR | |============== ===============| | | After BAR the line continues to be red... and I have no clue why? Any idea?
iTerm2 on Mac OS X also does this when the colored text wraps past the available columns. One workaround may be to erase to the end-of-the-line after writing BAR via the CSI Ps K Erase in Line (EL) control sequence, e.g. $ perl -e 'print "\e[41m".("a"x120)."\e[0mBAR\e[K"'
Colored terminal output ignores reset sequence. Color continues
1,495,801,914,000
In gnome-terminal, lxterminal and mlterm under Lubuntu 16.04, when pressing PgUp nothing happens, and the symbol ~ appears when PgDn is pressed, but the information won't scroll up or down. This is not the case for navigators and text editors, where they behave as expected. How can this be changed for a terminal?
It's a problem that has to be solved for each particular terminal. In the case of mlterm you add these lines to the shortcuts file ~/.mlterm/key: Prior=PAGE_UP Next=PAGE_DOWN As for gnome-terminal and lxterminal, the preferences window does not allow to change this.
How to scroll up and down in a terminal with PgUp and PgDn keys?
1,495,801,914,000
I would like to add a command to my .bashrc file (or corresponding) in such a way that the command, in this case setterm --foreground red, is only read when I start the virtual terminal ctrl + alt + F1 - 6 and not the Gnome Terminal et al. Is this possible? If so, how?
if [ "$TERM" = "linux" ]; then # Stuff to do only if running in a virtual console setterm --foreground red fi
Bashrc for Virtual Terminal
1,495,801,914,000
I gather all my local ip using arp-scan , Then filter particular system ip by mac address, And connect automatically to that particular system using ssh. I tried the following commands through piping sudo arp-scan --localnet|grep 10|cut -c1-12|xargs ssh myuser@ Here 1c in grep is the mac address starting letter of my system. Its return the following error ssh: Could not resolve hostname : Name or service not known xargs: ssh: exited with status 255; aborting
Use xargs Replacement String Flag You need to use the replacement string flag for xargs. For example, assuming the rest of your pipeline works as intended: sudo arp-scan --localnet | grep 10 | cut -c1-12 | xargs -I{} -n1 ssh -tt myuser@{} Note that both the xargs and ssh commands need some additional flags to work properly. Of special note is the need to pass the -tt flags to SSH in order to force PTY allocation on the remote host when the SSH client is receiving standard input from a pipe. Use Command Substitution and Shell Variables Alternatively, if you're accurately capturing a single IP address, you can just capture the result in a shell variable and invoke SSH on the correct host. For example, using the Bash shell: host_ip=$(sudo arp-scan --localnet | grep 10 | cut -c1-12) ssh "myuser@${host_ip}" The primary advantage of this approach is that it's easier to debug. However, your mileage may vary.
How to ip throught piping?
1,495,801,914,000
I'm on an atom-powered (read: under-powered) netbook, which is nevertheless sufficient for most of my needs (it has good graphical acceleration for videos and 2D graphics such as the browser, and terminal operations with sh are inherently quite fast). The biggest pain point of the setup is that all gtk-based terminal emulators seem to be really slow (scrolling is slow, and I need scrolling for reading man pages--it really sucks when you can't go RTFM properly). xterm and konsole are fast. (Tty's are the fastest but sometimes I want a terminal next to a browser window.) On the other hand, gtk-based terminals integrate better with MATE (I tried gnome-terminal, guake, mate-terminal and a couple of others and they all scroll slow compared to konsole and xterm, which both scroll fluidly). What could be the cause of the speed difference and could gtk-based terminals be made as fast as xterm or konsole?
It depends on how terminal works, really. Some terminals aim to be lightweight, others do not. Some features require more overhead which can have visible impact(this is what you've encountered). You may want to look for lightweight terminal emulators, try out few and pick the one that fits you best. I've personally used Sakura nad Terminator, both of which were satisfying and lightweight. However, since I've never had a speed problem, you might want something faster. Generally, don't limit yourself to one terminal emulator - try out few and see which one fits you best. Still, if you're really inclined, you might want to read this question. You can find good explanation there.
Slow gtk-based terminal emulators vs konsole and xterm
1,495,801,914,000
I had installed a proxy software (cntlm) on my machine. It sets the environment variable http_proxy to 127.0.0.1:3128. Now I've uninstalled the program using apt-get remove cntlm. However I'm able to see the http_proxy variable: env | grep proxy Gives me: http_proxy=http://127.0.0.1:3128/ https_proxy=http://127.0.0.1:3128/ no_proxy=127.0.0.1, localhost I've tried doing a recursive grep on ~ and /etc but it doesn't show anything: grep -ri https_proxy ~ grep -ri https_proxy /etc The interesting thing is that other terminals such as LXTerminal doesn't have this problem. It only occurs in gnome-terminal. I've also tried renaming the bash startup script files: mv .bashrc .bashrc~ mv .profile .profile~ mv .bash_profile .bash_profile~ By renaming, the stuff inside these files (and any linked files) won't be sourced. However, this doesn't help either. How do I go about debugging this problem? I've already gone through this question and it doesn't help.
Running gsettings reset-recursively org.gnome.system.proxy fixed the problem. There are two ways to define proxy settings: Manually set the http_proxy environment variable in /etc/environment or your bash profile. Define it in gnome system settings. I had not set the environment variable manually which is why recursive grep didn't find anything. gnome-terminal was reading gnome system settings and automatically defining the variable. See this post for more details on various ways of defining proxy settings.
Magic environment variables in gnome-terminal
1,495,801,914,000
I've installed and run virtuarenvwrapper.sh to try to configure an alternate version of python on my system. This script has placed somewhere a series of commands that are now executed whenever I open gnome-terminal. Now, when I open a terminal I see: bash: which: command not found... bash: -m: command not found... virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON= and that PATH is set properly. user@localhost ~]$ I want to remove these commands but I can't find out where they are. I've looked in: ~/.bash_profile ~/.bashrc /etc/bashrc The commands run on my user terminal as well as root's terminal. What other places can one put commands to run upon opening a terminal?
The culprit was a symlink at /etc/profile.d/virtualenvwrapper.sh The solution was to either remove that symlink or, better, uninstall the package: yum remove python-virtualenvwrapper
How do I remove the new environment commands that were created by the virtualenvwrapper script?
1,495,801,914,000
If I am in a Linux virtual terminal (pressing Control-Alt-F1 on Ubuntu), and I use the command cacafire, I get the flames inside the actual terminal. However, if I am in the gnome environment, and I start a terminal and run cacafire, I get a separate window popping up that displays the fire. How can I force it to display the fire in the same terminal that it is run from?
It's man doesn't seem to have a option to control it. But you can use DISPLAY= cacafire and cacafire wouldn't know how to connect to your X server; then fallback to running in the current terminal.
How can I get `cacafire` to show up in the original gnome-terminal, instead of a separate window?
1,495,801,914,000
I wrote the following #!/bin/bash cd ~/bin/red5-1.0.0 gnome-terminal --working-directory=. -x red5.sh red5.sh is the script to run (this is java written media server). My script above opens new terminal but with error message There was an error creating the child process for this terminal Failed to execute child process "red5.sh" (No such file or directory) What can be the cause? I am at Ubuntu 11.10
The working directory does not affect your $PATH1, thus I guess what's happening can be understood if you do the same thing in a terminal, i.e. $ cd ~/bin/red5-1.0.0 $ red5.sh will not work either; what does work is one of the following: $ cd ~/bin/red5-1.0.0 $ ./red5.sh # note the relative path to the script or $ cd ~/bin/red5-1.0.0 $ export PATH=~/bin/red5-1.0.0:$PATH # add the path to $PATH which is where $ red5.sh # the shell looks for red5.sh So, guessing that gnome-terminal works similar (regarding where it looks for executables), you could probably alter your script in one of these ways, too. 1: If your $PATH does not contain ., as Kevin pointed out (How about other relative paths, btw?).
How to create a script, which runs another script in separate terminal window and does not wait?
1,495,801,914,000
I'm setting up XMonad within Linux Mint, and I've been able to remove the menubar and the scrollbar from my terminal windows, but I can't get rid of the small resizing nub in the bottom right corner. Here's a screenshot: I think it's feature of Linux Mint (maybe?), but it serves no purpose because of the nature of XMonad, so I'd love to get rid of it. It's gnome-terminal, by the way. I assume that's important. Edit: Ok, it's a feature of gnome-terminal, because xterm and rxvt don't have it. So I guess my question is: How can I remove the nub from gnome-terminal? One answer is just "use a different emulator", but I'm hoping there's a way to get rid of it.
The gnome-terminal program sticks that nub there itself. It started doing that sometime during the transition to Gnome3, and when I realized it wasn't my window manager or desktop environment but the program itself, I was annoyed enough that I looked for an alternative. Roxterm is currently my terminal emulator of choice. [UPDATE]: I'm back to using gnome-terminal. More recent versions of gnome-terminal (or perhaps GTK?) no longer add the nub, and the Roxterm maintainer has just stopped development due to time constraints and a tricky incompatibility with recent GTK.
How do I get rid of the small nub in the bottom right corner of my terminal?
1,495,801,914,000
Some times when I am compiling a script the parameters are so long that they cover many lines in the terminal. When I resize the terminal in order to read more clearly, the content does not automatically re-adjust to the size of the terminal. Is there a way of telling the terminal to re-format its output depending on the window size of the terminal emulator? I am using gnome-terminal
There is no way to "tell a terminal" to "reformat" the scrollback buffer. The buffer is past. That said, you've got several possible scenarios: The text you want to re-adjust is not being controlled by any application and is, in fact, in the buffer. In this case, like @SuperBOB mentioned above, several terminal emulators, including Gnome-terminal, already redisplay the buffer so that line breaks happen at different places; The text is being controlled by some "full-screen" application (e.g. text being shown by a pager, like less, or in a text editor). In this case, the application can be asked to redraw the contents (by sending a redraw signal, which — AFAIK — is usually assigned to ^L (Control+L)). But chances are that your terminal emulator already does this; The text is not under the control of an active application, but was shown by some tool that formatted (added line breaks) to the output in order to match the terminal width. If this is the case, you're out of luck, because there's no way you can possibly do magic. For a more detailed analysis, we need to know which program generated the output and which tools are chained between that program and the terminal emulator (e.g. GNU screen).
How to re-adjust content while resizing gnome-terminal?
1,495,801,914,000
Hi I am trying to direct output of my script to a file My script is gnome-terminal -- ./program +config I have consulted some post and have tried gnome-terminal -- "./program +config 2>&1 | tee output.txt" or gnome-terminal -- 'bash -c "./program +config 2>&1 | tee output.txt"' and many other variations but they do not work well I am using Ubuntu 22.04.
Correct Answer It's very likely you don't need to use gnome-terminal to achieve whatever you're doing. There most likely is a better way to capture the output of ./program than running it in gnome-terminal. You still want to use gnome-terminal Unlike other terminals (like Konsole or xterm) I couldn't find any option to log the output of a session. If anything, the Gnome Manual says about the scrollback data: Scrollback data is stored in compressed and encrypted files on disk, under the system’s default location for temporary files (usually /tmp). These files are unlinked immediately after their creation, and as such, do not show up in the directory listing. The occupied disk space is freed up as soon as the corresponding terminal closes. It seems that Gnome is going out of its way to prevent users from getting an output log. You can work around it by using the script utility. From the man page: script - make typescript of terminal session The answer is as simple as launching script before running your program. In other words, replace: gnome-terminal -- ./program +config with gnome-terminal -- script -f $LOG_FILE -c "./program +config". Make sure to give a proper value to $LOG_FILE, something like LOG_FILE=$HOME/.terminal.log, and you should find the output in there once the program exits.
Direct output from gnome-terminal to text file
1,495,801,914,000
With the mouse, terminal tabs can be detached by highlighting a tab, right-clicking and selecting the said option. I'm more or less a keyboard-only user and thus this feature is inaccessible to me at the time.
Depends on which gnome-terminal version you're using and what settings you use but Detach Current Tab doesn't have a bound keyboard shortcut. However, you can bind one manually in Rocky 9: Settings > Configure Keyboard Shortcuts > Detach Current Tab Ubuntu: Edit > Preferences > Shortcuts > Detach Tab The actual location of Keyboard Shortcuts may vary depending on the Version/Distribution.
How to detach a session in Gnome terminal with keyboard?
1,495,801,914,000
I’m running Atom on Manjaro Linux. And I installed Platformio Ide Terminal. Everything is working fine, except the Zsh shell icons. None of the icons is getting displayed. Only boxes like you can see in the screenshot. I’m running Gnome Desktop Environment. Everything is fine in Zsh shell I get in the gnome-terminal Here is a screenshot of the same commands executed in the gnome-terminal What’s wrong with the terminal in Atom? What can be done to make it look like the gnome-terminal?
You need to use a font that contains all the icons you want. If in doubt, gnome-terminal's profile settings show you the font it uses. Use that same font in your IDE. (I don't know Atom Platformia IDE, but I bet the terminal font either configurable through some dialogue or just a setting in a CSS file somewhere.)
Why Zsh terminal icons are not getting displayed in Atom Platformio Ide Terminal?
1,495,801,914,000
I'm in Ubuntu 20.04LTS with GNOME Terminal 3.36.2. I would like to run two commands, executing the second only if the first succeeds: proc.sh && results.sh I would like to run this in a separate terminal window so I say: gnome-terminal -e 'proc.sh && results.sh' This works. But I get a warning that -e is deprecated, and I should be using --. However, both -x (also deprecated) and -- are the same and will interpret the entire contents of the quoted text as the executable name, which of course results in a "file not found" error. So what's the proper way to do this now?
The hint is in the manual: --command, -e=COMMAND Split the argument to this option into a program and arguments in the same way a shell would, and execute the resulting command-line inside the terminal. This option is deprecated. Instead, use -- to terminate the options, and put the program and arguments to execute after it: for example, instead of gnome-terminal -e "python3 -q", prefer to use gnome-terminal -- python3 -q. Note that the COMMAND is not run via a shell: it is split into words and executed as a program. If shell syntax is required, use the form gnome-terminal -- sh -c '...'. (source, emphasis mine) In the command you want to run && belongs to the shell syntax. You need a shell to handle it. Therefore: gnome-terminal -- sh -c 'proc.sh && results.sh'
How to open gnome-terminal and run a compound command
1,495,801,914,000
I am learning how to use ncurses, and I have noticed that for some reason, in gnome-terminal (on arch) ncurses window borders are not being displayed properly. It seems to work fine in xterm. Not sure what could be causing this, and I haven't had any luck googling. Any ideas?
Fixed it, changing $TERM to "gnome" solved the problem. See https://bbs.archlinux.org/viewtopic.php?pid=1738655#p1738655
Ncurses not displaying window border correctly in gnome-terminal
1,495,801,914,000
We have following script (in CentoS 6) in our lab to execute our applications with its output one-by-one. cd A/ sleep 1 gnome-terminal -t A --tab -e "./app1" cd ../B/ sleep 1 gnome-terminal -t b --tab -e "./app2" sleep 2 gnome-terminal -t c --tab -e "./app3" This is working perfect. Now what we want is to generate core dump files for one of our application (i.e. app3) ulimit -c shows 0 by default, and I don't want to change its default value. gnome-terminal -t c --tab -e "ulimit -c unlimited ; ./c" is not working, When googled found that to run into a script it should be, sh -c "ulimit -c unlimited". gnome-terminal -t c --tab -e "sh -c "ulimit -c unlimited" is working perfect. But, gnome-terminal -t c --tab -e "sh -c "ulimit -c unlimited ; ./app3" is NOT working. How can I enable core dump for app3 only? NOTE: We don't want this globally.
There are three ways of doing this. Use a proper chain-loading command. Instead of using the shell built-in command ulimit, use commands that were developed for this purpose, from the various daemontools-family toolsets: softlimit from daemontools softlimit from freedt softlimit from daemontools-encore softlimit from nosh s6-softlimit from s6 chpst from runit runlimit from perp So one would run, using softlimit from the nosh toolset as an example:gnome-terminal -t A --tab -e "softlimit --coresize unlimited ./app1" Use a subshell within the script. This applies the limit to the terminal emulator process as well. In this case this will be fairly benign. But if one is applying other limits such as open file handle limits or process forking limits this can be problematic. (ulimit -c unlimited ; urxvt -e "./app1") Note that this will not work with GNOME Terminal or the client-server variant of Unicode RXVT. Both of those do not directly invoke the terminal emulator as a child of your script. They perform a remote invocation via a server process, which will not have nor acquire the resource limits set in your script. Make GNOME Terminal run a shell that runs ulimit. Remember that you have to build this from the bottom upwards. You want the actual shell that does the work to run the command listulimit -c unlimited ; exec "./app1" To pass this command list to sh it needs to be all one argument after -c, so needs to be quoted:sh -c "ulimit -c unlimited ; exec \"./app1\"" To pass the sh invocation to GNOME Terminal, that too needs to be all one argument after -e, so a second level of quoting needs to be applied:gnome-terminal -e 'sh -c "ulimit -c unlimited ; exec \"./app1\""'
How to run ulimit in a script with other application
1,495,801,914,000
If I start a terminal (any terminal, for example urxvt) like urxvt -e sleep 5, then a new terminal is launched but after 5 seconds the terminal closes, because the sleep program has ended. How can I start a terminal with a program on the command line, but have the terminal stay alive after that process has ended? In practice, what I'd actually like to do is urxvt -e tmux new-session top, which opens urxvt with a tmux session that is running top. But when I press q, top ends which also causes tmux and urxvt to end as well. I'd like when I exit top for me to be taken to a shell within tmux.
The terminal (tmux) closes when it's executed the command you told it to execute. If you want to execute top and then an interactive shell, you need to tell it to do that. Combining commands is the job of the shell, so run an intermediate shell (which isn't interactive) and tell it to run the two commands in succession. urxvt -e tmux new-session sh -c 'top; "$SHELL"'
How to prevent the terminal from closing when the program it was started with ends? [duplicate]
1,495,801,914,000
Trying here to set a c++ application to run on gnome-terminal instead of eclipse console from within eclipse itself. Already done it with Java, but with c++ the menus are different.
That's it, finally managed to enable it, took 6 hours researching. Got it with help from https://www.eclipse.org/forums/index.php/t/305157/. Entered in Run Configuration, in perspective and set: At Main tab: Project: nameofproject C/C++ Application: /usr/bin/gnome-terminal Arguments tab: Program arguments: -e ./nameofproject* ** you can add --window-with-profile=PROFILENAME gnome-terminal setting to run it with other profiles. Working directory: Here set the exactly file location directory: ${workspace_loc:nameofproject/Debug} And deselect 'Use default' Environment tab: No changes Common tab: Deselect Allocate Console (necessary for input) in Standard Input and Output frame. Apply and run.
How can I run a c++ application on gnome-terminal directly from Eclipse instead of its console?
1,495,801,914,000
I've got this file: 0 1 2 3 4 5 6 7 8 9 a b c d e f __________________________________ 20 | ! " # $ % & ' ( ) * + , - . / | 30 |0 1 2 3 4 5 6 7 8 9 : ; < = > ? | 40 |@ A B C D E F G H I J K L M N O | 50 |P Q R S T U V W X Y Z [ \ ] ^ _ | 60 |` a b c d e f g h i j k l m n o | 70 |p q r s t u v w x y z { | } ~ | 80 | | 90 | | a0 |  ¡ ¢ £ € ¥ Š § š © ª « ¬ ­ ® ¯ | b0 |° ± ² ³ Ž µ ¶ · ž ¹ º » Œ œ Ÿ ¿ | c0 |À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï | d0 |Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß | e0 |à á â ã ä å æ ç è é ê ë ì í î ï | f0 |ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ | __________________________________ Its just an ASCII table. How do I make gnome terminal display it properly? By-default it doesn't display any of the row's symbols except for 1st 6, see screenie: My locale is en_US.UTF-8: $locale LANG=en_US.UTF-8 LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=en_US.UTF-8 fonts are default. Tried changing them, no luck.
That is not "ASCII", but appears to be ISO-8859-1 (also referred to as Latin-1). You can either set your locale to something with that encoding, e.g., en_US (depending on what your locale support is), or convert the file into UTF-8 You can use iconv to do this conversion, e.g., one of these: iconv -f ISO-8859-1 -t UTF-8 oldfile > newfile iconv -t UTF-8 oldfile > newfile Further reading: iconv - convert text from one character encoding to another
GNOME Terminal extended ascii support
1,495,801,914,000
I am trying to made a program to experiment bitwise operators. The name of the program is bitwise.c Before compiling the program, I decided to look at the directory just in case I don't get the name wrong. alexander@debian:~/Dropbox/src_code/C$ ls bitwise bitwise.c bitwise.c~ What is bitwise.c~ and why is it hidden from the file location?
This file is most likely created by the editor in which you have bitwise.c file open. Some editors create a temporary file while you are editing one, to track all the changes in case the program would crash without saving the file. The file should be gone once you stop editing the file.
What is bitwise.c~? [duplicate]
1,495,801,914,000
I've been trying to port my Windows .vimrc to Linux, to use on the command line (on gnome-terminal). Everything works fine, except for the colorscheme. It looks like it's loaded (:colorscheme returns solarized; :set t_Co returns t_Co=256 and :set background returns background=light), but it looks ugly on my terminal. If I run any of those commands again manually (either setting colorscheme, t_Co or background), then the theme displays normally. This is the .vimrc.bundle that's sourced on my .vimrc GVim also behaves normally. I tried other terminals (xterm, urxvt, screen), but none worked. Edit: Looks like there's some sort of conflict with a plugin loaded by Vundle. If I comment out the source ~/.vimrc.bundle, the colorscheme is loaded properly.
I'm hazarding a guess that given the number of plugins you have related to colors that one is interfering. I'd comment these out and see if that resolves the issue: " Bundle 'altercation/vim-colors-solarized' " Bundle 'spf13/vim-colors' " Bundle 'gorodinskiy/vim-coloresque' " Bundle 'flazz/vim-colorschemes' " Bundle 'skammer/vim-css-color' And then enable them one at a time to isolate.
vim colors not automatically loaded (probable Vundle conflict)
1,495,801,914,000
I enter a namespace with unshare --net --mount. When I run xterm in it, the shell in the windows that opens iherits the stuff from the namespace. When I run gnome-terminal it runs like I opened it from the desktop. Is there a way to run it "inside" the namespace?
As stated in this answer, running gnome-terminal --disable-factory makes it inherit the environment.
Run gnome-terminal in namespace
1,483,602,912,000
I have customized my command prompt to display current directory with some color and full path. Now I want to set title of my window to only directory name (not full path). Can you please advise how to achieve that in korn shell. Thanks.
The way I found to achieve this is by creating an alias to the cd. I put the following code inside the .profile file which did the trick xcd() { cd $*; echo -ne "\033]0;$(basename $PWD)\007"; } alias cd='xcd' Thanks a lot to Kusalananda for the solution which I was actually looking for: cd() { command cd "$@"; echo -ne "\033]0;${PWD##*/}\007"; }
How to change terminal title without changing the prompt string?
1,483,602,912,000
I'm viewing a log file with "tail -f" using GNOME Terminal. The log has a lot of input constantly coming into it, and what I find happens is that I scroll up to a previous section, and I'm reading it, and then the screen goes black, or gets replaced with text which is further down the file. I don't know if this is the problem, but it's as if tail can only hold so many lines in memory, and when a certain number come in after the ones I'm reading, it deletes the ones I'm reading. The number of subsequent lines which need to come in to make this happen isn't too huge - about 600 (~55,000 bytes) lines in an experiment I just did. I'd like to increase this to about 20,000 lines (or 1,000,000 bytes, say, if it's counted in bytes). Can anyone tell me how to do this? thanks PS - someone reading this might be tempted to say "this isn't what tail -f is for, it's just for reading the end of files". I like to have the best of both worlds - to press "Enter" to get to the end of the file and see what's happening now, but also to be able to scroll up and see what happened previously.
GNOME-Terminal's scrollback setting is under Edit->Preferences->Profiles->Edit->Scrolling. The default value appears to be 8,192 lines on my install, but you can set it to what you want or disable the limit entirely. You can also use a pager such as less for the same purpose: tail -f file | less Note that storing unlimited history in memory may end up taking a fairly large chunk of memory in long-running tasks. Using a pager will allow much of the buffer to be cleared when you exit the pager, while in the terminal it lasts as long as your terminal session. You may find this past answer about scrollback buffers helpful to understanding what's going on.
"tail -f" in GNOME Terminal - scrolling to previous lines breaks if there's been lots of subsequent output
1,483,602,912,000
I do run reset quite frequently while using GNOME Terminal. I've been trying to find a way to do (exactly) that using a shortcut. Reset and Clear (Ctrl + K) "resets" the terminal in a similar fashion, but I have to press Enter to get a prompt back. Is there a way to get the behavior I'm describing? I've tried iTerm 2.x in macOS, and Ctrl + K does exactly that, so I think there has to be a way to do this in GNOME Terminal as well, since this looks like a very basic workflow that many people might use on a daily basis.
Add to your .bashrc: bind -x '"\C-k":reset xterm' Source the file: $ . .bashrc Now when you press Ctrl+k you should get the desired result.
Obtain prompt right away after "reset and clear" in GNOME Terminal
1,483,602,912,000
I made some animations and a game that are to be played in the terminal and they rely on the terminal only having 8 colors available. When I run them on a Terminal that has 16 colors available (particularly obvious when you run neofetch and see the colors available) they do not render properly at all. Is there a quick and dirty way to force a linux terminal to use only 8 colors? Edit: The problem may also be that I was using an older version of ncurses on Ubuntu 18.04 LTS when I made these programs. I am attempting to get them to look right on a distro with an up-to-date version of the library. For anyone interested in attempting to answer the question I originally posed I'll still accept anything that demonstrates ways to force gnome-terminal to revert to 8-color mode if that's even possible. Edit: The problem was related to my frequent use of standend() to revert the drawing functions back to white on black text. For some reason this was not doing what I expected it to do on some distros. By explictly telling it to attron() a color pair that was defined explictly as black and white I solved the problem. This is a hacky and hard-coded solution that stems from my abusing the ncurses library in a hard-coded way. Consider this solved, although I'd be interested in some digestible resources on programming with raw escape sequences for the future to better understand this problem.
The problem was related to my frequent use of standend() to revert the drawing functions back to white on black text. For some reason this was not doing what I expected it to do on some distros. By explictly telling it to attron() a color pair that was defined explictly as black and white I solved the problem. This is a hacky and hard-coded solution that stems from my abusing the ncurses library in a hard-coded way.
Force Bash to use 8 colors
1,483,602,912,000
Background: I SSH into my Linux machine via Putty on my Windows machine. I am running VcXsrv on Windows and forwarding X over SSH. This is all working as expected. I am running into issues opening gnome-terminal on the new display when executing the commands through a bash script. When I execute these commands directly on the console, the new terminal server starts and I am able to start gnome terminal sessions that connect to the server. $ /usr/libexec/gnome-terminal-server --app-id my.foo & [1] 29553 $ gnome-terminal --app-id my.foo $ However, when I place the same commands into a shell script, I get the following error: contents of startGnomeTerm.sh #!/bin/bash /usr/libexec/gnome-terminal-server --app-id my.foo & gnome-terminal --app-id my.foo When executing the script $ ./startGnomeTerm.sh # Error creating terminal: The name my.foo was not provided by any .service files I have even attempted to share all shell variables with the script by executing $ export > shell_vars Then placing this at the beginning of the script. #!/bin/bash source shell_vars .... -UPDATE- The solution is to add a slight delay to between the commands. Setting up the server takes longer than the script was allowing for, so the terminal tried to connect before the server was actually running. Working script: #!/bin/bash /usr/libexec/gnome-terminal-server --app-id my.foo & sleep 0.5 gnome-terminal --app-id my.foo
As discussed above: timing issue; introduce a sleep between the start of the terminal server and opening the new terminal. :)
Unable to start new gnome terminals from shell script when remotely logging in through ssh
1,483,602,912,000
I want to use a nautilus script to open a (gnome-) terminal with a tmux session (or start one) at a specific location and then execute some commands in this terminal (e.g. nvim $file). I've encountered 2 problems however: 1: I have "Run a custom command instead of my shell" at "tmux", such that every terminal starts in a tmux session. This seems to negate the ability to open the terminal at a given location. What I tried is putting an executable test.sh file in ~/.local/share/nautilus/scripts/ with content: #!/bin/bash gnome-terminal --working-directory=$NAUTILUS_SCRIPT_CURRENT_URI this works on a blank profile. With "tmux" as startup command however I just get a blank terminal at ~ 2: If I try to use any command after that, nothing happens. nvim some_file_there does nothing, just as echo "hi" and exec echo 'hi' Could someone explain the behaviour to me? Meanwhile I've deactivated the "Run a custom command" setting in terminal. However, still I can only change the working directory (open terminal here), but cannot issue any further commands. My newest test script containing only: #!/bin/bash zenity --info --text="$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" gnome-terminal -e "ls" Does somehow change the working directory to the one, that the nautilus script is started from! Also it shows the results of the ls command, but in the terminal a dialog band is dropped down in blue saying: "The child process exited normally with status 0." And a Relaunch button to the right. - I guess this means, that a new session or terminal or so is started (the child), but it doesn't continue, such that I could eventually use it!? Can someone maybe clarify what happens here?
I've found solution relying heavily on tmux. Since tmux is working independently of the shell and prevails even after closing the windows, one can prepare a tmux session and then attach to it. The thing won't instantly exit, since the attachment command does not return unless you exit it. This and the fact that you can name and search a session yields the following Nautilus-Script: #!/bin/bash # nautilus script to start files in nvim under a tmux session # place this script into ~/.local/share/nautilus/scripts/nvimOpen.sh # presented without warranty by mike aka curvi # nvim running in another session? - # TODO tmux rename-session -t $whaever nvim # Tmux session 'nvim' is running neovim always! if tmux has-session -t nvim ; then # test if it is open and split it for selected_file in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS ; do tmux send-keys -t nvim Escape # change to normal mode tmux send-keys -t nvim ";vsp $selected_file" Enter # open file in vsplit done else # or start it up freshly! tmux new-session -d -s nvim ; tmux send-keys -t nvim "nvim -O $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" Enter tmux send-keys -t nvim Escape # change to normal mode fi # after the tmux session is prepared - attach to it in gnome-terminal! gnome-terminal -e "tmux attach-session -d -t nvim" Bonus: since I send the keys, instead of issueing the commands directly they appear in the terminals history, like expected! Attention: my nvim/init.vim contains a remapping of ; to :, which means, that in order to run one has to check the sent keys for "regular" vim/neovim settings!
Bash script to start tmux and issue commands
1,483,602,912,000
I just installed centos7.2 and am trying to set it up somewhat nicely. I found an answer on here that shows how to set up some colours in the prompt. I am finding that, once dropped into the .bashrc, it works fine when using putty to ssh in and when I use the Konsole app. But, when I use Terminal (which is gnome terminal), the colours will not match Michael's output (which is what I see in putty) and there is a funny character preceeding each piece of the output (which I tracked down to the \] sequence, which is supposed to be valid and doesn't choke elsewhere). Is it known that gnome terminal behaves differently than other terminal programs? Any way to make it conform? Not really liking konsole so much, but am open to suggestions for alternatives or ways to fix that will work across all clients (ie: I don't want to maintain two colour defs, for example, \e[01;32m prints the next chars green in putty and grey in gnome terminal; I have to use 38m in gnome terminal to get green).
No, gnome-terminal is not meant to behave differently than the others, although the exact shade of the 16 base colors is somewhat different across all the terminal emulators. (Update based on JdeBP's comment below: in some palettes, e.g. Solarized, these colors are deliberately totally different.) You should look around in gnome-terminal's Edit -> Profile Preferences -> Colors dialog and choose a scheme that matches your taste. In the escape sequence \e[01;32m 01 stands for bright and/or bold (there's a confusion about it across terminal emulators) and 32 stands for green foreground. 38 on the other hand means the terminal emulator's default foreground, which is green if you happen to have the "green on black" color scheme by default, but more typically it's either white or black. Assuming your shell is bash, its PS1 prompt is required to enclose all the escape sequences between \[ and \], this is how bash knows that printing those won't advance the cursor, and hence editing the command line won't fall apart. Assuming that these are indeed present in pairs in PS1, bash consumes them and never prints them to the terminal, so there's no way gnome-terminal could do anything nasty there. Probably they are not properly balanced in your PS1.
gnome terminal colors
1,483,602,912,000
This isn't so much a request for help as a curiosity of mine. I wrote this script to quickly pop up four terminal sessions and fill my screen, since so many of my current systems have things that come in fours, and I'm a bit OC about terminal positioning if I'll be using them all heavily. #!/bin/bash #launch 4 terminals setup to fill my screen gnome-terminal --geometry 116x27+0+600 & gnome-terminal --geometry 116x27+0+0 & gnome-terminal --geometry 116x27+1000+0 & gnome-terminal --geometry 116x27+1000+600 & exit Now, this script works just fine for me. Nothing to write home about etc. The wierd thing is that pre-rebooting my system (solaris 11 x86) I was not putting the commands to the background (no & at the end). It worked perfectly pre reboot. In fact, it worked slightly faster before the reboot, when it was not sending the commands to bg. post reboot, without back grounding the commands, I get one terminal, and when I exit from that one, I get the next one and so one. That seems reasonable to me, but I am now very curious if anyone knows what might have been different about how the script was launched that made it work without having to & all the commands. Its as if before it was being launched as a normal shell script, and now the same launcher, executing the same script, is launching it as though I were typing in each command at a prompt. I've looked around the docs, and tried options to see if anything affects this, unfortunately, my main use for desktops is usually just to have multiple terminal sessions up, so I'm kind of clueless about gui desktops. One last bit of weirdness. I copied the original script (with no &) to another script name. Then made a brand new launcher, and it worked again. So then I rebooted again. But post reboot, it no longer worked (opening them one at a time and only after the previous one has exited). Summary, before rebooting, this script didn't need the & to work, and now it does. Fresh made, this script works, but after a reboot it stops working. Why might this be? No changes were made to the system. If someone has intimate knowledge of how launchers get their information at boot time vs how they work when assembled on the fly, that would be very nice to know.
Tip: fire up all your gnome-terminals (all four), set them up just the way you want them, and then run: gnome-terminal --save-config=$HOME/my4.term Then modify your script to run: #!/bin/bash gnome-terminal --load-config=$HOME/my4.term And use that to launch the four terminals. It will also save the working directories you were in, windows size, geometry, tabs, etc.
issue with how newly made gnome launchers work vs launchers rebuilt after a system boot. (title change for clarity)
1,483,602,912,000
I use gnome-terminal on Ubuntu, and when the window is small (not maximized or fullscreen), my tmux statusline and the ZSH right prompt both stretch to the extreme right of the window, which is perfect. However, when maximized or fullscreen, there is a small but annoying gap at the right edge of the screen. Is there any way this can be fixed? (I know it's nearly insignificant; please be nice!)
First of all check if setting variable ZLE_RPROMPT_INDENT to 0 helps. The default is 1. From zsh manual: ZLE_RPROMPT_INDENT If set, used to give the indentation between the right hand side of the right prompt in the line editor as given by RPS1 or RPROMPT and the right hand side of the screen. If not set, the value 1 is used.
gnome-terminal : small gap at right side of screen (Ubuntu)
1,483,602,912,000
If I ssh to a machine and: man df I see this: I'm using GNOME-terminal/Ubuntu 10.04 LTS. So somehow the terminal is messed up, when I want to see the ex.: man pages.. How can I fix this?
It's failing to show underlined and bold text. This is sometimes related to the color scheme in use, as it's inherited from the system theme by default. In gnome-terminal, go to Edit -> Profile Preferences -> Colors. Uncheck "Use colors from system theme" and pick one of the built-in schemes instead. Works for me!™
GNOME-TERMINAL messed up