terminal

gnome-terminal (or VTE) sets $TERM to xterm rather than xterm-256color

前提是你 提交于 2019-12-25 16:54:21
问题 Is there a compelling reason why gnome-terminal (and, under the hood, maybe the VTE widget) sets $TERM to xterm rather than xterm-256color ? Clearly it supports 256 colors. For a while, I had a line in my .bashrc / .zshrc to simply export TERM=xterm-256color , because that's usually the terminal emulator that I'm using. But then I open up tmux , and the behavior / colors are wrong in many CLI applications, such as emacs and htop , because tmux will set the TERM variable to screen-256color,

Issue with the installation of gem 'pg' in Heroku - Rails

ε祈祈猫儿з 提交于 2019-12-25 16:44:21
问题 I'm trying to install ruby on rails on OSX for heroku, for which I used this tutorial. It seemed to install fine on the terminal, but after doing $rails new myapp --database=postgresql cd myapp I did this rails generate controller welcome and got an error: Could not find gem 'spring (>= 0) ruby' in the gems available on this machine. Run bundle install to install missing gems. And after following the instructions, I got 'An error occurred while installing pg (0.17.1), and Bundler cannot

How to make Eclipse run my program in a terminal

馋奶兔 提交于 2019-12-25 14:00:39
问题 Sometimes, the console in Eclipse just isn't enough, or my program has to be run in a terminal of some sort. How would I achieve this? I'm using Eclipse Mars 4.5.0 on a MacBook. Edit: I know how to run Java programs from a terminal, but what I want is Eclipse to do this automatically when I press the run button. 回答1: Making Eclipse do it for you isn't possible To do it manually: First, go to the directory with your *.java file. To go to the directory, use the cd command. Then, run javac

OSX 10.7.5 UTF-8 encoding over ssh

こ雲淡風輕ζ 提交于 2019-12-25 13:46:31
问题 I connect to a remote linux machine over ssh and when I view a remote text file with cat command, I see incorrect incoding. It's supposed to show äöü etc, but shows garbage. I tried a luit trick, luit -encoding "UTF-8" ssh remotehost but on Mac it gives error "Couldn't copy terminal settings" Which is a known issue and apparently Apple is not going to fix it on Lion. So I am stuck now. What are the alternatives? 回答1: This is a bug in Mac OS that causes tcsetattr to fail on ptys opened with

Using python under linux to count lines in all the files in a folder via terminal

怎甘沉沦 提交于 2019-12-25 09:20:08
问题 I am using Ubuntu with python 2.7, I need to take all the files in a folder, and count the lines in every file seperatly and dump it to a file. I found how to do it via terminal directly using parallel processing here It crashes when I try: subprocess.Popen('ls %s* | parallel -k zcat {} | wc -l >%s'%(dir,outputfile), shell=True) Now I am trying to use that terminal command via python, seems like it can't take the list of files and use them as files but only to count the length of the files

Spinner in Shell

别等时光非礼了梦想. 提交于 2019-12-25 08:49:45
问题 I found this for BASH, but I want to do the same thing with shell ( #!/bin/sh ). The twist is to make it a timer also, so like wait 60 seconds for example until it ends. 回答1: Fadi's own solution is helpful (and comes by courtesy of Adam Katz's comment on the linked answer), but comes with 2 caveats: The spinner, due to using \r , only works at the beginning of a line. Per POSIX, sleep only supports integral seconds. It may also not be readily obvious where to test for whether the operation is

Assign a function output prints to a variable in python

╄→гoц情女王★ 提交于 2019-12-25 08:12:46
问题 I have a function (in some project) that it prints the result.when I call it from the command line or in another python project, it prints the output on the terminal. But I want to store all the print result in a variable, something like this: output = function_name(function_args) and instead of printing the results on the terminal I want to store them in the output variable. also, the main function returns something(just a number as the status) as the result which i do not want that number.

In the mac terminal - how can I get arrow keystrokes from stdin?

江枫思渺然 提交于 2019-12-25 07:49:40
问题 I'd like to browse a terminal dialog menu with the arrow keys (like bash 'dialog') I would prefer ruby solution, but bash/python could work. read -n1 input # is not good enough, cause the arrow keys are not regular chars. Also, the 'read' in mac term doesn't support smaller timeout than 1 second. Anything? Thanks, 回答1: I am not sure what you are looking for - a way to simulate key presses to an application, or a way to generate simple dialog boxes, or a way to read characters from a keyboard.

Perl hash (could be a hash of hashes)

Deadly 提交于 2019-12-25 06:54:05
问题 working in perl I have managed to write a program that reads from a file usernames. Each username has logged in and out and these logs have been recorded. For example: maclawty796 pts/1 ip-64-134-238-2. Fri Oct 21 14:23 - 14:25 maclawty796 pts/2 10.1.28.122 Fri Oct 21 09:42 - 09:55 ehowe pts/3 10.1.28.204 Fri Oct 21 09:28 - 09:29 As you can see, the users may be logged twice. I am trying to not unify the information of all these accounts by username and month. For example: maclawty796 Oct xxx

Wordpress - Execute Command on New Post

陌路散爱 提交于 2019-12-25 06:50:13
问题 I have a localhost installed version of the latest WordPress on my server, and have begun designing my own plug, but am trying to learn a bit more about how WordPress works first. I'm currently looking for a method to execute a terminal command (or just an application that runs on the server) every time a new post has been created. Even better if possible, to run a different command depending on what category the post was made in. Is something like this possible? Thanks in advance! 回答1: Try