Showing posts with label terminal. Show all posts
Showing posts with label terminal. Show all posts

Saturday, May 5, 2012

My GNU Screen Configuration

First an update on my latest setup. I switched to Arch Linux a while back and I'm rather happy with it so I'm not thinking of going back to Ubuntu at the moment despite the fact that I'm hearing it's in a good condition.

Second I've started using screen a lot more than before. Specifically, I began running my emacs session inside screen a while back, so that I can connect to my home computer from other places and attach to my screen session and use the running emacs instance. More recently, I've switched to using tmux instead of screen but for the sake of keeping history, I'm posting the code and configuration I used to use here. tmux will be the subject of another post.

This is the .screenrc I used:

escape ^Oo                                                                                                                                                                                     
vbell off                                                                                                                                                                                      
                                                                                                                                                                                               
# Scrollback buffer size in lines                                                                                                                                                              
defscrollback 5000                                                                                                                                                                             
                                                                                                                                                                                               
startup_message off                                                                                                                                                                            
                                                                                                                                                                                               
hardstatus alwayslastline                                                                                                                                                                      
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'                                                       
                                                                                                                                                                                               
# enable support for 256 colors                                                                                                                                                                
term screen-256color                                                                                                                                                                           
terminfo rxvt-unicode 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'                                                                                                                                   
                                                                                                                                                                                               
# fix for residual editor text. sometimes when you run an editor and                                                                                                                           
# close it, some of its text may stay visible. this fixes that                                                                                                                                 
# problem.                                                                                                                                                                                     
altscreen on                                                                                                                                                                                   
                                                                                                                                                                                               
screen -t  emacs       0        emacs -nw                                                                                                                                                      
screen -t  shell0
It changes the screen prefix to ^O so that it doesn't clash with the emacs shortcut. It turns off the visual bell, enlarges to scrollback buffer, turns off the welcome screen, adds a status line, enables 256 color support inside screen, enables alternate screen (so that residual text from some editors will not stay visible after closing them), and finally starts a shell and an emacs instance.

I also added this code to my .stumpwmrc so that I can switch to emacs in the usual way (by pressing C-t C-e):
(defcommand emacs-in-screen () ()                                                                                                                                                              
  "attempts to switch to an emacs instance run in a gnu screen window                                                                                                                          
called 'emacs', itself inside a urxvt instance."                                                                                                                                               
  (let ((ret                                                                                                                                                                                   
         (run-shell-command "screen -X select emacs > /dev/null ; echo $?" t)))                                                                                                                
    (if (eql (elt ret 0) #\0)                                                                                                                                                                  
        (run-or-raise "urxvt" '(:class "URxvt"))                                                                                                                                               
        (message "no screen session found."))))                                                                                                                                                
(define-key *root-map* (kbd "C-e") "emacs-in-screen")
For some reason this sometimes fails to switch to emacs properly, but it usually does!

And one last thing. The GNU Screen version shipped with Arch lacks vertical split support. This AUR package contains the patch for vertical splitting. Unfortunately, it lacks another patch that stops screen from complaining about long $TERM values, so I made a new AUR package that applies this other patch, too. I found that the process of creating Arch packages is surprisingly easy. In this case, I just downloaded the other package, updated its PKGFILE, and made the source tarball using makepkg --source.

Sunday, March 18, 2012

urxvt: looking better and with tabs

urxvt is a great terminal emulator, but I don't particularly care for it's default look and feel. It's not very difficult to make it look better though.

This page explains how you can make urxvt look like gnome-terminal by adding a few lines to your .Xdefaults file. This is how my .Xdefaults looks like:
URxvt*background: #000000
URxvt*foreground: #00ff00
! black
URxvt.color0  : #000000
URxvt.color8  : #555555
! red
URxvt.color1  : #AA0000
URxvt.color9  : #FF5555
! green
URxvt.color2  : #00AA00
URxvt.color10 : #55FF55
! yellow
URxvt.color3  : #AA5500
URxvt.color11 : #FFFF55
! blue
URxvt.color4  : #0000AA
URxvt.color12 : #5555FF
! magenta
URxvt.color5  : #AA00AA
URxvt.color13 : #FF55FF
! cyan
URxvt.color6  : #00AAAA
URxvt.color14 : #55FFFF
! white
URxvt.color7  : #AAAAAA
URxvt.color15 : #FFFFFF

URxvt*font: xft:Monospace:pixelsize=18

URxvt*letterSpace: -1

URxvt.perl-ext-common : default,matcher
URxvt.urlLauncher     : firefox
URxvt.matcher.button  : 1


! scrollbar style - rxvt (default), plain (most compact), next, or xterm
URxvt.scrollstyle: plain

URxvt.perl-ext-common:  default,tabbed
Also, if you like to have tabs, you can run urxvt like urxvt -pe tabbed, or you can add this line to your .Xdefaults.
URxvt.perl-ext-common:  default,tabbed
 In order to open a new tab, press C-M-Down (that is, control and alt and down arrow). To switch tabs use C-M-Left and C-M-Right. To move the current tab, use C-Left and C-Right. I wish I could change these key bindings since the arrow keys are two far away from my comfort zone, but I haven't find a way to do that, yet. Well, nothing is perfect!

For more urxvt customizations, see this page.

By the way, this is the commands I've put in my .stumpwmrc in order to have urxvt as my default terminal emulator. Notice that the class attribute is URxvt not Urxvt as one might expect.
(defcommand urxvt () ()
  "Start a urxvt instance or switch to it if already running"
  (run-or-raise "urxvt" '(:class "URxvt")))
(define-key *root-map* (kbd "c") "urxvt")
(define-key *root-map* (kbd "C-c") "urxvt")
 If you're ever in doubt about the class attribute of a certain window, just switch to it, press C-t : and then type in (stumpwm::window-class (stumpwm::current-window)).

Better Console Font (in Arch)

In order to use Terminus as my console (tty) font, I simply installed the package terminus-font with pacman (includes both console and X11 ...