# A tour of vterm Gabriele Bozzola (@sbozzolo) [[!template id=vid src="https://mirror.csclub.uwaterloo.ca/emacsconf/2020/emacsconf-2020--30-a-tour-of-vterm--gabriele-bozzola-sbozzolo.webm" subtitles="/2020/subtitles/emacsconf-2020--30-a-tour-of-vterm--gabriele-bozzola-sbozzolo.vtt"]] [Download compressed .webm video (17.7M)](https://media.emacsconf.org/2020/emacsconf-2020--30-a-tour-of-vterm--gabriele-bozzola-sbozzolo--compressed32.webm) [Download compressed .webm video (10.9M, highly compressed)](https://mirror.csclub.uwaterloo.ca/emacsconf/2020/smaller/emacsconf-2020--30-a-tour-of-vterm--gabriele-bozzola-sbozzolo--vp9-q56-video-original-audio.webm) g [View transcript](#transcript) [[!template id=vid src="https://mirror.csclub.uwaterloo.ca/emacsconf/2020/emacsconf-2020--30-a-tour-of-vterm--questions--gabriele-bozzola-sbozzolo.webm" download="Download Q&A video"]] [Download compressed Q&A .webm video (4.1M)](https://media.emacsconf.org/2020/emacsconf-2020--30-a-tour-of-vterm--questions--gabriele-bozzola-sbozzolo--compressed32.webm) [Download compressed Q&A .webm video (3.3M, highly compressed)](https://mirror.csclub.uwaterloo.ca/emacsconf/2020/smaller/emacsconf-2020--30-a-tour-of-vterm--questions--gabriele-bozzola-sbozzolo--vp9-q56-video-original-audio.webm) Vterm is a fast and fully capable terminal emulator in GNU Emacs built as a dynamic module on top of libvterm. In this talk, I will give an overview of the package. I will discuss the installation and common customizations. I will go into details on some of the most important features, such as directory tracking or message passing. Finally, I will touch upon known incompatibilities and the future directions of the project. URL: <https://github.com/akermu/emacs-libvterm> <!-- from the pad ---> # Questions ## Q5: Does/will this work with 'emacs -nw'? Yes, it does. ## Q4: Thats a nice looking prompt, do you have it on a Git repo we could see, or something of that manner? Thanks, I use Bash right now so I didn't know it was the default on the others. It is not the default, but it is available easily with oh-my-zsh or similar on fish. I think the prompt is this: <https://github.com/sindresorhus/pure> ## Q3: Is there a plan to avoid the initial compilation step? Not any time soon. You will have to compile vterm the first time you start it. ## Q2: What are differences between Eshell and vterm? Performance. vterm is like xterm but in Emacs, Eshell is like Bash but in Emacs. <https://github.com/akermu/emacs-libvterm#given-that-eshell-shell-and-ansi-term-are-emacs-built-in-why-should-i-use-vterm> ## Q1: Could you put your testing scripts up somewhere? - 256colors: <https://pastebin.com/j6HF5q8T> - title: <https://pastebin.com/SByKdJM2> - I cannot pastebin the 1MB of data, I pasted a sample of it: <https://pastebin.com/n1T3aUff> # Notes <https://github.com/akermu/emacs-libvterm> <a name="transcript"></a> # Transcript [[!template text="Hello and welcome to this talk." start="00:00:00.880" video="mainVideo" id=subtitle]] [[!template text="The title of this talk is a tour of vterm," start="00:00:03.760" video="mainVideo" id=subtitle]] [[!template text="a fast and fully featured terminal emulator" start="00:00:06.080" video="mainVideo" id=subtitle]] [[!template text="inside GNU Emacs." start="00:00:08.559" video="mainVideo" id=subtitle]] [[!template text="So let's try to understand what we mean" start="00:00:10.801" video="mainVideo" id=subtitle]] [[!template text="with " ;fast and fully featured." ;" start="00:00:12.720" video="mainVideo" id=subtitle]] [[!template text="To do that we'll compare vterm" start="00:00:14.559" video="mainVideo" id=subtitle]] [[!template text="with the packages which are built in Emacs," start="00:00:16.801" video="mainVideo" id=subtitle]] [[!template text="mainly, term." start="00:00:20.401" video="mainVideo" id=subtitle]] [[!template text="So let's jump into the vterm." start="00:00:22.400" video="mainVideo" id=subtitle]] [[!template text="So this is a vterm buffer" start="00:00:25.040" video="mainVideo" id=subtitle]] [[!template text="and this is a ansi-term buffer." start="00:00:26.720" video="mainVideo" id=subtitle]] [[!template new="1" text="What I'm going to do now is" start="00:00:29.440" video="mainVideo" id=subtitle]] [[!template text="first I'm going to prove to you" start="00:00:30.721" video="mainVideo" id=subtitle]] [[!template text="what we mean by fast." start="00:00:32.160" video="mainVideo" id=subtitle]] [[!template text="To do that, let me open a large file display on screen--" start="00:00:34.161" video="mainVideo" id=subtitle]] [[!template text="a large file, this is about one megabyte of data--" start="00:00:37.441" video="mainVideo" id=subtitle]] [[!template text="and let me time that." start="00:00:40.239" video="mainVideo" id=subtitle]] [[!template text="It takes about 0.6 seconds with vterm." start="00:00:41.841" video="mainVideo" id=subtitle]] [[!template text="Let's do the same with with ansi-term." start="00:00:45.201" video="mainVideo" id=subtitle]] [[!template text="Well, we already see the difference." start="00:00:48.321" video="mainVideo" id=subtitle]] [[!template new="1" text="So I will use this time to tell you" start="00:00:51.520" video="mainVideo" id=subtitle]] [[!template text="what's different, and what is vterm exactly." start="00:00:53.039" video="mainVideo" id=subtitle]] [[!template text="vterm is a terminal emulator" start="00:00:56.321" video="mainVideo" id=subtitle]] [[!template text="built on top of an external library." start="00:00:58.400" video="mainVideo" id=subtitle]] [[!template text="The library is called libvterm," start="00:01:00.801" video="mainVideo" id=subtitle]] [[!template text="and is the same library used by Newton" start="00:01:02.719" video="mainVideo" id=subtitle]] [[!template text="for their own terminal emulator." start="00:01:05.519" video="mainVideo" id=subtitle]] [[!template text="It's a C library, and this is what gives us" start="00:01:07.200" video="mainVideo" id=subtitle]] [[!template text="a lot of good features. First, the speed." start="00:01:10.799" video="mainVideo" id=subtitle]] [[!template text="Time spent here, 0.6, is essentially" start="00:01:15.119" video="mainVideo" id=subtitle]] [[!template text="the time that it takes to:" start="00:01:17.120" video="mainVideo" id=subtitle]] [[!template text="1\. convert the Emacs representation of text" start="00:01:18.479" video="mainVideo" id=subtitle]] [[!template text="into the vterm representation of what is a string," start="00:01:22.241" video="mainVideo" id=subtitle]] [[!template text="and 2., into actually displaying that," start="00:01:25.041" video="mainVideo" id=subtitle]] [[!template text="and that can take time" start="00:01:27.361" video="mainVideo" id=subtitle]] [[!template text="if there's fontification involved." start="00:01:29.520" video="mainVideo" id=subtitle]] [[!template text="So these are the 0.6 seconds there." start="00:01:32.241" video="mainVideo" id=subtitle]] [[!template text="As we say, in ansi-term, that's much more time." start="00:01:34.240" video="mainVideo" id=subtitle]] [[!template text="It's much slower. So the terminal will feel" start="00:01:38.480" video="mainVideo" id=subtitle]] [[!template text="much snappier, much faster." start="00:01:40.721" video="mainVideo" id=subtitle]] [[!template new="1" text="But that's not the main benefit or the only benefit" start="00:01:42.880" video="mainVideo" id=subtitle]] [[!template text="of using this external library vterm." start="00:01:46.721" video="mainVideo" id=subtitle]] [[!template text="The second big benefit is that" start="00:01:49.760" video="mainVideo" id=subtitle]] [[!template text="vterm has support for all the escape codes" start="00:01:53.041" video="mainVideo" id=subtitle]] [[!template text="that xterm has support for," start="00:01:56.560" video="mainVideo" id=subtitle]] [[!template text="so vterm is essentially as running xterm" start="00:01:58.321" video="mainVideo" id=subtitle]] [[!template text="inside an Emacs buffer. So let's see that." start="00:02:01.119" video="mainVideo" id=subtitle]] [[!template text="For example, let's start by looking" start="00:02:03.600" video="mainVideo" id=subtitle]] [[!template text="at the support for colors." start="00:02:05.760" video="mainVideo" id=subtitle]] [[!template text="We have support for all the colors out of the box." start="00:02:08.239" video="mainVideo" id=subtitle]] [[!template text="We don't have to do anything." start="00:02:10.320" video="mainVideo" id=subtitle]] [[!template text="And if we did the same here, well," start="00:02:11.840" video="mainVideo" id=subtitle]] [[!template text="we have only 20 colors." start="00:02:14.721" video="mainVideo" id=subtitle]] [[!template text="There's a way to get all the colors," start="00:02:16.801" video="mainVideo" id=subtitle]] [[!template text="but it's much more involved." start="00:02:18.240" video="mainVideo" id=subtitle]] [[!template new="1" text="But this is not where vterm shines." start="00:02:19.680" video="mainVideo" id=subtitle]] [[!template text="We can run all the commands that we want." start="00:02:23.040" video="mainVideo" id=subtitle]] [[!template text="htop, ncdu, everything runs here." start="00:02:27.200" video="mainVideo" id=subtitle]] [[!template text="Also this title, it's a fairly complicated" start="00:02:31.441" video="mainVideo" id=subtitle]] [[!template text="manipulation of the window" start="00:02:35.520" video="mainVideo" id=subtitle]] [[!template text="and it will not work here." start="00:02:37.921" video="mainVideo" id=subtitle]] [[!template text="It just doesn't work actually." start="00:02:40.879" video="mainVideo" id=subtitle]] [[!template text="Now the terminal is probably messed up. Yes." start="00:02:42.001" video="mainVideo" id=subtitle]] [[!template text="So using this external library" start="00:02:46.161" video="mainVideo" id=subtitle]] [[!template text="removes the burden from the developers" start="00:02:48.400" video="mainVideo" id=subtitle]] [[!template text="of having to implement support" start="00:02:50.959" video="mainVideo" id=subtitle]] [[!template text="for all the escape codes." start="00:02:52.320" video="mainVideo" id=subtitle]] [[!template text="We just use those." start="00:02:53.281" video="mainVideo" id=subtitle]] [[!template new="1" text="So in many ways, running vterm" start="00:02:55.360" video="mainVideo" id=subtitle]] [[!template text="is running xterm inside Emacs," start="00:02:58.480" video="mainVideo" id=subtitle]] [[!template text="but it's better than that because," start="00:03:01.760" video="mainVideo" id=subtitle]] [[!template text="since this is an Emacs buffer," start="00:03:04.160" video="mainVideo" id=subtitle]] [[!template text="we can enjoy a lot of features from Emacs" start="00:03:05.840" video="mainVideo" id=subtitle]] [[!template text="as well as a tighter integration" start="00:03:09.760" video="mainVideo" id=subtitle]] [[!template text="with Emacs itself." start="00:03:11.361" video="mainVideo" id=subtitle]] [[!template text="For example, as you see here," start="00:03:13.200" video="mainVideo" id=subtitle]] [[!template text="the title of my buffer is from the directory I'm in." start="00:03:15.841" video="mainVideo" id=subtitle]] [[!template text="So let's go to my tmp." start="00:03:20.240" video="mainVideo" id=subtitle]] [[!template text="The title will change." start="00:03:21.760" video="mainVideo" id=subtitle]] [[!template text="So there's information being exchanged" start="00:03:23.441" video="mainVideo" id=subtitle]] [[!template text="between vterm and Emacs." start="00:03:25.921" video="mainVideo" id=subtitle]] [[!template text="And of course, the title is not the only place" start="00:03:28.000" video="mainVideo" id=subtitle]] [[!template text="where information is exchanged." start="00:03:30.001" video="mainVideo" id=subtitle]] [[!template text="I can find a file and I will be in the directory" start="00:03:32.000" video="mainVideo" id=subtitle]] [[!template text="where my terminal is." start="00:03:35.920" video="mainVideo" id=subtitle]] [[!template text="This feature is also available in ansi-term," start="00:03:37.681" video="mainVideo" id=subtitle]] [[!template text="and it works also on vterm," start="00:03:40.000" video="mainVideo" id=subtitle]] [[!template text="and it follows me. So if I go to tmp," start="00:03:41.361" video="mainVideo" id=subtitle]] [[!template text="I'll get the tmp." start="00:03:43.441" video="mainVideo" id=subtitle]] [[!template text="If I ssh to a remote server," start="00:03:44.720" video="mainVideo" id=subtitle]] [[!template text="it will work also on remote servers as well," start="00:03:47.121" video="mainVideo" id=subtitle]] [[!template text="which is a very nice way to edit files remotely" start="00:03:50.240" video="mainVideo" id=subtitle]] [[!template text="while we're working on a shell." start="00:03:53.920" video="mainVideo" id=subtitle]] [[!template new="1" text="And second, while vterm is not an Elisp interpreter" start="00:03:55.600" video="mainVideo" id=subtitle]] [[!template text="like eshell, what we can do is" start="00:03:59.281" video="mainVideo" id=subtitle]] [[!template text="we can still run Emacs functions." start="00:04:01.201" video="mainVideo" id=subtitle]] [[!template text="So for example..." start="00:04:04.721" video="mainVideo" id=subtitle]] [[!template text="that requires some configuration." start="00:04:06.081" video="mainVideo" id=subtitle]] [[!template text="vterm command (message "hi")" start="00:04:08.001" video="mainVideo" id=subtitle]] [[!template text="as you see there's a "hi" here." start="00:04:11.600" video="mainVideo" id=subtitle]] [[!template text="So what I'm doing is I'm executing" start="00:04:13.121" video="mainVideo" id=subtitle]] [[!template text="the Elisp function hi." start="00:04:14.960" video="mainVideo" id=subtitle]] [[!template text="I can drop that and turn it around," start="00:04:16.239" video="mainVideo" id=subtitle]] [[!template text="hash function to run Elisp functions." start="00:04:18.960" video="mainVideo" id=subtitle]] [[!template text="Or another one, find-file, same." start="00:04:21.601" video="mainVideo" id=subtitle]] [[!template text="We call this feature "message passing,"" start="00:04:24.880" video="mainVideo" id=subtitle]] [[!template text="and it requires some configuration" start="00:04:27.361" video="mainVideo" id=subtitle]] [[!template text="on the Emacs side as well as in the shell side." start="00:04:30.001" video="mainVideo" id=subtitle]] [[!template new="1" text="It's important to stress" start="00:04:32.000" video="mainVideo" id=subtitle]] [[!template text="what's the nature of vterm." start="00:04:33.441" video="mainVideo" id=subtitle]] [[!template text="For instance, every time I'm sending a key binding," start="00:04:35.360" video="mainVideo" id=subtitle]] [[!template text="it's not immediately clear if my intention is" start="00:04:37.920" video="mainVideo" id=subtitle]] [[!template text="to send it to the shell or to Emacs." start="00:04:40.001" video="mainVideo" id=subtitle]] [[!template text="So vterm implements some reasonable defaults," start="00:04:41.841" video="mainVideo" id=subtitle]] [[!template text="but at the moment it's mainly packaged" start="00:04:44.320" video="mainVideo" id=subtitle]] [[!template text="to display characters on a screen." start="00:04:46.800" video="mainVideo" id=subtitle]] [[!template text="So for example, if you're using evil," start="00:04:49.120" video="mainVideo" id=subtitle]] [[!template text="the editing commands in evil" start="00:04:50.721" video="mainVideo" id=subtitle]] [[!template text="will not work immediately." start="00:04:52.640" video="mainVideo" id=subtitle]] [[!template text="There's some work to be done" start="00:04:54.081" video="mainVideo" id=subtitle]] [[!template text="and integration can be improved on that side," start="00:04:55.759" video="mainVideo" id=subtitle]] [[!template new="1" text="but sometimes we really want this to behave" start="00:04:58.161" video="mainVideo" id=subtitle]] [[!template text="exactly like a Emacs buffer." start="00:05:00.240" video="mainVideo" id=subtitle]] [[!template text="We want to be able to search." start="00:05:02.240" video="mainVideo" id=subtitle]] [[!template text="If I try to get it to search," start="00:05:03.681" video="mainVideo" id=subtitle]] [[!template text="it will not work." start="00:05:06.640" video="mainVideo" id=subtitle]] [[!template text="I will send it to the shell." start="00:05:07.281" video="mainVideo" id=subtitle]] [[!template text="So to do that, we enabled vterm copy mode." start="00:05:08.401" video="mainVideo" id=subtitle]] [[!template text="As you see, copy mode, and now this buffer" start="00:05:11.920" video="mainVideo" id=subtitle]] [[!template text="is essentially a fundamental buffer." start="00:05:14.721" video="mainVideo" id=subtitle]] [[!template text="I can move around. I can search." start="00:05:17.039" video="mainVideo" id=subtitle]] [[!template text="So it must have... I can do everything I want." start="00:05:21.120" video="mainVideo" id=subtitle]] [[!template text="And there are additional features." start="00:05:25.521" video="mainVideo" id=subtitle]] [[!template text="For example, I can jump around all the prompts." start="00:05:26.480" video="mainVideo" id=subtitle]] [[!template text="I find this extremely useful," start="00:05:30.561" video="mainVideo" id=subtitle]] [[!template text="because I can copy updates from my programs." start="00:05:32.639" video="mainVideo" id=subtitle]] [[!template text="What I always have to do is" start="00:05:35.040" video="mainVideo" id=subtitle]] [[!template text="I have to Google some errors." start="00:05:38.321" video="mainVideo" id=subtitle]] [[!template text="So what I do is I select that" start="00:05:41.521" video="mainVideo" id=subtitle]] [[!template text="and I have my keybinding in Emacs conf," start="00:05:43.120" video="mainVideo" id=subtitle]] [[!template text="and I'm Googling what I have to Google." start="00:05:45.121" video="mainVideo" id=subtitle]] [[!template text="So this is very nice and if I..." start="00:05:48.480" video="mainVideo" id=subtitle]] [[!template text="now that I have selected something," start="00:05:51.121" video="mainVideo" id=subtitle]] [[!template text="if I just press return," start="00:05:52.640" video="mainVideo" id=subtitle]] [[!template text="I will go back to my normal editing mode" start="00:05:53.841" video="mainVideo" id=subtitle]] [[!template text="with the text copied, so I can paste it back." start="00:05:56.401" video="mainVideo" id=subtitle]] [[!template text="So it's a quick way to interact with copy" start="00:06:00.161" video="mainVideo" id=subtitle]] [[!template text="and interact with the output of a buffer." start="00:06:02.721" video="mainVideo" id=subtitle]] [[!template new="1" text="So finally, let's discuss how to actually use vterm." start="00:06:05.841" video="mainVideo" id=subtitle]] [[!template text="Let's circle back, let's go," start="00:06:09.121" video="mainVideo" id=subtitle]] [[!template text="and let's look at the GitHub repo" start="00:06:10.560" video="mainVideo" id=subtitle]] [[!template text="where development is happening." start="00:06:12.400" video="mainVideo" id=subtitle]] [[!template text="vterm is available in MELPA," start="00:06:14.001" video="mainVideo" id=subtitle]] [[!template text="but since it's leveraging the power" start="00:06:15.520" video="mainVideo" id=subtitle]] [[!template text="of an external module," start="00:06:17.760" video="mainVideo" id=subtitle]] [[!template text="you must have Emacs compiled" start="00:06:18.960" video="mainVideo" id=subtitle]] [[!template text="with support for modules," start="00:06:20.480" video="mainVideo" id=subtitle]] [[!template text="and many distros like Ubuntu, Debian," start="00:06:22.000" video="mainVideo" id=subtitle]] [[!template text="that's not there. So you have to" start="00:06:25.600" video="mainVideo" id=subtitle]] [[!template text="get Emacs with support for modules:" start="00:06:26.881" video="mainVideo" id=subtitle]] [[!template text="compiling or getting images somewhere else." start="00:06:29.200" video="mainVideo" id=subtitle]] [[!template text="And also, the first time you are going to use this," start="00:06:31.361" video="mainVideo" id=subtitle]] [[!template text="which works only on Mac or GNU Linux systems," start="00:06:33.840" video="mainVideo" id=subtitle]] [[!template text="Emacs will try to find and compile this module," start="00:06:38.961" video="mainVideo" id=subtitle]] [[!template text="so it's important. This requirement is important." start="00:06:41.759" video="mainVideo" id=subtitle]] [[!template text="If you're using Windows, well," start="00:06:44.241" video="mainVideo" id=subtitle]] [[!template text="it's not available and will not work." start="00:06:46.401" video="mainVideo" id=subtitle]] [[!template new="1" text="So to conclude, I want to just advertise this page." start="00:06:49.199" video="mainVideo" id=subtitle]] [[!template text="If you have problems, look at the issues" start="00:06:53.440" video="mainVideo" id=subtitle]] [[!template text="and open an issue in case." start="00:06:56.240" video="mainVideo" id=subtitle]] [[!template text="We'll try to help you." start="00:06:58.241" video="mainVideo" id=subtitle]] [[!template text="We are very excited about vterm," start="00:06:59.200" video="mainVideo" id=subtitle]] [[!template text="and I think it's a transformative" start="00:07:00.800" video="mainVideo" id=subtitle]] [[!template text="terminal experience inside GNU Emacs." start="00:07:02.639" video="mainVideo" id=subtitle]]