Tilde not working in gnome-terminal - shell

I figured out recently that my '~' character doesn't work in gnome-terminal:
-it works in ANY application I can run (sublime text, emacs, gedit, nano...)
-it works on TTYs (ctrl+alt+FX)
-it works on xterm, xfce4-terminal etc.
-it doesn't work in gnome-terminal. I reinstalled it, still doesn't work
-it doesn't work in dash, when launched from gnome-terminal
I use zsh, I tried to launch it with a brand new .zshrc since I have quite a lot of keybindings in it and it still doesn't work.
Oh, and also, when I run 'sed -n l' and try a '~', nothing shows up, so no key binding from anywhere, I guess...
I'm kind of out of ideas right now, and hope you could help me?
Regards

If other terminals in the same X session are seeing the keypress and things running in gnome-terminal are the only things that can't then gnome-terminal is grabbing the keypress.
You can confirm this by running read -n 1 in gnome-terminal and hitting ~. If you get the prompt back then the shell saw it. If you don't it didn't.
If it doesn't then you need to see what in gnome-terminal is grabbing it. Check the shortcuts listed in the menus first.

Related

Duplicated characters and non-updating input using tmux in zsh

First off:
I'm using tmux 2.5 installed via homebrew on OS X 10.12, in iTerm 2 (though the problem appears in Terminal.app as well). My tmux.conf is on Github, along with my zshrc.
The problem: Seemingly out of nowhere, I started seeing an issue with typing in the prompt. Typing keys once will display them twice, and backspacing will move the cursor forward and redraw characters already present on the line. This only happens inside of a tmux session, and not inside my "regular" terminal.
Here's a gif of the issue. In this gif, I type 1234567890, then hit backspace 9 times, and type ls. Note that 0 only shows up once, and lls with a duplicated l runs the ls command as expected.
Hopefully I just hit a weird key combo on accident, but I've been stuck on this for a while.
Thanks for any help!
Installing tmux-256color for macOS as in this guide solves the problem.
Running the following as mentioned in a github issue solved the problem for me:
brew install ncurses
$(brew --prefix)/opt/ncurses/bin/infocmp tmux-256color > ~/tmux-256color.info
tic -xe tmux-256color tmux-256color.info
infocmp tmux-256color | head
I'm also running into this issue as well. I encountered the problem similar to #artemave, by trying to change the set -g default-terminal "screen-256color" to set -g default-terminal "tmux-256color". The goal of doing this was to gain italics, per the tmux FAQ.
#taylor's answer didn't work for me, as I didn't have that command.
I managed to determine that:
The issue doesn't occur with bash
When running a blank .zshrc, backspacing creates new blank lines, but I'm not seeing the character duplication
Using tmux-256color will successfully give italic fonts
Using TERM=xterm-256color and TERM=konsole-256color does not change the above effects
Using xfce4terminal (0.8.9.1), Konsole (19.12.3), or URXVT (9.22) doesn't change the above behavior
I wasn't able to really "fix" the issue, as the even going down to a blank .tmux.conf wasn't able to change anything. Instead, I just needed to change it to anything else. xterm-256color was suggested in this issue, but I found nearly anything else would work fine.
I'll keep working on it and update this answer if I find anything else.
Edit: This tmux issue is the exact issue we're running into. I'll see if the solutions there work
https://github.com/tmux/tmux/issues/597
Edit 2: I've submitted a GitHub issue with tmux. No real results yet, but it does offer some guidance on things to check on.
The problem seems to be fixed after commenting out this line from my tmux.conf:
set -g default-command "reattach-to-user-namespace -l zsh"
I also had to manually run tmux kill-server instead of relying on just re-sourcing my conf file.
When I find some time, I'll look more into what went wrong here...

running tmux automatically when xterm is launched: what is the most elegant/correct solution?

I am trying to setup my workstation in such a way that tmux is run for each terminal (xterm, gnome-terminal, ...) that is launched. I was thinking to add tmux to the .bashrc; problem is that if I launch bash twice for whatever reason, it start a second tmux inside the current tmux.
So:
is there a way to detect, maybe from the .bashrc, that the current bash is the 'first' one and not a second one launched in the same terminal?
any other good ideas / best practices / bash design patterns?
You can add the following to your .bash_profile:
SHELL=tmux
This is the first place xterm checks for the command to run if none is given on the command line.
Combine the two previous answers:
alias xterm='SHELL=tmux xterm'
You get the desired behavior when starting just xterm, but you can still use xterm for other operations, such as xterm top.
What about aliasing xterm to xterm tmux?
Just add the following line to your .bashrc:
alias xterm='xterm tmux'

