LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 09-07-2011, 12:44 PM   #1
Blackened Justice
Member
 
Registered: Jun 2011
Posts: 82

Rep: Reputation: Disabled
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

Last edited by Blackened Justice; 09-07-2011 at 12:46 PM.
 
Old 09-07-2011, 02:01 PM   #2
business_kid
Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 5,953

Rep: Reputation: 496Reputation: 496Reputation: 496Reputation: 496Reputation: 496
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.
 
Old 09-07-2011, 04:06 PM   #3
Blackened Justice
Member
 
Registered: Jun 2011
Posts: 82

Original Poster
Rep: Reputation: Disabled
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).
 
Old 09-08-2011, 02:42 AM   #4
business_kid
Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 5,953

Rep: Reputation: 496Reputation: 496Reputation: 496Reputation: 496Reputation: 496
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.
 
Old 09-08-2011, 07:57 AM   #5
Blackened Justice
Member
 
Registered: Jun 2011
Posts: 82

Original Poster
Rep: Reputation: Disabled
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
emacs in terminal-mode constrains output to 80 columns (emacs bug, or watch bug?) jgombos Linux - Software 1 06-17-2011 09:49 PM
emacs + auctex - opening output PDF inside emacs buffer coenvh Linux - Newbie 1 04-29-2010 05:52 AM
Alt no longer META key when using in-terminal option of Emacs (emacs -nw) frznchckn Linux - Software 1 06-02-2007 02:41 AM
where is the .emacs file in the emacs source code tarball? aizkorri Programming 2 01-13-2007 02:05 PM
edb (emacs database) won't open file - emacs 20 & 21 tip184 Linux - Software 0 04-03-2004 07:31 AM


All times are GMT -5. The time now is 09:28 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration