# Terminal Love



## tzoi516 (Dec 3, 2013)

My main terminal application is x11/evilvte, but I'm really enjoying sysutils/tmux a lot - there are times for tabs, and there are times when I need it all right there. I'm not a fan of alt-tab for TTYs. What terminal add-ons or tweaks do other people use/like?


----------



## fonz (Dec 3, 2013)

FWIW, I currently do the vast majority of my stuff from one or two central machines, both of which run X with virtual desktops. So I just have some terminals open on any virtual desktop where I need them. I do like tmux though, and before that came along I used sysutils/screen a lot.

For some reason I do have a perhaps somewhat pathological urge to install games/sl on every machine  :h Oh, and being a vimer I like misc/vifm. Whoever mentioned that thing on these forums some time ago, thanks again  :f


----------



## jrm@ (Dec 3, 2013)

I also like sysutils/tmux, but I spend most of my time in eshell.  With editors/emacs running in daemon mode, you can disconnect/reattach like sysutils/tmux.  It's handy to have a shell that doubles as an elisp interpreter inside editors/emacs.  eshell does have it's quirks still though, so that's why I have to jump back to sysutils/tmux from time to time.


----------



## ShelLuser (Dec 3, 2013)

At first I heavily used screen on my Linux servers, but after I migrated all my Linux (CentOS) servers to FreeBSD I also quickly discovered and embraced sysutils/tmux. Which reminds me that I really need to finish the second part of my 'tmux tutorial'.

Alas; I've became a big fan of tmux due to the very slick way in which it's set up (for example no more need for a setuid binary) and it's extensive and flexible configuration options. Control-a and control-C will take me right into vi with ~/tmux.conf loaded for editing. Control-a and control-r will then re-load said config file (and of course (re-)apply any configuration options).

Even better: all those manually added commands are also mentioned and shown whenever I press control-a + ?. So when I pull up the help screen.

It's things like that which made me a firm tmux supporter. Which is basically the only thing I'm using on my servers. Apart from /bin/sh, /usr/local/bin/ksh and of course /bin/csh


----------



## ShelLuser (Dec 4, 2013)

fonz said:
			
		

> For some reason I do have a perhaps somewhat pathological urge to install games/sl on every machine  :h


Darn you! 

SO after I approached this probably 'evil' port with great care (running `# make missing` to look for a good excuse not to try it for example) I eventually installed it as well. Now, I don't really make much typing mistakes, but after that first animation on my (non-X11) server I was hooked as well 

Really funny and very well made.

But of course I now have to blame you for pointing out the funny


----------



## jrm@ (Dec 4, 2013)

ShelLuser said:
			
		

> Control-a and control-C will take me right into vi with ~/tmux.conf loaded for editing. Control-a and control-r will then re-load said config file (and of course (re-)apply any configuration options).



What do you use to go to the beginning of the prompt line if `Control-a` is taken by tmux?


----------



## fonz (Dec 4, 2013)

jrm said:
			
		

> What do you use to go to the beginning of the prompt line if `Control-a` is taken by tmux?


The `Home` key, I'd guess. That's what I do anyway.


----------



## tzoi516 (Dec 4, 2013)

Looking forward to that sysutils/tmux, if you decide to finish it.

I too just installed games/sl; that is pretty funny. I have to sneak it on my son's Linux Mint laptop.


----------



## ShelLuser (Dec 4, 2013)

jrm said:
			
		

> What do you use to go to the beginning of the prompt line if `Control-a` is taken by tmux?


If I'm typing a command on the console and need to go to the start then I first press escape followed by ^ after which I'm taken straight to the start of the line.

I'm using ksh on all my servers (for my own user account) where I'm using the so called 'vi mode'. So basically the shell options vi and vi-tabcomplete are both enabled. And that allows me to use vi-styled commands. It's an option I heavily enjoy.

I can move on the commandline (apart from using ^ and $ I can also use commands such as w or W which can jump to the next or previous word, options are endless). And apart from moving on the commandline I can also use the vi movement keys to recall previously used commands. Or use the search option (by pressing /) and simply search for one. Or what to think about quickly deleting something? A quick escape followed by d and w will delete the word. Or if I want to retype the rest of the commandline I simply use d and $ which will delete everything behind the current cursor location.

The options are endless, and stuff like that makes working with the commandline a whole lot more enjoyable for me.


----------



## tzoi516 (Dec 4, 2013)

Are these custom configurations, or are they stock?


----------



## fulano (Dec 5, 2013)

The best terminal of all times: x11/rxvt-unicode


----------



