I am getting very strange outputs from my IRB console. Here it is:
irb(main):001:0> File.dirname(__FILE__)
=> ←[0;31m"←[0;0m←[0;36m.←[0;0m←[0;31m"←[0;0m
Seems like an encoding issue, right? I am not sure why this is happening. Any ideas how to fix it?
Those are escape codes used to set colors in a terminal program; probably most popularly to colour a prompt in an xterm or compatible terminal. My bash prompt environment variable, for example, looks like this:
PS1="\[\033]2;\w\007\]\[\033[0;31m\]\u#\h \[\033[0;32m\]\!\[\033[0;31m\]> \[\033[0m\]
It looks like some string like that one is getting into your console and confusing it (since it's not bash and/or in an xterm-friendly terminal emulator, I guess).
As Carl and Mike pointed out, that's color information. You can have the colors actually show up if you install ANSICON. Wirble and Cucumber showed up with colored text in their output in a dos box on my Windows machine once I installed that.
Related
When I run a Javascript file with Deno ...
// file.js
console.log(42)
... doing deno run file.js, then Deno prints ...
←[33m42←[39m
... to the standard Windows 7 console (cmd.exe). What is this, and how can I disable this?
On Windows 7 code coloring is not supported in the standard cmd.exe, resulting in these strange characters.
Solution
If you add an environment variable NO_COLOR=true Deno will not try to color the output anymore and the weird characters will disappear. If you remove the variable again you may have to restart Windows in order to get back the coloring.
See also deno help where I got this from.
A helpful tool to edit environment variables is RapidEE.
If you want the colors, try out a console emulator like for example cmder.
when I try to introduce something the console with bin / console, for example:
php bin/console doctrine:generate:entity
The output of cmd returns these characters
How can i fix it?
What you see are ANSI color codes. Linux and OS X systems should support them natively.
But on Windows, you'll either need to use an emulated terminal like Cygwin or a Windows implementation of an ANSI capable terminal, like ANSICON to see the output as it was meant to be. Also see the note in the documentation about this for further alternatives/possibilities.
I just switched to a windows machine and I'm trying to get fish configured correctly. I installed it through the default route, as a shell selected through cygwin setup. It seems to be working fine, but when I directly access fish.exe or run fish.exe through IntelliJ, it outputs a ? before very prompt:
I googled and found this on fish documentation FAQ:
I'm seeing weird output before each prompt when using screen. What's wrong?
Quick answer:
Run the following command in fish:
echo 'function fish_title;end' > ~/.config/fish/config.fish
Problem solved!
The long answer:
Fish is trying to set the titlebar message of your terminal. While
screen itself supports this feature, your terminal does not.
Unfortunately, when the underlying terminal doesn't support setting
the titlebar, screen simply passes through the escape codes and text
to the underlying terminal instead of ignoring them. It is impossible
detect and resolve this problem from inside fish since fish has no way
of knowing what the underlying terminal type is. For now, the only way
to fix this is to unset the titlebar message, as suggested above.
Note that fish has a default titlebar message, which will be used if
the fish_title function is undefined. So simply unsetting the
fish_title function will not work
So it appears that intelliJ and cmd (fish.exe runs in cmd.exe if you access it directly) do not support setting the title bar, so they just output the character to the terminal instead. However, their suggested solution does not work. I've tried various options like echoing an empty string or a space, but nothing gets rid of that darn question mark.
Has anyone else run into this and found a solution?
Notes:
It doesn't have this behavior when using fish through mintty.exe,
most likely since that terminal supports setting the title, but I really prefer
to use the terminal inside intelliJ instead of having it in a
separate window.
It didn't have this problem when I used fish through IntelliJ on Ubuntu or MacOSX, it appears to be isolated to Windows
I'm writting a Ruby program for windows, and I need to read user input from keyboard (stdin).
However, it's needed that the user key-presses are not automatically displayed in the windows console, and behave like "silent key presses"
This problem in Ruby over linux, can be solved using the "stty" linux command:
%x{stty -icanon -echo}
because it is the linux terminal who automatically outputs the user-keys into the terminal, so running the "stty" command tells the terminal to stop showing the user-key-presses.
But my program must run in windows, so I tried searching for a "stty" equivalent command for windows console, but still found nip...
?any suggestions, pointers ?
Look at Highline gem. To clarify, look at ask method and provide a block to silence it's output. It is well exemplified in their documentation
This is related to this question : How to get coloured file listing in windows cmd shell ?
I'm trying to get, wouldn't you believe it, coloured file listing in windows cmd shell. Windows are XP SP2, if that matters.
In the old DOS days there used to be little programs like hdir, adir and such which displayed that nice. Nowadays, such programs are no more.
There is however, ls, from unixkit-tiny or unixtools. Unfortunatelly, it uses ANSI escape codes for displaying colours, and cmd doesn't handle those too well.
There are several solutions which include loading ansi.sys and command.com, but command.com doesn't handle long filenames that well, and is awfully slow. Even then sometimes it has problems displaying colours.
So what I'm asking, is there a way to get coloured file listing in windows cmd shell, apart from using cygwin ? Or is there a way to get ANSI escape codes to work with cmd.exe in a way so that native ls will play nicely ?
I ran across ANSICON at http://adoxa.110mb.com/ansicon/index.html ansicon github repo
Using it to colorize NAnt output. ls --color is being processed correctly.
Source code is provided, but I haven't examined it.
Actually I reckon A+ for ansicon -- Use
ansicon.exe -I
Installs it as a filter on your CMD.exe sessions. Works a treat with HTTY (ruby gem).
:-)
You could start the builtin Telnet server, firewall it to only allow localhost access, and use a telnet client that understands such escapes - even the native one. (I know, an ugly hack.)
It's possible to patch cmd.exe....
http://gynvael.coldwind.pl/?id=130&lang=en