Is it possible to colour the console output with OCaml on Windows ?
It seems to be possible on a linux terminal : print_string "\027[31m blabla" but I cannot find any information regarding the Windows console.
Using ther Vanilla windows tooling..
Color management is not possible by default using the command ( ms dos ) console emulation.
Out of the box, the best you can get is by using the PowerShell command line interface instead and to configure the colors like explained in this page.
In an opened terminal:
write-host -foregroundcolor Red "Hello"
will result in Hello printed in Red ...
But this is not convenient at all..
A better solution provided by an external tool
The easiest way is to uses an external tool to do the job, but you'll need to install a kind of windows command line extension.
A nice project can be found HERE it's called ANSICON and will directly interpret the ANSI codes the same way the Linux modern terminal emulators does.
You may be interested in ANSITerminal
. I do not remember how good the Windows version is — I personally do not use that platform — but do not hesitate to fill issues or submit pull requests.
If you are looking for ANSI color support (and more) in cmd.exe you can use clink.
Related
This question is very close to the following question:
Is it possible to output on multiple terminal windows within a single C program?
Yeah, I removed the the letter c. The above link shows how to do this on linux.
I was wondering, can this be done on windows and osx as well?
And if so how?
And also, can it work with "third party" terminals, like iTerm on osx or cmder on windows?
The language preferred to achieve this is java, but not required.
if i correctly understand, you need to create pipe to the terminal window, in order to send data to it. If found a link for you, which may help. spawning a new terminal and writing to its output
I'm the uninformed user. I want to use mercurial for my personal use in terms of writing code and writing papers and have every change be accessible. I'm not a programmer by trade, I run a lot of matlab code and that's it as far as programming experience goes. I've installed the TortoiseHg with Windows Explorer "shell" integration all-in-one package. I already have python 2.7 installed too.
Next I went to this tutorial: https://www.mercurial-scm.org/wiki/TutorialInstall and I got lost right away. They say the mercurial program is called hg, so I type so in the search function and it comes up, I open it and a quick command window opens up and closes in a fraction of a second and that's it, nothing else happens. I read a bit further into the tutorial and they say that you have to type hg in the prompt. I tried windows powershell and this did work but I don't know if I was supposed to be doing this from within some hg prompt or something.
I went to the next step of the tutorial and they go through the steps of making a repository. I blindly typed the commands they have setup and it worked until I typed "ls -a" saying that it's not a recognized cmdlet.
I don't know what I'm doing and I need a better resource that helps me get this set up and running as I don't understand why even opening "hg" does apparently nothing or if even I should be using powershell for the tutorial.
Mercurial is mainly used by people who are programmers by trade...so all the tutorials are written for programmers, and therefore assume a certain understanding of how command line applications work.
I suspect you're not that familiar with the command line, so first of all, I second user694733's comment:
For a beginner, the TortoiseHG GUI is way easier to get started.
(and they have excellent documentation as well)
Anyway, here's why the command line didn't work like you expected:
hg is a command line application. When you directly start it from Windows (which you did by typing hg in the Windows start menu), it behaves like you described: it pops up and immediately disappears. You need it to start from the Windows command line instead.
There are two different command lines in Windows:
a) Windows PowerShell, which you already used
b) the "classic" Windows command line, which you can open by typing cmd into the search box in the Windows start menu
There's no special "hg prompt", it's just that you're supposed to run hg in one of the two command line interfaces I listed above. It doesn't matter which one you use - hg behaves the same in both.
it worked until I typed "ls -a" saying that it's not a recognized cmdlet.
Mercurial does not only work on Windows, but on other operating systems as well (Linux and Mac OS, for example).
The hg commands are the same everywhere, but everything else is different depending on your operating system. For example, ls is the Linux command to list the content of a directory. In Windows, it's dir instead.
Most, if not all, of the Mercurial developers don't use Windows, so their tutorials are not written with Windows in mind.
You should really start with TortoiseHG, as mentioned above (its documentation is Windows friendly, too) or if you really want to use the command line, I'd suggest a different tutorial, Hg Init, which was written by a Windows guy (Joel Spolsky, the CEO of Stack Exchange, the company that runs Stack Overflow).
In the past, I have used MATLAB sparingly from Linux machines at work, and I far and away preferred using the '-nodesktop' option. On all Unix-like machines I've worked on this option allows me to control STDIN and STOUT with relative ease, but on Windows(using Cygwin) this option spawns a new window and control is returned to the calling shell!
Basically, I would like to know if there is any way that I can force MATLAB to behave as it would on a Unix-like machine?
Thanks!
Short answer: You can not.
A longer answer can be found on their website.
-nodesktop behaves differently depending if you are on Windows vs
Linux or Mac. On Windows we provide a boring Command-Window only
interface that lacks the “bells and whistles” of the regular Command
Window or the full Desktop.
So you can use -nodesktop, but it pops up that annoying command line only window.
I have a lot of perl scripts that are on infinite loop running on my windows system. It is terribly inconvenient to have that many command prompts open not to mention the likelihood of closing them by mistake(strangely, they also seem to pause when I click on the prompt)
Is there someway I can handle this? Like maybe minimize this to the tray and maximize whenever necessary?
If it is of any use, I use activeperl
You can use Console2 utility, which is a Windows console window enhancement, it has a multiple tab feature.
Install GNU Screen. You can get it for Windows as part of Cygwin. You can then have multiple command line shells running in a single window, and can detach that window to run in the background.
Have you considered Win32::Daemon?
Looking for a better Windows XP command-line interface. The Visual Studio Command Prompt isn't near as nice as the Linux/OSX terminals.
Thoughts?
edit:
Answers: Console on Sourceforge, and the Windows Powershell. Thanks, I'll go dig them up and evaluate them.
The Cygwin package is too much overhead for what I want.
edit2:
Looks like the Windows Powershell for now. Its copy&paste functionality isn't great, but MS supports it.
Take a look at Console2 http://sourceforge.net/projects/console/
It's features:
"multiple tabs, text editor-like text selection, different background types, alpha and color-key transparency, configurable font, different window styles"
As has your question been tagged, have you tried Windows PowerShell? It's paradigm is based on unix's pipes but instead of outputting text the processes output .Net objects.
cygwin? www.cygwin.com. Or mingwin?
Cygwin
This is an answer extending line.
I'm not clear on what you mean by Linux/OSX command prompts being "nice". If you just mean that they provide more utilities, I usually install Windows Services for Unix to add common programs like grep and vi.
I see you put "powershell" as one of your tags. Maybe you could help direct our answers by explaining what you don't like about PowerShell as a replacement for cmd.exe?
I use Take Command from JP Software
Cygwin is a good alternative. You can run Bash or other shells on Windows. You get most of your classic Linux/UNIX commands, shell scripting, etc. You even get the GNU compilers and can avoid Visual Studio if you wish. From Cygwin, you can access your regular Windows programs, drives, etc so there's rarely a reason to go back to cmd.exe.
If you are just looking to automate tasks via shell scripts (not interactive shell), then you should look at Windows Scripting Host. WSH is a feature-rich scripting environment for Windows that comes pre-installed on all modern versions of Windows.
I've been combining putty, cygwin, screen, and zsh(not bash) lately. I like a lot of the features of zsh, like autocd which and auto-pushd, which put the directories you change into onto the directory stack without having to type pushd. I also like that fact that multiple shells share history, and don't overwrite each other. Screen lets me run multiple zsh shells in one putty window. You can get zsh and screen from the cygwin site. I run: putty -cygterm screen
You'll also need the patched version of putty that has the -cygterm support.
GitBash by git is also a good option. It can be configured to be used in unix like environment.
It can be downloaded from here http://msysgit.github.io/