My friend and I started working on a project. We use grunt, so it's not optimal for us to both have our own terminals. The terminal we had originally was shared. Now we can't get a shared one back. What do I do?!
Cloud9 is using Tmux so you can run the following commands:
USER: A - Identify your TMUX session
$ tmux display-message -p '#S'
lcipriani#ace_457
USER: B - (on the same workspace) - switch to that terminal
$ tmux switch -t lcipriani#ace_457
Enjoy!
Related
I want to run a python script in a tmux session on startup when launching my google cloud vm. I have searched around stack overflow and found this piece of code.
#! /bin/bash
sudo -H -u MyUser tmux new-session -d -s discord 'python3 MyFile.py'
I placed this in the meta data part of my vm where startup_scripts go but it doesn't launch when i start my vm. However when I run this code in the terminal after my vm has started it does exactly what I want it to do. What am I missing here?
After digging around for I while I found the problem. The command runs in the root directory so, before your piece of code, you have to add:
Add: cd home/username
Before your code.
I'm using Linux Mint 19 Cinnamon. I've an Angular project and I want to do the following things. All these in a separate terminal:
Navigate into project folder and run code . so that I can see the code on Visual studio.
Navigate into project folder and run ng serve to launch my application and keep it running.
Navigate into project folder and run node server.js to start backend server and keep it running.
this is very painful as the project location is-
home/xpert/Documents/social-coder
and it contains two servers:
social-coder/application The angular server that runs on localhost:4200
social-coder/server/server.js The backend server that runs on localhost:3000
Both the servers need to be constantly running for the application to work.
Navigating again and again with a new terminal is what wasting my time. I decided to write a shell script so that I can do all at once with one single click. This is what my .bashrc file contains:
alias first='gnome-terminal | npm start --prefix Documents/social-coder/application'
alias second='node Documents/social-coder/server/server.js'
alias third='code Documents/social-coder'
This is what I've thought. SO, all of the above 3 commands works perfectly If I manually copy-paste them in separate terminals. But again, I have to manually open 3 different terminals and make them run. I'm coming from:
How to write practical shell scripts - Like Geeks
Run command on another(new) terminal window
How to Use GNOME Terminal App
gnome-terminal opens a new terminal but still runs npm start from the same terminal itself.
I admit that I'm a newbie and there are gaps in my knowledge. Please correct me.
For now I've created a command using pipe. It is working but I'm not sure whether this is the preferred way or not:
gnome-terminal -- /bin/bash -c 'npm start --prefix Documents/social-coder/application' | gnome-terminal -- /bin/bash -c 'node Documents/social-coder/server/server.js' | gnome-terminal -- /bin/bash -c 'code Documents/social-coder'
Please feel free to edit this answer.
I'm trying to run an executable file as sudo using terminal at startup but I'm having some issues. I couldn't find the solution in other answers, so I opened up this one. I'm using a Raspberry Pi 3 B+ with the Raspbian Stretch with desktop and recommended software downloaded from the official Raspberry Pi website.
I have an executable that needs to be run with sudo (I use the pigpio library to communicate with another hardware through SPI and if I don't run the executable with sudo, the pigpio doesn't work). What I'm trying to achieve is that when the Pi finishes to startup the graphical interface, it would run the LXTerminal and execute "sudo home/pi/myfolder/myprogram".
I've tried:
sudo nano ~/.config/autostart/myprogram.desktop
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=myprogram
Exec=lxterminal -e "sudo /home/pi/myfolder/myprogram"
Terminal=true
sudo chmod a+r ~/.config/autostart/myprogram.desktop
Also tried:
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
lxterminal --command="sudo /home/pi/myfolder/myprogram"
Both methods did open the lxterminal at startup, but didn't executed my program.
Can anyone help me out?
I found the solution, so I'm gonna post it here in case someone else needs it. If it already exists in somewhere else around here, feel free to tag it as duplicated.
The solution that worked for me was this:
sudo nano ~/.config/autostart/myprogram.desktop
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=myprogram
Exec=lxterminal -e bash -c 'sudo /home/pi/myfolder/myprogram;$SHELL'
Terminal=true
sudo chmod a+r ~/.config/autostart/myprogram.desktop
The $SHELL makes the terminal stay open after myprogram ends its execution. If you don't need this feature, just exclude the ;$SHELL part of the code above.
There's possible duplicate but it's closed and unanswered.
As I'm using chef for automation, would be nice to automate tmux launch with pre-launched python web server and second window opened. (this is specifically for my development environment). And only way of doing this probably specifying parameters from command line.
Commands which I want to execute are in window with title "daemon":
source bin/activate
cd project
DEBUG=1 python app.py
I'm unable to find which command line parameters allows to pre-execute commands when launching tmux, and also to open more windows on launch.
You want to create a session without attaching to it (using the -d option), so that you can send additional tmux commands to open the second window before actually attaching.
tmux new-session -t mysession -d 'source bin/activate; cd project; DEBUG=1 python app.py'
tmux new-window -t mysession
tmux attach-session -t mysession
I used home-brew to setup tmux on a mac. When trying to run tmux I keep on getting this error
open terminal failed: missing or unsuitable terminal: xterm-256color
any suggestions?
Your system doesn't have xterm-256color. You could:
Set TERM to something other than xterm-256color outside tmux (try just plain export TERM=xterm).
See if there is a package containing xterm-256color, perhaps a later version of ncurses or terminfo.
Install it manually from another system with something like:
infocmp -x xterm-256color > out
Then transfer the "out" file to your Mac and try:
tic out
This happened to me during a system upgrade. Unfortunately I did not see a way besides restarting: tmux kill-server and then run tmux.
you can just type export TERM=xterm in console when you see this error, or put export TERM=xterm in the file ~/.bash_profile and source ~/.bash_profile. then you may never get this error again.
This works fine on my debian.
TL;DL
sudo ln -sf /usr/share/terminfo/x/xterm-color /usr/share/terminfo/x/xterm-256color
Details
Maybe the file /usr/share/terminfo/x/xterm-256color is corrupted. It may be fixed upon (system/package) upgrade / reinstall.
Meanwhile you can use other terminfo entry. You can get the available options by ls /usr/share/terminfo/x.
I am having the same problem and using xterm-16color meanwhile.
To set terminfo, you can type reset in the terminal, then select the terminfo:
username:~$ cd /usr/share/terminfo/x
username:x$ ls
x10term xnuppc+200x64 xterm-24 xterm+pcfkeys
x1700 xnuppc-200x64-m xterm-256color xterm-pcolor
x1700-lm xnuppc-200x75 xterm+256color xterm-r5
...
username:x$ reset
reset: unknown terminal type xterm-256color
Terminal type? xterm-16color
=== Edit 2018 Feb 20 ===
You should config the term in many places if you want to make it permanent, for example, .vimrc, .tmux.config, .Xresources, e.t.c.
I still have issue when using terminator -x 'tmux attach -t music; exec bash'
So I'm using a quick hack as below:
cd /usr/share/terminfo/x
sudo mv xterm-256color xterm-256color.bk
sudo ln -sf /usr/share/terminfo/x/xterm-color /usr/share/terminfo/x/xterm-256color
When I removed some sessions/windows this error went away for me. Apparently I had too many TTY's open.
You can kill sessions/windows from outside tmux with these commands:
tmux kill-session -t <session-name>
tmux kill-window -t <session-name>:<window-name>
I am also having the same issue.
export TERM=xterm
tmux kill-server
This helps solve the problem: https://www.peterdavehello.org/2019/11/tmux-open-terminal-failed-missing-or-unsuitable-terminal-xterm-256color/
In my case Xterm was absent.
(But I had the same error on Ubuntu)