Emacs shell with ZSH, I get weird characters - emacs

I want to use emacs with zsh in debian 8, my locales are es_ES,
uname -a
Linux toshiba-debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1 (2015-05-24) x86_64 GNU/Linux
normally it goes well but sometypes I get Weir characters like ^G or someting like this:
╭─anquegi#toshiba-debian ~/Descargas ‹ruby-2.2.1#laguna›
╰─$ lm
zsh: correct 'lm' to 'ln' [nyae]? ^Gn
n
or
╭─anquegi#toshiba-debian ~/Descargas ‹ruby-2.2.1#laguna›
╰─$ pry
^[[0G[1] pry(main)>
I tried a lot of things like the two first answer here, but nothing works
Weird character zsh in emacs terminal
I do not know what to do next

Related

Zenity won't render Unicode characters

I'm trying to run a simple Zenity dialog where I catch user's input:
zenity --forms --title="Title" --add-entry="Comment"
When I write in ASCII characters it catches them just fine, however, I when I the input contains Unicode characters (namely Hebrew) it outputs them as question marks.
I know for sure that it's Zenity's fault, as if I try to change the title as following: --title="שלום" it would fail to launch altogether.
I'm running on Ubuntu Xenial with all latest patches. Zenity version is 3.18.1.1.
I found the culprit to be Ubuntu's locale settings.
All I had to do to fix this was:
$ sudo locale-gen "en_US.UTF-8"
$ sudo update-locale LANG=en_US.UTF-8 LANGUAGE=en.UTF-8
And reboot.
Edit
As suggested, I'll elaborate a little bit about this fix:
Before changing those values, running locale would show both LANG and LANGUAGE empty.
Typing in Hebrew in terminal would result in question marks.
Nothing in the system seems to have changed, except that now Hebrew can be used in terminal and Zenity.

getopt on linux and solaris

On linux the following operation with getopt works fine:
TEMP=`getopt :mvfuhr:: --long "mask,verbose,force,unmask, help, remask::" -n 'test.sh' -- "$#"`
On Solaris, i am unable use the long arguments to process...
Though the this works:
TEMP=`getopt :mvfuhr:: "$#"`
Looks like the getopt bundled with the solaris is of an older version. How can i make it work like linux? or is there some setting that needs to be done to process long arguments?
Here is a clever (although currently with a minor bug) way to handle this issue:
Using getopts in bash shell script to get long and short command line options

Emacs 256 colors not working using PuTTY and screen

I'm having trouble getting 256 colors to work using emacs 23.1.1 connecting using PuTTY and screen. Server is running CentOS 5.6.
In my PuTTY config, my terminal-type string is set to xterm-256color. In my .screenrc I have term xterm-256color Once in screen tput colors gives me 256, echo $TERM gives me xterm-256color, but once I start emacs M-x list-colors-display only gives me 8 colors.
Not sure what the problem is.
Thanks.
I hit the same problem.
To fix this problem, just add this to ~/.bashrc (yes,I use bash)
# -----------
export TERM=xterm-256color
export TERMCAP=
# ------------
run screen and emacs in an screen window. it's ok now.
versions:
bash-4.2.45
emacs-24.3_10
Screen version 4.00.03 (FAU) 23-Oct-06
Your ~/.screenrc should read:
term screen-256color
(this shouldn't be mixed up with xterm-256color)
Putty has a setting to allow 256 color mode. It's under Window/Colours, labeled "Allow terminal to use xterm 256-colour mode". Make sure it's checked.
After you load emacs, you can confirm the TERM value emacs is using with:
(assoc 'tty-type (frame-parameters (car (frame-list))))
It should be (tty-type . "xterm-256color").
Looking at your post and your responses to others, it sounds like your problem is... screen. To test my hypothesis, try this ...
$ wget http://www.frexx.de/xterm-256-notes/data/256colors2.pl
$ chmod 755 256colors2.pl
$ ./256colors2.pl
... if you see 256 colors in the shell, but not in screen, the problem is screen. And, even if there are other problems, you are going to have to fix screen in order to have any hope of seeing 256 colors in emacs ;)
I recently fixed this situation for myself on a system where I don't have sudo by building a personal copy of screen. Screen is small and it is no big deal to do ... and, IMHO, emacs w/256 colors is well worth the bother.
On Linux 2.6.x I did this:
$ wget ftp://ftp.gnu.org/gnu/screen/screen-4.0.3.tar.gz
$ tar -xf screen-4.0.3.tar.gz
$ cd screen-4.0.3
$ ./configure --prefix=$HOME --enable-colors256
$ make
$ make install
Test the new screen out with ...
$ ~/bin/screen
$ ./256colors2.pl
... if it works, put this in your ~/.bashrc:
PATH=~/bin:$PATH ; export PATH
The screen I ended up with reports being an earlier version ...
$ ~/bin/screen -v
Screen version 4.01.00devel (GNUdf0777e) 2-May-06
... than the version on my system:
$ /usr/local/bin/screen -v
Screen version 4.00.03 (FAU) 23-Oct-06
But while they both claim to support 256 colors...
$ tput colors
256
Only the new build really does. Yeah!
I had similar difficulties, I believe both of these lines were required for screen, putty, and emacs to get along with 256 colors.
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
term xterm-256color
You may also need this line too.
defbce "on"
Speak up if that's still not enough.
Try using emacs in daemon mode instead (emacs --daemon), and open emacsclients (emacsclient -t) instead of using screen/tmux. This will give you one less variable to handle in debugging this.
I was having a similar problem with putty and screen, though not using emacs. Following ataylor's response, I went to Window/Colours in Putty. In there I found and checked 'Use system colours'. This fixed my issue.

zsh in Emacs output junk characters

No matter I use term or ansi-term to start zsh in Emacs, I encounter this problem, whenever I input commands, the output will have some junk characters like:
[ruby-1.9.2] ~ pwd
2;pwd1;pwd/Users/tyraeltong
the 2;pwd1;pwd is screwing the output, don't know whether others are experiencing same problem? I found a similar thread here Getting Emacs ansi-term and Zsh to play nicely but by [[ $TERM == eterm-color ]] && export TERM=xterm I still see the junk characters.
Emacs doesn't play nice with ZLE, so I have this in my ~/.zshrc:
if [[ -n ${INSIDE_EMACS} ]]; then
# This shell runs inside an Emacs *shell*/*term* buffer.
prompt walters
unsetopt zle
fi
Found the solution in the related post mentioned earlier
In a nutshell, in emacs M-x package-install and install multi-term. M-x multi-term kicks off a shell, with all the bells & whistles oh-my-zsh has to offer
It could be an erronious PROMPT_COMMAND that has bash syntax. Try:
export PROMPT_COMMAND=""
and see if that helps.

Grep failing with Emacs (windows), and GnuWin32 Grep

I've downloaded and installed the GnuWin32 tools, and added the grep executables to the Emacs bin. I've also, for what its worth, added the GnuWin32 bin folder to my Path variable.
Problem is though, when I try and run with suggested grep commands, I always get:
Grep exited abnormally with code 53 at Wed Feb 24 17:16:12
For the life of me, I can't find any reference to error code 53 anywhere! :(
I've tried the exact examples on a number of websites for example, when I enter:
M-x grep <ret>
It comes up with
Run grep (like this): grep -n
Which is fine, but I have no idea of what parameters it expects. I've tried some in some tuorials, but I get error code 53 again!
One of the things I've tried is straight from the emacs wiki (http://www.emacswiki.org/emacs/GrepMode#toc2) (maybe not for the windows version though?) and it says to try this command:
M-x grep -n -e setq ~/.emacs
Which I've tried and I get:
-*- mode: grep; default-directory: "c:/[My Directory]/" -*-
Grep started at Wed Feb 24 17:30:47
grep -n -e setq ~/.emacs NUL
Grep exited abnormally with code 53 at Wed Feb 24 17:30:47
So frustrating as this is meant to be a powerful feature of Emacs and I'm really trying to learn it as I've heard good things about it!
Any help would be appreciated! :)
Andy
UPDATE
From the suggestion below, I've tried it via command line and it seems to work fine, perhaps there some config I'm missing?
UPDATE
I've found the command M-x Occur which seems to do much the same as I would image grep does. Are there many extra benefits to using grep over occur if I can't get this working?
Download the dependencies zip file and copy libiconv2.dll, libintl3.dll, pcre3.dll and regex2.dll to Emacs' bin directory.
Copy grep.exe and find.exe to Emacs' own bin directory. Emacs will then use these files over any other executables with the same name, including Windows' own find utility.
Note: if you don't use the installer, you need to download the dependencies zip file as well and copy libiconv2.dll, libintl3.dll, pcre3.dll and regex2.dll to Emacs' bin directory, otherwise you may get an "exited abnormally with code 53" error message.
EmacsWiki: Grep Mode
The exit code of 53 is possibly an OS exit code rather than a grep-specific exit code. For windows this would be "The network path was not found". Are you doing anything over a network path? Are there any missing dll's that grep needs? Can you successfully run grep on the command line?
I had a similar problem and the following worked for me.
Go to the windows console
Enter the command "set" to bring up your system variables
I had shell=c:\progra~1\rational\ration~1\nutcroot\mksnt\sh.exe
Enter "set shell=" to remove the variable
Try Emacs again
Good luck!