Personalising my toolset: Konsole, BASH, Emacs, weechat, tmux..

by Amit


Terminal Emulator and Shell

I use the KDE desktop (on Fedora), hence my choice of terminal emulator is KDE’s Konsole with the Solarized theme, which is built-in. I use the BASH shell, with almost no aliases and exports. However, I use a custom prompt so that I have a different color for the prompt and the output of the commands:

# prompt
# http://maketecheasier.com/8-useful-and-interesting-bash-prompts/2009/09/04
PS1="\[33[35m\]\t\[33[m\]-\[33[36m\]\u\[33[m\]@\[33[32m\]\h:\[33[33;1m\]\w\[33[m\]\$ "

Emacs

I have been a Emacs user for few years now. Unlike most people, I usually do very few customisations and/or install extra Emacs packages to enhance its functionality beyond the default features. However, last time I installed it after my upgrade to Fedora 18, I decided to spend some time customising it to my liking. I came across the awesome Mastering Emacs [1] blog of Mickey and used it as a reference point for making my Emacs customized to the way I hadn’t done before. When you first install Emacs (Emacs 24 is what I am using), on starting it what you see is something like this:

Image

The first things I do is remove the Menu bar, tool bars, scrollbar and the startup splash screen and message, which can be done with the following lines of Emacs Lisp:

(setq inhibit-startup-message t
      inhibit-startup-echo-area-message t)  
(menu-bar-mode -1) 
(tool-bar-mode -1) 
(scroll-bar-mode -1)

Now, where do you put these customization code snippets? There are three choices: ~/.emacs, ~/.emacs.el and ~/.emacs.d/init.el (where ~ indicates your home directory). I have the customization scripts in ~/.emacs.d/init.el (since that allows me to have everything in .emacs.d directory). See [2] for more details on init files.

Next, I add a few more customisations: always have line numbers and column numbers displayed and set auto-fill mode on (to automatically wrap lines). Here is how my init.el looks like now (lines beginning with ;; are comments are hence ignored):

;; hide them all.
(setq inhibit-startup-message t
inhibit-startup-echo-area-message t)
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)

;; Line number
(global-linum-mode 1)
;; Show column-number in the mode line
(column-number-mode 1)

;; Auto-fill mode
(add-hook 'text-mode-hook 'auto-fill-mode)

With the writing area quite to my liking, I next explore Emacs’s package manager [3] which will allow me to customize Emacs with a few more enhancements by installing packages. The package-list-package command will list all the currently available pacakages in ELPA with their status in my Emacs installation such as available, built-in.:

M-x package-list-packages

M-x package-list-packages

To install a new package, I can use the command package-install RET RET (or, you could use the mouse).

Theme: The first package I want to install is the solarized theme for Emacs. However, it is not available in ELPA for that, I will need to add another package repository, that of MELPA [4]. The following code in my init.el does that:

(require 'package)
(add-to-list 'package-archives
             '("melpa" . "http://melpa.milkbox.net/packages/") t)

I restart Emacs and the command package-list-packages displays a number of other packages from the MELPA repository, one of them being the solarized theme which I can install using: package-install RET color-theme-solarized RET . Now, I will need to add code to load the theme on startup. The following snippet does it:

(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/solarized")
(load-theme 'solarized-dark t)

By default, the solarized theme will be installed (like other packages) in ~/emacs.d/elpa. To keep my themes in a separate directory, I create a sub-directory themes under my emacs.d directory and keep all the solarized files in a separate directory solarized. Now, when I restart Emacs, I see something like this:

Emacs + Solarized

Emacs + Solarized

This is pretty much my workable Emacs configuration right now leaving aside one more package: IEdit [5]. I think this will be pretty useful for a bulk search and replace. I installed it using: package-install RET iedit RET. To enable it, use the command iedit-mode or, use C-;. See: http://ascii.io/a/1923 for a quick demo. . I hope to learn more about IEdit as I start using it more.

Like other editors, Emacs creates a backup copy when you are editing a file. This leads to a pollution of your working directory with files whose names end with ~. To tell Emacs to save to a different directory, you can add the following snippet to your init.el (taken from [7]).:

(setq
   backup-by-copying t      ; don't clobber symlinks
   backup-directory-alist
    '(("." . "~/.saves"))    ; don't litter my fs tree
   delete-old-versions t
   kept-new-versions 6
   kept-old-versions 2
   version-control t)       ; use versioned backups

 

That’s it for my Emacs configuration for now. You may want to see some of the resources I have gathered so far here [6]. My init.el file looks like this now:

;; hide them all.
(setq inhibit-startup-message t
      inhibit-startup-echo-area-message t)  
(menu-bar-mode -1) 
(tool-bar-mode -1) 
(scroll-bar-mode -1)

;; Line number
(global-linum-mode 1)
;; Show column-number in the mode line
(column-number-mode 1)

;; Auto-fill mode
(add-hook 'text-mode-hook 'auto-fill-mode)

;; Package repo
(require 'package)
(add-to-list 'package-archives
             '("melpa" . "http://melpa.milkbox.net/packages/") t)
;; ;; (add-to-list 'package-archives
;; ;;              '("marmalade" . "http://marmalade-repo.org/packages/") t)

;;(package-initialize)

;; Solarized theme
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/solarized")
(load-theme 'solarized-dark t)

;; Font setting
(add-to-list 'default-frame-alist '(font . "DejaVu Sans Mono-14"))

;; Backup settings
(setq
   backup-by-copying t      ; don't clobber symlinks
   backup-directory-alist
    '(("." . "~/.editing_backups"))    ; don't litter my fs tree
   delete-old-versions t
   kept-new-versions 6
   kept-old-versions 2
   version-control t)       ; use versioned backups

Links:

[1] http://masteringemacs.org/
[2] http://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html
[3] http://emacswiki.org/emacs/ELPA
[4] http://melpa.milkbox.net/
[5] http://www.masteringemacs.org/articles/2012/10/02/iedit-interactive-multi-occurrence-editing-in-your-buffer/
[6] https://gist.github.com/4600244
[7] http://emacswiki.org/emacs/BackupDirectory

One last bit of customisation I do is always start Emacs in maximized mode. Hence, I have added a BASH alias: alias emacs='emacs -mm' in my .bashrc.

Weechat for IRC

I have been using Weechat for few weeks now and really like it. I have been meaning to switch to a console based IRC client for a while now, and weechat finally looked friendly enough for me to switch to one. Here are my notes [1] on how to setup a new server, autoconnect on startup, auto join channels, etc.

[1] https://gist.github.com/4487378

tmux

No customisations yet.

About these ads