## ShelLuser (Dec 11, 2013)

tzoi516 said:
			
		

> Are these custom configurations, or are they stock?


Sorry for my late response but I wasn't quite sure what you mean with this. But considering how your message sits directly under mine I'm assuming that you meant to ask me this question.

And if not then well, maybe this is useful for someone else 

The 'vi-mode' is stock, it comes out of the box so to speak:


```
smtp2:/home/peter $ echo $0
-ksh
smtp2:/home/peter $ set -o
Current option settings
allexport      off  keyword        off  nolog          off  trackall       off
braceexpand    on   login          on   notify         off  verbose        off
bgnice         off  markdirs       off  nounset        off  vi             on
emacs          off  monitor        on   physical       off  viraw          off
errexit        off  noclobber      off  posix          on   vi-show8       off
gmacs          off  noexec         off  privileged     off  vi-tabcomplete on
ignoreeof      off  noglob         off  restricted     off  vi-esccomplete off
interactive    on   nohup          on   stdin          on   xtrace         off
```
But although I'm using ksh myself keep in mind that this option isn't exclusive for that shell only. Bourne and Bourne Again (or better put: sh and bash) also support this option:


```
smtp2:/home/peter $ sh
$ set -o | grep vi
vi              off
privileged      off
$ bash
[peter@smtp2 ~]$ set -o | grep vi
privileged      off
vi              off
[peter@smtp2 ~]$ csh
peter@smtp2:/home/peter % set -o
set: Variable name must begin with a letter.
```
As you can see I have no idea about the C Shell but I'm only using that for the root user anyway


----------



## tzoi516 (Dec 11, 2013)

It was to you, so thanks for the assumption. 

Thread flow, to me at least, seems hard to follow when every post has a quote. So I tend to quote when I know I won't be able to get my post in below the person I'm directing my post to.


----------



## tzoi516 (Dec 11, 2013)

ShelLuser said:
			
		

> But although I'm using ksh myself ...



Do you use shells/pdksh or shells/ksh93?


----------



## Juanitou (Dec 11, 2013)

ShelLuser said:
			
		

> As you can see I have no idea about the C Shell but I'm only using that for the root user anyway


For tcsh: `% echo 'bindkey -v' >> ~/.cshrc`


----------



## ShelLuser (Dec 11, 2013)

tzoi516 said:
			
		

> Do you use shells/pdksh or shells/ksh93?


I'm using shells/pdksh. But I'm convinced that the same can be achieved by shells/ksh93 as well, I've been using this setup ever since I became a Solaris administrator, which is already quite some time ago.

Since you're interested, I'm achieving all of this on my environment by adding this to my ~/.profile:


```
# enable KSH settings
. $HOME/.ksh;

# set ENV to a file invoked each time sh is started for interactive use.
ENV=$HOME/.ksh; export ENV
```
I'm using the ENV variable to make sure that my settings are also applied whenever I'm opening a new TMux screen.

Then my ~/.ksh profile, this contains the following:


```
if [ "$0" == "-ksh" ]; then
   set -o posix -o braceexpand -o vi -o vi-tabcomplete;
   PS1="`hostname -s`:\${PWD} \$ ";
fi
```
There was a very good reason why I'm checking for the active shell prior to setting these settings but unfortunately I can't recall them from the top of my head. Probably related to my usage of su and keeping csh as the shell for the root user.

Edit: s/CSH/csh


----------



## ShelLuser (Dec 11, 2013)

Juanitou said:
			
		

> For tcsh: `% echo 'bindkey -v' >> ~/.cshrc`


Since we don't have a thanks system right now I'll just have to write out an "I owe you +1" and do things the hard way 

Cool!

Thanks for sharing this. Now, I'm not going to mess with my root environment (I tend to keep this as pristine as possible) but I'm very happy to learn about the bindkey option. I just checked tcsh(1) and this setup is indeed mentioned there as well (small quote): "_but bindkey can change the key bindings to vi-style bindings en masse._".

It goes to show us once again that tcsh is not to be underestimated  :h


----------



## tzoi516 (Dec 11, 2013)

Thanks @ShelLuser.

I'm running FreeBSD 10.0-RC1 and can't `make install` or use ports-mgmt/portmaster; shells/ksh93 can't find the file when installing, and shells/pdksh is saying it's broken in FreeBSD 10. I haven't tried `pkg install`, but I'm not sure if I want to go that route just yet.


----------



## stejoo (Dec 13, 2013)

tzoi516 said:
			
		

