Console2 not using PS1 colours - cygwin

I am using Cygwin in Console2 with the following PS1
export PS1='\[\e]2;\w\a\e[1;32m\e[40m\n\w\n\d - \# > \[\e[0;00m\]'
The prompt has the correct text content, but all the colors are ignored.
~/wd
Tue Mar 18 - 01:14 PM >
Screenshot showing Console2:
When I use mintty, the colours are perfect.
TERM is set the same in both Console2 and mintty:
Tue Mar 18 - 06:29 PM > env | grep TERM
TERM=cygwin
TERMCAP=SC|screen|VT 100/ANSI X3.64 virtual terminal:\

You have not show your screenshots. So I'm not sure what do you meaning.
But I believe it is cygwin feature (bug). It thinks that ANSI is not available in Windows terminal (that is true for Console2, but of course not if you are using ANSICON or ConEmu). That means that cygwin process all ANSI sequences internally (it does not send them to the terminal). So, if any problems happens, that all is cygwin implementation problems.

Related

emacs shell interprets ipython characters wrongly

I'm using gnome-terminal, emacs -nw, eshell inside emacs, and ipython.
For some reason the emacs shell is interpreting characters wrongly.
Here's what I see (plese note the last 3 lines):
$ ipython
Python 3.5.2 (default, Jun 28 2016, 08:46:01)
Type "copyright", "credits" or "license" for more information.
IPython 5.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
^[[?12l^[[?25hprint("hi")
^[[J^[[?7h^[[?12l^[[?25h^[[?2004lhi
^[[?12l^[[?25h
I believe this must be some encoding problem, but I'm not sure how to diagnose and fix it.
Here's my env output if it helps:
$ env
XDG_VTNR=2
XDG_SESSION_ID=c3
TERM=xterm-256color
SHELL=/bin/bash
XDG_MENU_PREFIX=gnome-
VTE_VERSION=4402
GJS_DEBUG_OUTPUT=stderr
WINDOWID=29360134
GJS_DEBUG_TOPICS=JS ERROR;JS LOG
USER=adrin
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
SESSION_MANAGER=local/mydarlingarch:#/tmp/.ICE-unix/498,unix/mydarlingarch:/tmp/.ICE-unix/498
USERNAME=adrin
MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
MAIL=/var/spool/mail/adrin
DESKTOP_SESSION=gnome
QT_QPA_PLATFORMTHEME=qgnomeplatform
XDG_SESSION_TYPE=x11
PWD=/home/adrin
LANG=en_US.UTF-8
GDM_LANG=en_US.UTF-8
GDMSESSION=gnome
XDG_SEAT=seat0
HOME=/home/adrin
SHLVL=1
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
XDG_SESSION_DESKTOP=gnome
LOGNAME=adrin
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
WINDOWPATH=2
XDG_RUNTIME_DIR=/run/user/1000
DISPLAY=:0
XDG_CURRENT_DESKTOP=GNOME
COLORTERM=truecolor
XAUTHORITY=/run/user/1000/gdm/Xauthority
_=/usr/bin/env
Thanks to #brian-malehorn, the problem was indeed the control characters sent by ipython.
This could be checked by trying to echo a colored text using echo -e '\033[0;31mhello\033[1;0m', which in my case printed a colored text. If the problem was the colored text, it could be fixed by:
ipython --colors=NoColor
My problem however, was not the above, therefore it must have been control characters sent by ipython to the shell. This can be disabled using:
ipython --simple-prompt

Interactive TCL shell shows no output in cygwin

I am running Vivado in TCL mode under cygwin and noticed that I do not get any output in return to some commands I enter.
The commands which do not return anything seem to be non-builtins or commands which require OS interaction, as far as I can tell.
Consider the following example:
$ vivado -mode tcl
puts HelloTcl
****** Vivado v2015.4.2 (64-bit)
**** SW Build 1494164 on Fri Feb 26 04:18:56 MST 2016
**** IP Build 1491208 on Wed Feb 24 03:25:39 MST 2016
** Copyright 1986-2015 Xilinx, Inc. All Rights Reserved.
HelloTcl
puts 2
2
expr 1 + 2
puts 5
5
help synth_design
read_vhdl
ERROR: [Common 17-163] Missing value for option 'files', please type 'read_vhdl -help' for usage info.
package require Tcl
pwd
exit
exit
INFO: [Common 17-206] Exiting Vivado at Fri Jul 14 13:44:28 2016...
The commands which did not return the expected output are expr 1 + 2, help synth_design and pwd (and possibly package require Tcl).
The situation is the same with the "normal" tclsh.
Can anyone help me understand what the reason of this behavior is?
My OS is Win7 Pro 64bit. Everything works fine with cmd or Powershell. The behavior is also as expected when running Vivado in a terminal under Linux.
It would seem that vivado is only writing values out when you explicitly ask for it, unlike with a standard interactive tclsh which also writes out the result of each command (provided it isn't the empty string). You need to write an explicit puts […].
puts [expr 1 + 2]
puts [pwd]
As long as you know about it, I guess it's not too big a deal. Just a bit annoying.

Percent sign in bash is not typeable

I have a strange problem: I cannot type or copy the percent sign in my bash...
I tried to read ~/.bashrc, /etc/profile (and stuff in /etc/profile.d). I also tried "sudo bash", but still not possible to type "%". Percent sign in "sh" works...
Any suggestions?
uname -a
Linux 3.2.0-65-generic #99-Ubuntu SMP Fri Jul 4 21:03:29 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
BTW: Question moved to: https://superuser.com/questions/890645/percent-sign-in-bash-is-not-typeable
A workaround is using the ascii value 37: Press and hold the ALT-key, enter 37 on your numeric keyboard and release the ALT-key.
A solution is checking the keyboard mapping. Hold the shift and try all the numbers. On my keyboard I have
!##$%^&*()
Do you have an old keyboard somewhere that you could try?
I had a similar problem with the mapping of the backspace button. Instead of deleting previous characters while editing files it would appear "^?" . I used "stty sane" in the command line and it was reset. Maybe that helps.

Unwanted control characters displaying in vimscript function output

[using MacVim 7.3 on OS X Lion]
I have a vimscript function which runs an external command. It's executing correctly, but the output displays (unwanted) control characters, such as [0m, [33m, [36m, and -1H. The relevant line in the vimscript function is:
exec ":!bundle exec rspec --color " . a:filename
Which produces:
:!bundle exec rspec --color spec/acceptance/user_logs_in.feature
[33m*[0m
Pending:
[33m User logs in [0m
[36m # the step 'the user "foo#test.host" exists' is not implemented[0m
[36m # [0m
Finished in 0.07121 seconds
[33m1 example, 0 failures, 1 pending[0m
Here's what the same command and output look like from the terminal, which is how I want it to display in vim:
$ bundle exec rspec --color spec/acceptance/user_logs_in.feature
*
Pending:
User logs in
# the step 'the user "foo#test.host" exists' is not implemented
#
Finished in 0.1161 seconds
1 example, 0 failures, 1 pending
Also, any time I execute and external command, vim displays -1H immediately after it. For example, if I type:
:ls<return>
I see:
:ls-1H
<rest of the output is as expected>
Any ideas on hiding those control characters and -1H.
(disclaimer: I'm very new to vim so please don't assume too much background knowledge on my part.)
Thanks.
Update 3/31/2012 # 17:32 PM
Sam Goldman's correct: MacVim doesn't know how to display colors, so it outputs the color codes.
I've switched to terminal vim (which supports colors, at least with iTerm), but using the version of vim that comes with MacVim, which is more up-to-date and is compiled with ruby support (among other things). The easiest way to do that is:
brew install macvim --override-system-vim
MacVim doesn't know how to display colors. Terminal vim will display the colors correctly, or you can add --no-color to your rspec command (or a .rspec file). I'm not sure about the -1H thing. Maybe some customization you have for your terminal?

What exactly does "locale" do on Mac OS X and/or other Unix/Linux OS

Reading
man locale
I figure that that locale displays information about the "current locale" or a list of all available locales.
In addition, running
$ locale
gives...
LANG=
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
However, neither the man nor running it actually sheds a light on what these environment variables do. I would like to ask specifically what these environment variables are needed for or used for? (say for example in the context of a software running on this unix/linux OS that has these environment variables)
The Question: What does that mean in the context of a software that is running on the OS with these locales?
Oh, the man page (man 1 locale) does:
LC_CTYPE
Character classification and case conversion.
LC_COLLATE
Collation order.
LC_TIME
Date and time formats.
LC_NUMERIC
Non-monetary numeric formats.
LC_MONETARY
Monetary formats.
LC_MESSAGES
Formats of informative and diagnostic messages and interactive responses.
Perhaps, you had a look for the 'locale' manpage in the wrong section? These are the standard sections (see man man)
0 Header files (usually found in /usr/include)
1 Executable programs or shell commands
2 System calls (functions provided by the kernel)
3 Library calls (functions within program libraries)
4 Special files (usually found in /dev)
5 File formats and conventions eg /etc/passwd
6 Games
7 Miscellaneous (including macro packages and conven-
tions), e.g. man(7), groff(7)
8 System administration commands (usually only for root)
9 Kernel routines [Non standard]
so, for the locale binary, you have to look in section 1: man 1 locale. To fully answer your question, I cite the description part of locale's man page:
DESCRIPTION
The locale utility shall write information about the current locale
environment, or all public locales, to the standard output. For the
purposes of this section, a public locale is one provided by the imple-
mentation that is accessible to the application.
When locale is invoked without any arguments, it shall summarize the
current locale environment for each locale category as determined by
the settings of the environment variables defined in the Base Defini-
tions volume of IEEE Std 1003.1-2001, Chapter 7, Locale.
When invoked with operands, it shall write values that have been
assigned to the keywords in the locale categories, as follows:
* Specifying a keyword name shall select the named keyword and the
category containing that keyword.
* Specifying a category name shall select the named category and all
keywords in that category.
Samples (LC_TIME and LC_MESSAGES):
$ export LC_TIME='fr_FR.UTF-8' #french time
$ date
mar. août 30 18:41:07 CEST 2011
$ export LC_TIME='de_DE.UTF-8' #german time
$ date
Di 30. Aug 18:41:12 CEST 2011 #english time
$ export LC_TIME='en_US.UTF-8'
$ date
Tue Aug 30 18:41:17 CEST 2011
$ rm NON-EXIST
rm: cannot remove `NON-EXIST': No such file or directory
$ export LC_TIME='de_DE.UTF-8' #german time, but english MESSAGES
$ rm NON-EXIST
rm: cannot remove `NON-EXIST': No such file or directory
$ export LC_MESSAGES='de_DE.UTF-8' #german messages
$ rm NON-EXIST
rm: cannot remove `NON-EXIST': Datei oder Verzeichnis nicht gefunden
LC_COLLATE is for sorting information according to a language. LC_MONETARY is the format for currency (US: $1.24, europe: 1.24 €)
Locale governs a lot of things, such as:
Encoding in use (i.e., en_US.UTF-8, or some other classic encoding)
Translation files to use for the standard library or other applications.
Internationalization (number formatting, currency, dates)
The C locale is the "default" locale. It is generally advisable to be more specific, and run as something UTF-8 enabled on Linux.

Resources