terminal

print to the end of terminal

白昼怎懂夜的黑 提交于 2019-12-10 23:09:46
问题 Like this picture of apt-get, how can I print something at the end of the line, just like the speed on the screen. Although I can use escape like \e[C to make it move several columns to the right and print, but the speed varies and the string length varies. Can anyone tell me how to do this? I am currently programming using bash. Thanks. 回答1: Often you will find the width of the console window in the environment variable COLUMNS, but this is not completely reliable. A more reliable solution

When setting terminal attributes via tcsetattr(fd…), can fd be either stdout or stdin?

非 Y 不嫁゛ 提交于 2019-12-10 22:37:56
问题 I have been looking int the man 3 tcgetattr (as I want to change the terminal settings in a program) and found this. int tcgetattr(int fd, struct termios *termios_p); int tcsetattr(int fd, int optional_actions, const struct termios *termios_p); Question: I would like to know what fd should mean? (it seems to be stdin , yet I do not understand why)? Background My comprehension is that terminal is input and output together, as my understanding was that a /dev/tty or /dev/pty yields stdin ,

Term::ReadKey, non-blocking read in raw mode: Detect EOF?

℡╲_俬逩灬. 提交于 2019-12-10 22:19:40
问题 When I pipe stuff into my program, it does not seem to get any character like 0x4 to indicate EOF. $ echo "abc" | map 'cat' saw a: \x61 saw b: \x62 saw c: \x63 saw : \x0A zzzbc ^C I have to press Ctrl+C to quit, but I'm not really sure what the Ctrl+C is acting on. It's probably having the shell send a SIGINT to the pipeline? I don't know how pipelines work on that level. Here is my program map : #!/usr/bin/env perl use strict; use warnings; use IO::Pty::Easy; use Term::ReadKey; use Encode; $

Change Font dynamically in console

醉酒当歌 提交于 2019-12-10 20:36:34
问题 Is there a proper plugin or a class to change font size, font type and decoration within a common output console? You can change terminal's font by going into preferences but that is not what I'm looking for here. I want to be able to change font dynamically from within code. Is there anything in Ruby or some terminal commands to do so (I use Mac OS X). 回答1: The font/font size used in ANSI terminals are implementation specific, and ANSI color/style codes are the only way to provide decoration

Writing code to: start an R session, run R script, terminate session, repeat

安稳与你 提交于 2019-12-10 20:33:01
问题 I am looking for a simple "set it and forget it" way, either as a single string of arguments in terminal or a simple Java program, to automate the following: 1) start an R session 2) tell R to source .R files that contain code for lengthy, parallelized simulations 3) terminate the R session upon completion 4) start a new R session 5) tell R to source other .R files 6) terminate the R session upon completion 7) lather, rinse, repeat My .R scripts will take a total of several days to run,

OSX - always hide certain files

﹥>﹥吖頭↗ 提交于 2019-12-10 19:57:41
问题 I know how to show and hide hidden files in the Terminal - but is there a way to hide certain files like .DS_STORE when showing hidden files? Make certain files super-hidden, so to speak? 回答1: Use chflags with the hidden option ie: chflags hidden fileToHide to hide the file from the Finde and chflags nohidden fileToHide to show the file Please do keep in mind the warning in man page: Only a limited number of utilities are chflags aware. Some of these tools include ls(1), cp(1), find(1),

Run grunt task with node.js arguments on Windows

[亡魂溺海] 提交于 2019-12-10 18:23:39
问题 I am running into an out of memory error when running grunt babel. It is solved on mac by increasing max-old-space-size. However some of our developers are on windows machines and I have not found a way to do this on windows. What is the equilevant of: node --max-old-space-size=10000 node_modules/.bin/grunt babel on windows? Or is there a universal command that works on both? My dependencies: "@babel/core": "^7.1.5", "@babel/preset-env": "^7.1.5", "grunt-babel": "^8.0.0", "grunt": "^0.4.5",

sbt: Can't run interactively from mintty on cygwin

我们两清 提交于 2019-12-10 18:12:48
问题 When I run sbt interactively from a DOS shell or from a cygwin bash terminal, it functions just fine. However, when I try to run from my preferred mintty terminal, sbt doesn't respond to my commands until I send it an end of file (control-) and sbt exits. TERM is set to cygwin when I'm using the bash terminal, and it's xterm when I'm using mintty. Does anyone know how to fix this? 回答1: It ends up that by doing the opposite of this answer, I added the -Djline.terminal=jline.UnixTerminal java

How to compile and run C/C++ in a Unix console/Mac terminal?

拟墨画扇 提交于 2019-12-10 18:07:06
问题 How can I compile/run C or C++ in Unix console or a Mac terminal? (I know it, forget it, and relearn it again. Time to write it down.) 回答1: If it is a simple single source program: make foo where the source file is foo.c or foo.cpp, etc. You dont even need a makefile. Make has enough built-in rules to build your source file into an executable of the same name, minus extension. Running the executable just built is the same as running any program - but you will most often need to specify the

Why does the code . shortcut not work on OSX?

▼魔方 西西 提交于 2019-12-10 18:03:24
问题 I've tried adding the 'code .' shortcut to launch your current directory in Terminal in Visual Studio Code, but I was promptly returned the following error: LSGetApplicationForInfo() failed with error -10814 while trying to determine the application with bundle identifier com.microsoft.VSCode. Visual Studio Code is installed on my machine successfully. I'm using OSX Yosemite 10.10.3. Does anybody know how to get this shortcut to work correctly? 回答1: Make sure you have Visual Studio Code 0.3.0