You are not logged in.
I want to use Emacs instead of Emacs-Nox and other graphical applications in Tiling Window Managers without the hassle of moving the dead terminal window to another workspace.
To do that I came up with the following bash function:
function e () {
if [[ $2 ]]; then
if [[ $1 == mpv ]]; then
echo mpv --fullscreen=no "'"$2"'" '&&' urxvt > /tmp/2 &&
bash /tmp/2 & i3-msg kill
fi
echo $1 "'"$2"'" '&&' urxvt > /tmp/2 &&
bash /tmp/2 & i3-msg kill
else
echo emacs "'"$1"'" '&&' urxvt > /tmp/2 &&
bash /tmp/2 & i3-msg kill
fi
}So basically if I type 'e .zshrc' this function will kill the current terminal, start emacs and then create another terminal when emacs dies, if I pass two arguments, it will run the first argument instead of emacs. A special case is made so mpv opens videos with full screen disabled.
As you can see, this script is terrible and I would like to improve it.
** I'm using the i3 function "i3-msg kill" which means this script will no longer be functional if I switch to another window manager. However if I use 'exit' or 'bye' instead of 'i3-msg kill' it waits until "urxvt" is started before killing the terminal, making it useless.
** If I try to open multiple files with an app it fails big time, it doesn't take the third argument since I'm only passing the 1st and 2nd. I'm also failing to figure out how to make the script ls /usr/bin | grep $1 and check if the first argument is an app or not.
Last edited by RaphaelLamperouge (2015-10-09 06:32:52)
Offline
This sounds like a classic X-Y problem. Why do you have "dead terminals" in the first place?
Offline
If you run a graphical application in a terminal, it starts the graphical application in another window and the current terminal becomes a stdout dump.
So for example, if I type emacs homework.tex I'll have a unusable terminal taking up screen space, I'll need to switch to that terminal, move it to another workspace and then when I finally finish editing my homework the terminal will be gone (well, I moved it somewhere else...) and I'll have to start another terminal.
Now try opening a text file, read a .docx file the Windows dude gave me and listen to some music on spotify. You will have 3 dead terminals.
Last edited by RaphaelLamperouge (2015-10-09 04:58:28)
Offline
So, use something like dmenu that is designed for just that...
Offline
I'd have to pass the full path and all desired parameters to dmenu, without bash completion or command history.
EDIT:
You use vim. Vim CLI app is amazing.
Emacs GUI app is better than Emacs CLI app. I want to use Emacs GUI for that reason.
Do you understand my suffering now? Imagine having a dead terminal around every time you open a file with vim.
The reason so many people use emacs nox when it's clearly inferior is because they can't use the GUI version from the terminal, I'm trying to fix that.
Last edited by RaphaelLamperouge (2015-10-09 05:32:14)
Offline
I'd have to pass the full path and all desired parameters to dmenu, without bash completion or command history.
dmenu can be patched for filename completion...
Offline
It beats the point of using a shell at all honestly, I just wanna type 'e file' and see the file magically opening before my eyes, that's what terminal emulators are for.
EDIT:
I understand where you're coming from but while DMenu is useful for opening apps like Firefox it's not suited for something like Emacs. I'm positive this topic will be a life-saver for many people still using "emacs -nw" to open it in a terminal, they're basically losing out on many emacs functions unique to the GTK app. I'm also often forced to use "octave --no-gui" because of all the associated issues of using graphical applications on terminal-based window managers.
Regarding the script, it's perfectly functional (albeit very incomplete, I'll try to push it to .oh-my-zsh if I fix all issues), I'm struggling mostly with passing multiple arguments (open multiple files) and that's what I'd like to ask your help with.
Last edited by RaphaelLamperouge (2015-10-09 06:15:20)
Offline
Well, no. The terminal is not for launching graphical apps: that is my point.
If you insist on continuing to do it, at least background it and kill the terminal immediately with exit...
But as I said originally; there are plenty of solutions to this "problem", other than the rather inelegant approach that you have landed on.
Offline
I apologize for my rudeness but I'd like to ask if you're ignoring the words "Emacs GUI" intentionally.
Emacs is a Command Line Interface based Text Editor, I believe you'll agree with that.
------------------------------
Now, Emacs also has a GTK version, this version is by definition a "graphical application".
Are you saying I shouldn't open emacs with the terminal because it's a graphical application?
Offline
I'm saying that opening terminals repeatedly to launch graphical applications is suboptimal. You can do it if you want to, but there are far more effective ways of doing it that don't leave you with the "problem" of dead terminals. Hence my remark about an X-Y problem.
But this is Arch: you are free to do what you will...
Offline
Like I said... the main "graphical" application we're talking about here is called "Emacs".
Yes, Emacs has a Graphical Application version.
I'm not trying to launch "GIMP" from the terminal, I'm trying to launch my text-editor from the terminal.
Last edited by RaphaelLamperouge (2015-10-09 06:41:50)
Offline
I have no idea why you think I don't understand what you are talking about... I really don't care whether you launch emacs or matlab from the terminal, it is your business. But if you are asking for help to remove the problem of "dead terminals" (irrespective of what was started in those terminals), then--as I said--it is an X-Y problem of your own creation.
Offline
I'm disappointed by your intentions to turn this into a X-Y problem, you don't seem to be even trying to understand what I'm trying to do despite my repeated efforts to explain what it is.
Anyone reading this thread should be able to understand the following workflow.
$ emacs file &
-- Terminal dies
-- Window opens
-- Switch to dead terminal
$ exit
-- Close file on emacs when you're done
-- Open another terminal
I'm trying to make it look like
$ e file
And everything should automate itself without additional steps.
Last edited by RaphaelLamperouge (2015-10-09 06:55:44)
Offline
I'm disappointed by your intentions to turn this into a X-Y problem, you don't seem to be even trying to understand what I'm trying to do despite my repeated efforts to explain what it is.
If you insist on continuing to do it, at least background it and kill the terminal immediately with exit...
$ emacs file & exit"Problem" solved.
Or you could just do what everyone else does: https://wiki.archlinux.org/index.php/Li … _launchers
Offline
Except that
First
--- Your solution will fail exactly 50% of the time.
[1] 21085
zsh: you have running jobs.Second
--- You need 8 additional key presses.
Third
--- You need to open new terminal every time you want to edit a file, because you closed the last one.
Fourth
--- Ever opened vim with dmenu?
Last edited by RaphaelLamperouge (2015-10-09 07:07:05)
Offline
Because, as I have repeatedly pointed out, it is not a "solution" because there is no "problem" other than your insistence on a broken workflow.
I'm done.
Offline
Not sure how opening a file with emacs is broken workflow.
Maybe you want me to use vim, or the inferior emacs nox, or maybe type the full path to my ~current~ location on d-menu every time I want to edit a file.
Anyway, since this led to nothing but derailing, could you, as a mod, delete this conversation? I'll edit the OP tomorrow to be clearer if you do.
Offline
Remove the exit keep the & no? can't test atm
http://linuxcommand.org/lc3_lts0100.php
Zsh apparently also has
command &!which I think would be more in line with what you want
Last edited by V1del (2015-10-09 08:19:52)
Offline
Check out the Emacs documentation to see what's up with a thing called "emacsclient". I think you can use it to get an "e" command for your terminal like you want to have.
The way I remember, emacsclient looks for a running Emacs "server" and tells it to load a file. You can make it so that if there's no Emacs server running, it will start Emacs. That "server" stuff, you can either have Emacs running as a daemon, or you can make it so the "server" is your normal Emacs client. It's just something that's getting enabled in your init.el.
I don't know what's going on with regards to sudo and editing system files, no idea how that's accomplished with the emacsclient stuff.
Offline
Basically I wanna type "emacs file" and see emacs opening in the same terminal.
I currently accomplish with with "emacs -nw" but it's inferior.
I edit LaTeX files and Emacs GTK is leagues better than Emacs NOX for LaTeX editing so I'd like to use Emacs GTK instead, that's it ![]()
Last edited by RaphaelLamperouge (2015-10-09 16:31:14)
Offline