tmux Escape key exits server

I'm using tmux on a macOsX moutain lion (10.8)
Whenever i'm in a terminal, pressing the Escape button results in the connection to the server being lost and tmux actually exiting. I experience the same behavior regardless in iterm2, terminal and while using any of zsh, bash or a normal login shell.
That's how it looks like:
Any hints? :)
I finally figured out that it was related to iterm2-tmux integration.
As you can read here in the Usage section just below the code box, the tmux-iterm2 integration makes the ESC key actually kill tmux, unless you actually use tmux -C.
This effect was actually undersirable for me since I was not using tmux -C and the ESC key is extremely important in programs like vim or mc.

Weird problem in running bash script

I wrote a bash script that fetches lyrics from a website. The script is here --> http://scrippets.wordpress.com/2011/02/01/fetching-lyrics-of-songs-from-the-terminal/ (the indentations in the script are correct unlike how it looks on the blog)
This script works perfectly well when executed from the terminal. Now i created a custom keyboard shortcut using compiz commands, that executes the following command when the right key combination is pressed :
gnome-terminal --working-directory="/home/tapan/sandbox/bash/" --window-with-profile=lyrics -e "/home/tapan/sandbox/bash/lyrics.sh" -t "`rhythmbox-client --print-playing`"
I created a new profile called "lyrics" to give the terminal that opens up a custom look. When i open up a terminal with this profile and run the script, it works perfectly fine again. However, when i use the keyboard shortcut to run the custom command, i get the following error:
Pink Floyd - Is There Anybody Out There?
wget: missing URL
Usage: wget [OPTION]... [URL]...
Try `wget --help' for more options.
cat: 3.txt: No such file or directory
I cannot figure out whats wrong. I mean if it works perfectly well in the terminal normally, why shouldn't this work? Any suggestions?
PS: The script i have written is pretty elementary and noobish, so any suggestions to improve it are also welcome in the comments :)
EDIT: The output has changed a little, now it just shows the name of the song playing and nothing else. Though sometimes it still shows the wget error.
EDIT2: When i run that gnome terminal command from a terminal, it works. The problem is only when running it with the keyboard shortcut using compiz commands or if i use the run dialog (the alt+f2 one).
The two wget commands should probably have the url variables in double quotes, for example: wget -q -U Mozilla -O 1.txt $link should be wget -q -U Mozilla -O 1.txt "$link"
You need to uriencode your song title so that special characters like '?', '&', '%', and '+' are not passed literally in your URL.
name3=${name2//\?/%3F}
searchq=${name3// /+}
will handle the ?'s. I don't know of a more general solution in bash without resorting to one-line Perl or Python scripts.

Can I get GNU Emacs to TAB complete filenames after using ssh in the *shell* buffer?

I am using GNU Emacs 23.1.50.1 (i486-pc-linux-gnu).
What I want is conceptually simple, [TAB] indicates that I press the
TAB key.
M-x shell
erik#furby:~$ ls
bin Desktop Documents Dropbox R.tools
erik#furby:~$ cd Drop[TAB]
and tab completion works fine (i.e., Dropbox is completed)
However, as soon as I ssh, this no longer works.
ssh erik#remote.edu
Terminal = dumb
erik#remote:~> ls
bin private
erik#remote:~> cd priv[TAB]
and the minibuffer displays
"No completions of priv"
I've found others with the same problems, but
could not discern the solution.
http://www.linuxforums.org/forum/red-hat-fedora-linux/56103-tab-completion-problem-ssh-shell-through-emacs.html
Emacs remote shell
OK, after I posted the question, I stumbled on dirtrack-mode , which appears to have a solution, although not entirely trivial. It uses dirtrack-mode, and the author says:
"It took me a long time to figure out how to get tab-completion working in shell-mode when I was ssh’d into another computer."
It's been annoying me for years; I'm glad I'm not the only one!
This answer to a duplicate worked for me:
C-x C-f /user#host:~ (open a directory on the remote server in dired mode)
M-x shell in the dired buffer
It works with eshell if you instead of doing ssh user#host you do cd /ssh:user#host: however it doesn't seem to work with shell.

Resources