Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Using bash with screen in an alias

I have a screen session that is always running in a separate user (for a minecraft server). Each time I want to attach to this screen, I use su -c 'screen -r mc-1.18.2' minecraft to attach back to this screen.

I wanted to make an alias for this command just so I didn’t have to type it out or go up in the command history each time. I added alias mcconsole="su -c 'screen -r mc-1.18.2' minecraft" to my ~/.bash_aliases folder. My other aliases work just fine but when I run mcconsole I am left with a brand new screen session. I am not sure where the hiccup is when attaching to the screen session (which is running as I can attach to it normally).

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

maybe try to invert simple and double quotes, something like:

alias mcconsole='su -c "screen -r mc-1.18.2" minecraft'

or escape double quotes inside:

alias mcconsole="su -c \"screen -r mc-1.18.2\" minecraft"

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading