terminal

How do I get width and height of my terminal with ioctl?

大兔子大兔子 提交于 2019-12-24 00:55:53
问题 What do I have to change to make this work? #!/usr/bin/perl use 5.012; use warnings; require "/usr/lib/perl5/vendor_perl/5.12.1/x86_64-linux-thread-multi/sys/ioctl.ph"; my ($rows, $cols, $xpix, $ypix); my $winsize = "\0" x 8; my $TIOCGWINSZ = 0x40087468; # should be require sys/ioctl.pl if (ioctl(STDOUT, $TIOCGWINSZ, $winsize)) { ($rows, $cols, $xpix, $ypix) = unpack('S4', $winsize); } else { say "something didn't work" and exit; } Inspired by tchrist's answer in From column to row. 回答1: This

print delay with pexpect: select returning stdin when no data ready to read

拥有回忆 提交于 2019-12-24 00:52:22
问题 Using pexpect I'm running Python in a subprocess. When the program below is run, I have to hit a key before the >>> prompt is displayed. I previously was using a naive version of pexpect, but switched hoping this would fix the problem. In this naive version, the problem was that select.select() returned stdin as ready to read when in fact it wasn't, as a blocking read on stdin was attempted, blocking the program until I hit a key. I suspect the same thing is happening here. How do I prevent

Which character encoding is the IPython terminal using?

泪湿孤枕 提交于 2019-12-24 00:22:46
问题 I used to think I had this whole encoding stuff pretty figured out. I seem to be wrong because I can't explain what's happening here. What I was trying to do is to use the tabulate module to print a nicely formatted table using from tabulate import tabulate s = tabulate([[1,2],[3,4]], ["x","y"], tablefmt="fancy_grid") print(s) in IPython 3.5.0's interactive console under Windows 10. I expected the result to be ╒═════╤═════╕ │ x │ y │ ╞═════╪═════╡ │ 1 │ 2 │ ├─────┼─────┤ │ 3 │ 4 │ ╘═════╧════

How to print the python code of a function to the terminal? [duplicate]

你。 提交于 2019-12-23 23:52:34
问题 This question already has answers here : Python reflection - Can I use this to get the source code of a method definition (4 answers) Closed 6 years ago . I've got a system in which I constantly experiment with the contents of a function, after which I run the program. Since I often have many terminal windows open, I sometimes don't exactly know which version of the function belongs to which terminal window. Is there a way to print the source code of a specific function to the terminal? 回答1:

How to send control C to Mac Terminal using python?

匆匆过客 提交于 2019-12-23 22:23:38
问题 I have a python script that needs to send control C to the mac terminal. I've tried sending the plain text "^C" but I get back that the terminal does not recognize the command. (The terminal meaning the pseudo terminal that python creates) Basically, I am using the terminal to run an old Unix Executable and the only way that I can think of to terminate this gracefully is to send the interrupt signal. Is there any way I can fool the terminal into thinking that I pressed control C? Thanks in

Slow tab switching in Vim with large terminal

亡梦爱人 提交于 2019-12-23 19:43:49
问题 My vim is very slow to switch tabs ( :tabnext ) when i've fullscreened my terminal (1920x1200). Does anyone have a fix for this? Is it a vim issue, or is it my setup? Redrawing a black terminal (gnome-terminal) with a bit of text shouldn't be that hard. 回答1: It is probably the gnome-terminal problem. Vim with my fullscreen (1920x1080) rxvt-unicode (urxvtc) terminals works just fine. 来源: https://stackoverflow.com/questions/2864084/slow-tab-switching-in-vim-with-large-terminal

Command that works in local computer, but doesn't work in server?

江枫思渺然 提交于 2019-12-23 19:28:00
问题 I am using ubuntu 10.04 for my desktop and Ubunt 10.04 server edition ofr my server. the following commnad: sudo pip install -e git+http://github.com/facebook/python-sdk.git#egg=facebook Works on my deskotp, but doesnt work on the server. On the server, I received the following error message: Obtaining facebook from git+http://github.com/facebook/python-sdk.git#egg=facebook Cloning http://github.com/facebook/python-sdk.git to ./src/facebook Exception: Traceback (most recent call last): File "

Delete an unreferenced image from repository in Xcode

白昼怎懂夜的黑 提交于 2019-12-23 18:42:10
问题 I deleted default.png from my resources folder because I wanted a different image for the loading screen, but I just deleted the reference which was apparently a dumb thing to do. I dragged the new image into resources and tried to change the name to Default.png, but it won't let me, which I think is because the first Default.png is still in the repository somewhere. Anyway, how do I delete that image(and others with which I have probably done the same thing) from the repository when it is no

Bash terminal colors in integrated terminal in VS Code

こ雲淡風輕ζ 提交于 2019-12-23 17:59:46
问题 I'm on a windows 10 machine and I recently installed VS Code to use instead of Sublime Text 3. I changed the integrated terminal in VS Code to default to git Bash. That is working just fine now but I seemed to have lost my color coding for files and directories. I tried adding eval "$(dircolors -b /etc/DIR_COLORS)" to my .bash_profile but it still doesn't work in the integrated terminal, however if I open Bash externally all of my colors are still there. 回答1: I was able to get colors to work

Execute C program till Ctrl+C hit in the terminal

佐手、 提交于 2019-12-23 17:50:35
问题 I am writing a program that repeatedly does an operation till Ctrl+C is hit by the user in the Linux terminal. I am programming in C. Any ideas how i can implement this. I have tested my program by using "for" loops with a condition but now i want to make it run as long as Ctrl+C is hit by the user and interrupted. What I was thinking was of writing a do while loop like the following do{ / Computation / } while(Ctrl+C is not hit) But i dont know how to check for the Ctrl+C input from the user