I yesterday upgraded by MacPorts' apps which took apparently about 4 hours.
It was irritating to see the installation process going on in one tab in terminal.
Problem: to hide a running process in terminalsuch that it does not take space in my working area
I found today that there a new command coproc in Bash 4:
coprocess is executed asynchronously
in a subshell, as if the command
established between the executing shell and the coprocess
I am not sure whether you can use it to solve the problem or not. I did not manage to use it.
How can you hide the running process such that it is not visible in terminal but it continues to run?
Did you consider Ctrl + Z to put the process in pause, then bg to run this one in background?
To detach your process from the terminal, you can then type disown. You can now close the terminal, and even your session.
The problem here is that the outputs will appear anyway in the bash.
You can also start your program in screen. This command provide an easy way to start a program, close the console and retrieve it later.
I suspect you are looking for nohup
nohup LongRunningNoisyProgram &
will run the program, log the output to a file so you don't see it, push the program into the background, and won't cancel the program if you exit your terminal later while it is still running.
There is at least one thing the other repliers have not covered: how to manage hiding processes.
Suppose you have 100 background processes created with "nohup find / &". You want to quit them to really see how the background processes work. Please, use the command:
ps -ej | awk '! /grep/ && /find/ {print $2}' | xargs kill -9
Then, you may want to know how to control the keys to hide processes. You can change it to p, where susp stands for CTRL+z (^Z):
stty susp p
You can see the keys here:
stty -a
Please, compare the stdouts before and after the change. The command is particularly useful because it helps to remember other commands, such as ^W (to remove a word).
Jerome had an excellent tip about screen. I highly recommend to pursue the direction:
http://www.commandlinefu.com/commands/matching/screen/c2NyZWVu/sort-by-votes
Related
I have a program written in C that fails. When I run it in zsh, the program fails, but it's error output is not displayed in command line (note that the second ➜ was red, indicating a failed execution):
hpsc-hw2-USER on master
➜ ./sort -a 405500
hpsc-hw2-USER on master
➜
However, when I run it in bash, the error shows up:
[USER#COMPUTER hpsc-hw2-USER]$ ./sort -a 405500
Segmentation fault (core dumped)
Any idea why? I'm running oh-my-zsh with the spaceship theme if that helps.
but it's error output is not displayed in command line
That's not something that your program writes to the screen. It's the shell that's writing it. So the shell is not 'hiding' it.
I'm not using zsh myself, but since a red arrow indicates that the program was abnormally terminated, I guess you can look at the code for the red arrow and create a custom message. Here is a question about the error codes that might help you: What error code does a process that segfaults return?
I remember that I once made a custom bash prompt that showed the last exit code. Maybe I used this, but I'm not sure: Bash Prompt with Last Exit Code
Here is the documentation for how to customize the prompt for spaceship theme: https://denysdovhan.com/spaceship-prompt/docs/Options.html#exit-code-exit_code
I assume that you need to add exit_code to the SPACESHIP_PROMPT_ORDER section in your .zshrc file.
Any idea why?
You probably have to ask the developers. An equally valid question is: "Why does bash print 'segmentation fault'?" It's just a design choice. Bash does not print the memory address where the segfault occurred. Why is that?
Seems like the developers of oh-my-zsh thought it was enough with a red arrow.
Any ideas how to make zsh output the error message?
The result of the last command is stored in the shell variable ?, so you can print it with something like print $? or echo $?. Like most shells, zsh is incredibly configurable, so you can write a script that e.g. includes the result of the last command in your prompt. Here's a blog post in which the author configures zsh to display non-zero results in the right prompt: Show Exit Code of Last Command in Zsh.
Or why it doesn't do it to begin with?
Shell commands don't normally crash, and if they encounter errors they typically provide more useful output than just the return code on their own. The return code is most useful for scripts, so that you can write a script that handle error conditions.
I wanted to run 'brew update' but run 'brew upgrade'.
After that, my tmux stop working on some functionalities.
For example, I cannot split windows. I have already tried using shortcut (Prefix-%), terminal command (tmux split-window), or tmux command (Prefix-:split-window). Sometimes the terminal divides the window for a fraction of time and then the new pane fades out. Sometimes nothing happens.
If tmux is detached, I can attach with tmux attach but some other commands are not working. For example, if I run tmux new-session -As "foo", it returns the string [exit] and if I inspect the return (echo $?), it returns 0.
I have already tried to run tmux without any configuration in case my tmux.conf have some problems. But when I run tmux -f /dev/null, it returns the string [exit] and if I inspect the return (echo $?), it returns 0.
The problem is that I am not sure if the problem is with tmux itself (it was upgraded to 3.2a - and I did not remember which version it was before) or if the problem is with another program or with the fact I am running with Mac M1 processor, that causes me problems in a bunch of situations.
I have already tried to downgrade tmux but there are not many materials on how to do that I the ones that I tried did not work. So I give up, especially because I was not sure if this would solve the problem.
In summary, I need some help at least to know how to best debug the problem.
Thanks!
I had the exact same problem and could fix it by just restarting my tmux session. Dettaching and reattaching is not enough.
I'm trying to wrap my head around this: on Windows, I use cmder (a wrapper around ConEmu) which improves on the bare cmd.exe experience (a lot) but can also host other shells like PowerShell or Git Bash. I'd like to go more "unix-y" but still well integrated with my Windows tools. Git Bash strikes the right balance for me: I can do things like rm -rf node_modules but still run my Windows commands fine.
It's easy to get Git Bash going inside cmder, however, I'd like to replace the shell with zhs, mainly to get the super-useful "up arrow respects the current prefix" feature (I write git, press the up arrow and only get suggestions on the recent Git commands).
The question is, who will handle the up arrow? Will it be ConEmu and do Windows-y stuff (cycling through all the commands) or will it fall down to zsh and the cycling will be implemented by it? How does this work?
Related: ConEmu: possible to change the up arrow behavior?
ConEmu's disclaimer states
ConEmu is not a shell, so it does not provide "shell features" like remote access, tab-completion, command history and others.
Only the shell itself knows when user types a command and only the shell may store executed commands history. Of course, only the shell may process Up/Down/Tab keys to "browse" stored history of commands.
cmder is a bundle of tools including clink, which integrates into cmd.exe and process cmd's prompt internally. So, in cmder by default Up/Down/Tab arrows are processed by clink.
More info is here: http://conemu.github.io/en/TabCompletion.html
Let's say you run a command like grunt serve on a tmux pane,
and you kill the pane on which the command is running. I found that
the process is not killed:
ps aux | grep grunt
still shows that grunt is running even though the pane is gone.
How do you kill a tmux pane along with the process(es)?
To stop the program running you can close the pane by entering <C-B> x and then entering y.
Just do: <CTRL-B>:kill-pane
Use Ctrl + b¹, > to get a menu with this and other useful commands:
This is what uses the Spotify plugin.
¹ Or the chosen tmux escape sequence.
Other notes and sources
tmux list-keys | grep display-menu #
curl cht.sh/tmux # Online cheatsheet
https://wiki.archlinux.org/title/tmux
You may find the tmux-safekill plugin useful.
I wanted it to kill Ruby processes, so I had to fork the repo to add that functionality in, so I'm sure you could do the same for grunt processes if you don't get all the functionality you need from the repo directly.
I was working on a Unity 2D game project on OS X 10.10, and I can't drag file or folder, it will show this error.
No Drag&Drop has been setup. Please
UnityEditor.DockArea:OnGUI()
I have tried:
save project and then restart
click Assets folder and choose Reimport All
But it seems not work, how to fix it?
Recently I have the same problem and what I did was quit Unity and force quit the pboard process via Activity Monitor and then launch Unity again, it works for me.
Unity uses NSPasteboard (OSX shared manager for clipboard) to hold the data for Drag&Drop, so any process that monitors/modifies the clipboard may be messing with the Drag&Drop.
I think there might be a Chrome extension that would be generating notifications that would for some reason break drag and drop. Disable all your extensions in google chrome and if that doesn't solve your problem in Unity then do a fresh install of google chrome.
Edit: As suggested by other users, another solution that might work is
Quit Unity and force quit the pboard process via Activity Monitor and
then launch Unity again.
Hope it helps.
Based on the answer provided by Sinyo I created a small shell script to speed up the process and thought I would share. [For Mac only] It closes Unity, kills the pboard process, then reopens Unity.
#!/bin/sh
osascript -e 'quit app "Unity"'
pid=$(ps -fe | grep 'pboard' | grep -v grep | awk '{print $2}')
if [[ -n $pid ]]; then
kill $pid
else
echo "Does not exist"
fi
osascript -e 'launch the application "Unity"'
I know this is an old thread but I thought I might contribute. I was having the "No Drag&Drop" error in an implementation of a property drawer and tried all the tips given here with no success. I was about to give up and blame it on unity, but then I found a solution. You see, I was setting the object references and calling the DragAndDrop.SetGenericData() method during the mouseDown event.
I changed it so that in the MouseDrag event I check to see if there is existing DragAndDrop (checking for null in the return of DragAndDrop.GetGenericData()). If its null, I set the data during on MouseDrag just before calling DragAndDrop.StartDrag().
This fixed the problem. Hope it helps someone else.
This is the simplest way to accomplish the best answer:
killall -HUP pboard
(from terminal or similar, obviously)
Based on #user3130047's answer, this is another version. Mac Only.
Quit Unity.
In console, put this command and execute it.
ps aux | grep pboard | grep -v grep | awk '{print $2}' | xargs kill -9 | launchctl start com.apple.pboard
Open Unity.
That's it.
But, this may cause your another opened applications copy&paste doesn't work. So, you need to restart them.