LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How can I get emacs -nw when I call emacs from a terminal but GUI emacs elsewhere? (https://www.linuxquestions.org/questions/linux-newbie-8/how-can-i-get-emacs-nw-when-i-call-emacs-from-a-terminal-but-gui-emacs-elsewhere-901626/)

Blackened Justice 09-07-2011 12:44 PM

How can I get emacs -nw when I call emacs from a terminal but GUI emacs elsewhere?
 
Title says pretty much everything. When I call emacs from the terminal, I want to have the terminal-based version of emacs, not have a separate window with the GUI version. However, if I call it using Gnome Do, or from the applications menu, I want to have the GUI version.

Could anyone help me?

Thanks in advance

EDIT: Another doubt: Is there any difference between typing 'sudo bash' or 'su'?


Cheers

business_kid 09-07-2011 02:01 PM

Let me try.

In your ~/.bash_profile put this line
Quote:

alias emacs='emacs-nw'
in your ~/.bashrc, put
Quote:

alias emacs='emacs-gui-version' or whatever it's called.
As for sudo bash, it avoids the password stage of su.

Blackened Justice 09-07-2011 04:06 PM

I don't have a .bash_profile in my home folder...
As a simple temporary solution I have made a simple script and put it in the /usr/local/sbin folder, the first in the $PATH variable.

#!/bin/bash
/usr/bin/emacs -nw

It works if I just call emacs, but I can't pass any arguments (most importantly the filename).

business_kid 09-08-2011 02:42 AM

Let me try again:
Quote:

echo "alias emacs='emacs-nw' " >>~/.bash_profile
echo "alias emacs='emacs-gui-version' " >> ~?.bashrc
Make sure to fix the second line with the correct binary. I'm not an emacs type - I'm not even a vi type. Those commands will add a line if the file is there, and create it if it isn't.

Blackened Justice 09-08-2011 07:57 AM

Thank you for the suggestion, I read the .bashrc file and figured out what to do. I created a .bash_aliases file, as suggested, and put the "alias emacs='emacs -nw'" line on it. It now works perfectly, if I call it from the terminal I get the terminal version and if I call it from pretty much everywhere else, I get the GUI version.


All times are GMT -5. The time now is 12:17 PM.