I have a PyQt application where it spawns an XTerm window in a widget.
The XTerm window is launched with -e vim <file> which immediately runs Vim displaying the file for edit, etc.
When I hit :w! in Vim, I'd like to somehow catch that event and echo it
back to XTerm, and/or ultimately back to PyQt, so that I can modify another UI element.
I do know how to use a Vim autocmd to catch :w! (BufWritePost) and execute a shell script,etc...
...but I think I need to have Vim echo back, either with simple ASCII text or via a SIGNAL, back to the XTerm window and hopefully back to the QProcess.
So I think the key is figuring how to tell XTerm to do this, but I'm a bit stumped and open to any and all suggestions about how to accomplish.
Thanks to all in advance.
Your script would have to take into account that XTerm will not do the echoing (text echoed/printed in the terminal goes to the terminal's screen). Your script would have to either make vim echo something to a file, or run vim (in xterm) from a helper script that would pass the information back in a file.
Usually this is done by allocating a temporary file in the parent process (your PyQt application), and passing its name to the child process.
Related
Using Automator on OSX
Passing selected files/folders to rsync using a service. It is working and copies are succesful. Although want two things to happen and one question as to how to reference the "current" users desktop in the destination.
Want it to open terminal and visibly show the copy process with the --progress option that rsync offers. A GUI window would be nice but wanting simple for now.
Would like a simple "completed" message to be displayed somehow. Either in the terminal window or a GUI message.
Where the First.Last is used in the destination path, how can this be defined to simple use the current users desktop?
Below is what is working now but without the 3 things mentioned above.
for f in "$#"; do
/usr/bin/rsync --verbose --progress --times "$f" /Users/First.Last/Desktop/copy
echo "$f COMPLETED"
done
Thanks for any and all suggestions.
I am operating in a linux environment (not familiar to me) and I am handling a bunch of files in django. Bit embarrassing but I seem to have done something subtle to the server that disallows me from setting up separate work stations from my terminal... i.e. emacs file.py & won't work for me; it just says that the emacs window is loading but it won't actually appear - I've waited 5 minutes.
It's not a big deal as emacs file.py works fine and I can "Reset terminal" once I'm done editing the file. However, saving the file could be a problem as the saving options are different between the "&" and "without &" versions of the command. It's such a basic thing that there seems to be no info on it online... any tips?
NOTE: it all started when I mistakenly typed emacs file.py and forgot the & and now something seems to be irreversibly changed that logging in and out again doesn't fix...
When using emacs in a text terminal, start it without the &, you need to run it in foreground. To save a file, use the standard C-xC-s (if your terminal interprets the keystrokes differently, you have to configure the terminal). After saving the file, you can get back to the shell by pressing C-z. It would stop emacs, but you can get back in by typing fg or %em or similar.
To quit emacs, use C-xC-c.
On a Chromebook (Dell Chromebook 11), using Vim, I saved a file to /home/user/filename.txt . How can I get that content anywhere else in the world?
gmail attach a file does not let me go to /home/user
copy with Ctrl-C within Vim does not result in my text being in the paste buffer
I can see file:///home/chronos/user/Downloads/ in a browser, so if I could save content to /home/chronos/user/Downloads from Vim, I could get text out, but I can't do that.
In sum, I'd like any way to get the content of filename.txt anywhere outside the machine (cut and paste available in a browser, moving the file, resaving to a thumb drive). Thanks for any help.
file:///home/chronos/user/Downloads/ is literally the same Downloads folder. However, you can do that with terminal as well (if you're linux geek, this should be pretty simple)
Since you said you were using Vim, I assume that developer mode is on. In the shell, you can make use of mv linux command to move it to downloads.
mv /your/path/to/file.txt ~/Downloads/file.txt
Cheers!
I'm using Ubuntu and Qt Creator 4
I have a .cpp program in the executable form (say abc.out) that I wish to run when I press a button. It contains a number of cin and cout, so I want it to run on a "terminal" (on Ubuntu) so that I am able to input and output values to it. How can I do that?
I've tried system() and
also,
QProcess p1;
p1.start(./abc.out);
Using QProcess, my executable runs but stops at the first cout. It runs on the application output screen in Qt Creator and not on terminal.
For example:
I see on application output:
enter name:
When I type the value and press enter here, it doesn't accept the value, but moves to the next line and allows me to type further.
I want to run this abc.out file on the terminal. Any ideas would be really helpful.
Do you mean Qt Creator 2.4? In any case, on the Projects tab, you should find the Run settings section and from there you can find a "Run in terminal" checkbox. You could also use a Custom Executable option and type there: gnome-terminal --command ./abc.out The exact details can vary a bit as I'm using Qt Creator 2.5.
This should work when launching from Qt Creator, but when you use your app outside the IDE, you need to launch it from terminal and not by double clicking the executable. To fix this, I can think of two ways:
Launch a terminal window from QtGui (something like QProcess::execute("gnome-terminal --command ./abc.out"); ), though the problem is different systems have different terminal names.
Provide a Qt input/text box yourself as part of your GUI which then forwards the user input to the executable (something like myqprocess.write(input_asked_from_user_by_QtGui); ). Here you probably need to know what information to ask the user beforehand. If you want to display the cout output of the started process, you can use the read method and friends of the QProcess.
From your question I assume that you are writing an application that launches other applications using QProcess. Thats fine, but if your subprocess is waiting for data from the standard input it will wait forever since you did not provide any data. The stdin of your parent application cannot be automatically guided to the subprocess. Imagine you are starting two processes from your main app. To which child process should the input go?
If you want to communicate with child processes, you must use the QIODevice methods of QProcess and send/read data from/to that application.
The only sensible solution is to launch the target application in a terminal. Whether your own code provides the terminal window or you reuse an existing terminal application is up to you.
I'm switching from gnu screen to tmux, and I'm observing a weird behaviour where my shell hangs when I create a new window in tmux. I can kill the hang and get to my shell if I hit CTRL-C, but I want to find out what's going wrong.
I've done some echo debugging of my zsh configuration and figured out that the hang happens after ~/.zsh/env is sourced (it doesn't hang w/in ~/.zsh/env, I've checked that), but before ~/.zshrc is sourced. I'm willing to dig further, but I'm not sure what happens between those two steps. Can anyone tell me, so I know where to look?
Ah-ha, it's /etc/zprofile that's causing the issue. I found out from man zsh the order of the sourced files. Thanks!