command

Color ouput with Swift command line tool

好久不见. 提交于 2019-12-31 10:36:04
问题 I'm writing a command line tool with Swift and I'm having trouble displaying colors in my shell. I'm using the following code: println("\033[31;32mhey\033[39;39m") or even NSFileHandle.fileHandleWithStandardOutput().writeData("\033[31;32mhey\033[39;39m".dataUsingEncoding(NSASCIIStringEncoding, allowLossyConversion: true)!) It works when I use a simple echo in php (the text is displayed in green) but is there a reason it doesn't work in a Swift command line tool? Thanks! 回答1: Swift has built

Navigating to the earliest/latest command in history when you're in the middle of your history

安稳与你 提交于 2019-12-31 08:41:52
问题 Say I am in a bash terminal and have a large history of commands. I pressed the up arrow a whole bunch of times and am in the "middle" of the history. I want to now navigate to the first or the last command in my history quickly (without holding down the up or the down arrow for a long time). Is this possible? If so, what is the shortcut key to achieving this? 回答1: Take a look in the man page: man bash Here I copied for you the thing you were looking for: previous-history (C-p) Fetch the

Are there shortcut keys for ReSharper's Unit Test Runner?

本小妞迷上赌 提交于 2019-12-31 08:16:13
问题 For obvious productivity reasons, I make an effort of learning and using as many of the keyboard shortcuts for the various Re# commands. However, it seems that the unit test runner does not have any associated shortcut keys. I want to be able to select certain tests and be able to run or debug them without resorting to grabbing the mouse each time. Is using the mouse my only option? 回答1: ReSharper adds items to Visual Studio's keyboard settings dialog box. Go to: Tools -> Options, Environment

Tcsh run command if command was run

家住魔仙堡 提交于 2019-12-31 03:11:49
问题 I'm not really familiar with TCSH I would like run a command2 if a command1 was entered in the shell, something like this: if command1 then echo "Command succeeded" command2 else echo "Command failed" fi I tried this code but it doesn't work. Step two would be to read and print in a file a part some variable that command1 changed (making a kind of history only for some variables). 回答1: You can use $? to get exit code from last command. #!/bin/tcsh # command below can fail or succeed command1

Create Java Command Console in JPanel

落花浮王杯 提交于 2019-12-31 02:08:49
问题 I want to create a "Command Console" similar to the Windows Command Prompt, with command history, etc which is in a JPanel so that it can be added to a JFrame. What I want to do is present the user with the prompt to allow them to execute commands. What I have in mind is similar to the BeanShell Console, however I haven't be able to find the source code for the console. 回答1: To include BeanShell into your application, add the .jar-files from the BeanShell download page to your Java project

Executing Linux command as root in Qt

我只是一个虾纸丫 提交于 2019-12-30 11:28:31
问题 I want to execute a linux command as a root user, from my C++/Qt code. Ultimately a a dialog requesting root pass should be implemented, but for no I can hard-code root password. This is what I done so far: QProcess p; p.start( "dmidecode" ); p.waitForFinished(-1); QString p_stdout = p.readAllStandardOutput(); QString p_stderr = p.readAllStandardError(); And it is working for commands that do not request root privileges. But I want to implement commands like "zypper up" or "dmidecode" which I

Why do the outputs differ when I run this code using NetBeans 6.8 and Eclipse?

对着背影说爱祢 提交于 2019-12-30 10:57:49
问题 When I am running the following code using Eclipse and NetBeans 6.8. I want to see the available COM ports on my computer. When running in Eclipse it is returning me all available COM ports but when running it in NetBeans, it does not seem to find any ports .. public static void test(){ Enumeration lists=CommPortIdentifier.getPortIdentifiers(); System.out.println(lists.hasMoreElements()); while (lists.hasMoreElements()) { CommPortIdentifier cn=(CommPortIdentifier)lists.nextElement(); if (

Python - open new shell and run command

允我心安 提交于 2019-12-30 10:08:32
问题 At the moment I am running a bash command from within Python using the following method: os.system(cmd) However I need to run the command in a new shell/terminal. Does anyone know how to do this? Thanks, Dan 回答1: I am using the following method (this will also redirect stderr to stdout): import subprocess cmd_line = "echo Hello!" p = subprocess.Popen(cmd_line, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) out = p.communicate()[0] print out 回答2: os.system() is deprecated in

Create excel file from command line

回眸只為那壹抹淺笑 提交于 2019-12-30 09:56:11
问题 is there any way to create a new excel file from command line? Thanks in advance. 回答1: If the Excel files you need to create are always the same, you can create a template manually, then create new files at will with something like... copy template.xlsx myNewSpreadsheet.xlsx If you need to create files with content that varies, I suggest starting with the powershell solution proposed by David. 回答2: You can do this using PowerShell: PS> $excel = New-Object -ComObject "Excel.Application" PS>

How can I avoid command clutter in the ViewModel?

ぐ巨炮叔叔 提交于 2019-12-30 06:20:10
问题 I am building an application that uses quite a few commands, and they are cluttering up my viewmodel. MVVM is new to me, so sorry if this question is a bit stupid. Is there a way to reduce the clutter? For example here you can see the a part of the clutter.. private void InitializeCommands() { LogoutCommand = new RelayCommand(Logout); OpenCommand = new RelayCommand(SetImage); SaveCommand = new RelayCommand(SaveImage, SaveImageCanExecute); UploadToFlickrCommand = new RelayCommand