> Thanks @ShelLuser.
> 
> I'm running FreeBSD 10.0-RC1 and can't `make install` or use ports-mgmt/portmaster; shells/ksh93 can't find the file when installing, and shells/pdksh is saying it's broken in FreeBSD 10. I haven't tried `pkg install`, but I'm not sure if I want to go that route just yet.


You might want to check out shells/mksh. It is a successor of shells/pdksh and in active development. I happen to use it on several smaller (some of them embedded) Linux based machines, where it's a lot faster that the default shells/bash that comes with those.  And I sometimes consider making it my main shell, but I just haven't gotten around to that yet.


----------



## tzoi516 (Dec 13, 2013)

Thanks. Even that one is giving me errors, and it's not even in my ports tree

error:

```
===>>> Package installation support cannot be used with pkgng yet,
       it will be disabled


	===>>> No /usr/ports/editors/mksh exists, and no information
	===>>> about editors/mksh can be found in /usr/ports/MOVED

===>>> No valid installed port, or port directory given
===>>> Try portmaster --help

===>>> Killing background jobs
Terminated
===>>> Exiting
```

/usr/ports/editors partial listing:

```
drwxr-xr-x  2 root  wheel     5 Dec  5 10:22 mg/
drwxr-xr-x  3 root  wheel     7 Dec  5 10:22 mined/
drwxr-xr-x  3 root  wheel     7 Dec  5 10:22 mlview/
drwxr-xr-x  3 root  wheel     7 Dec  5 10:22 morla/
drwxr-xr-x  3 root  wheel     7 Dec  5 10:22 mousepad/
drwxr-xr-x  3 root  wheel     7 Dec  5 10:22 mp/
drwxr-xr-x  3 root  wheel     7 Dec  5 10:22 nano/
drwxr-xr-x  3 root  wheel     7 Dec  5 10:22 nano-devel/
drwxr-xr-x  2 root  wheel     5 Dec  5 10:22 ne/
drwxr-xr-x  3 root  wheel     7 Dec  5 10:22 nedit/
```


----------



## wblock@ (Dec 13, 2013)

It is not in editors but in shells: shells/mksh.


----------



## nickednamed (Dec 14, 2013)

I'll have to install games/sl on my brother's computer for a laugh. Good thing his Linux distribution of choice always runs as root  Thanks!

I'm very far from being a vi guru of any kind, but I too really like to use vi-like tools on the terminal when I can. I've been using misc/vifm for a long time now, and have my favourite shell, shells/zsh, set up with vi mode and I've also set it up with the solarized colour scheme, and a few odd aliases like  ":q". 

There are also many non-vi-related zsh customisations that make using the terminal a real pleasure, such as custom prompt with git info/branches and current vi-mode, extra completions, mimeype handling and certain zsh functions sch as zmv and zargs. No need to fire up a file manager at all! 

And here is an example of a shell function called bd that I seem to use a lot.

Regarding vi mode mentioned above, I have a question for the more skilled vi users out there (as I've been spoiled with the like of editors/vim from the start).

In my vim, backspace and delete work as they "usually" do in other programs. However, in vi and vi mode in zsh, backspace (and Ctrl+H) only work up until the last insert point, and the delete key simply changes the case of the characters (not sure how it behaves in shells/khs93, shells/pdksh, shells/bash or shells/mksh but I'm assuming it is the same).

So what's the typical vi way of backspacing past insert points or deleting characters? Is it simply "dw" / "dW" and "db" / "dB"?


----------



## tzoi516 (Dec 16, 2013)

Ugh! I'm an idiot. It happened on a day when I didn't have coffee.


----------



## tzoi516 (Dec 16, 2013)

I installed shells/ksh93 since it's the standard; shells/pdksh is listed as broken, and I did install shells/mksh to compare. I do like some of the vi like key strokes.


----------



## paigosa (Dec 20, 2013)

Are there any text browsers with good JavaScript support?  I have tried elinks but it has trouble with web mail and online banking.  In all honesty, firefox is my primary reason for keeping X11 installed.


----------



## nickednamed (Dec 21, 2013)

@paigosa,

I've tried a number of text browsers (www/netrik, www/lynx, www/w3m, www/retawq, www/links,) but none of them handled _J_ava_S_cript as well as www/elinks.

Have you tired compiling www/elinks with the SPIDERMONKEY option enabled? 

From the www/elinks website: 


> Yes, there is some ECMAScript support in ELinks. There isn't anything we could call complete, but some bits could help with the most common ECMAScript usage cases - help you (and then us  get into your banking account, pass through those ignorant page redirects done by JavaScript code snippets and so.


----------

