Miles to go ...

Dev: Console jockey

Console is pairing input device - the keyboard, and output device - the monitor. That, when jacked into a computing machine, transforms any ordinary human-being into a console-jockey. Let us ride on ..

This post is organized in five parts namely, the terminal, shell, programming languages, version control and handy bunch of tools. Most of these tools are configurable.

Desktop

Keyboard tweaks

sudo apt-get install gnome-tweak-tool // to remap key codes.
sudo apt-get install gnome-session-fallback // to go back to classic desktop

Fonts and konsole

curl -kL https://raw.github.com/cstrap/monaco-font/master/install-font-ubuntu.sh | bash

Use Tweak and Settings to configure startup-applications, fonts, font-size, keyboard, network, suspend-on-power-off etc.

Terminal

Terminal is a 2 dimensional array of character cells to display human readable text. Although it is least useful in the context of pixel graphics, it tends to be most versatile for keyboard jockeys. In present day computers, terminals are almost always emulated, here are some such emulators,

sudo apt-get install konsole terminator
sudo apt-get install libvte-dev

libvte is the popular library that provides the terminal emulator for most of the gtk based terminal application.

If you are power user of terminal, who end up opening several windows and several tabs in each window, then you must seriously consider tmux (or its ancestor screen).

tmux,

In short, tmux allows user to create sessions and attach any number of terminal emulators to a session. Inside a session you can create any number of windows, even splitting them into panes. There is a whole bunch of short-cut keys defined for you to manage, migrate and monitor your windows/panes and emulator clients. For detailed information, check out its man-page.

sudo apt-get install tmux
man tmux    # To learn about tmux.

Shell

Terminal always launches a shell by default. Most likely, the default shell is defined in /etc/passwd or in terminal’s configuration file. If you are a power user you ought to try zsh.

sudo apt-get install zsh zsh-completions zsh-lovers zsh-syntax-highlighting

Zsh comes with an awesome completion, with syntax-highlighting you can even get live feed back about what you are typing, similar to fish-shell.

Don’t forget to configure your shell with .zshrc, there are many samples available through google.

Editor, vim

Start with vim. Sleek, productive and can get extremely powerful for text editing and text manipulations.

sudo apt-get install exuberant-ctags vim vim-scripts vim-python-jedi
sudo apt-get install vim-syntax-docker vim-syntax-go vim-vimerl
sudo apt-get install vim-vimerl-syntax vim-athena vim-gtk vim-gnome

vim comes with a built in scripting language. But bindings are available for several languages like python, lua, tcl etc … To know the available binding in your vim installation,

vim --version

Should list +python, +lua etc.. in the output.

Similarly, to copy/paste content from OS clipboard +clipboard option should be listed when doing –version, subsequently use +yy, +p and related commands inside vim will copy/paste from OS clipboard.

Supposing Vim has clipboard support, synchronizing Vim’s default register and the clipboard register is possible by adding the following line in your .vimrc file,

set clipboard=unnamed

Allowing you to simply use y and p.

Under /etc/vim/vimrc uncomment lines to enable vim to jump to the last position when opening a file.

Programming languages

Now that we have an editor, here is a list of über-cool languages that you should install and play-around with,

lua,

In spirit lua is similar to Javascript, with some semantic support for concurrency using co-routines. It is an elegant and cleanly done language which must be the first choice of language for configuring/extending applications.

sudo apt-get install lua luajit luarocks

luajit is a super-fast Just-in-time compiler for lua that can almost compete with Google-javascript-V8. luarocks is package manager for lua. Packages can be installed local to a single user or under system directory making it available for all users.

node.js,

node.js is a Javascript tool that encourages the paradigm of event-driven programming, similar to what we see in web-browsers. It is one of the fastest growing language-tool-kit.

sudo apt-get install nodejs npm

npm is node-package-manager. Installing the package will also install the console based interactive shell for node. Node packages when

python,

Python is dynamically typed, high level programming language. It is both suitable for quick scripting and prototyping applications, has got a wonderful collection of library that comes along with the distribution and countless third party packages.

sudo apt-get install python python3 python-doc python3-doc
sudo apt-get install python-pip python3-pip # package manager for python
sudo apt-get install ipython ipython3   # powerful interactive shell
sudo apt-get install python-dev python3-dev # python development package

Right now python is going through a phase of split personality, one called as 2.x version and the other called as 3.x version. Incompatibilities exist between these two versions, and there are still some applications/tools that are slowly changing to 3.x version.

This leads to an interesting situation for developers, who may want to develop with Python-2.x sometimes and with Python-3.x other times. Normally get around this problem by using virtualenv.

# Installing setuptools / pip / virtualenv
sudo apt-get install python3-setuptools # Install package python3-setuptools,
sudo easy_install3 pip  # will give you the command pip-3.2 like kev's solution.
sudo pip-3.2 install virtualenv

Since Python-2.x and setuptools will eventually get phased out (hopefully), above gymnastic may not be relevant in the longer run.

If you are authoring python package and uploading them into python-cheeseshop, pypi you can create a ~/.pypirc to automatically upload your package with credential. Make sure that the file is readable only by your uid,

[distutils]
  index-servers = pypi

[pypi]
  repository: http://www.python.org/pypi
  username: <username>
  password: <password>

haskell,

Haskell is a functional language that does lazy evaluation. It has a very strong community of programmers and large collection of libraries and tools.

sudo apt-get install ghc ghc-doc ghc-haddock ghc-prof haskell-platform
cabal update                # Update list of haskell packages.
sudo apt-get install darcs

darcs is a DVCS written in haskell and many haskell projects use that as their revision control. Cabal is the package manager for haskell.

erlang,

erlang is the default language to create multi-node distributed and concurrent applications.

sudo apt-get install erlang erlang-base-hipe erlang-doc erlang-manpages

HiPE is High Performance Erlang, a just-in-time compiler for erlang. Even though it is not as sophisticated as JVM it does a decent job.

ruby,

Ruby is good to create scriptable tools where the scripts, although interpreted as ruby program, can be written in declarative style.

sudo apt-get install ruby ruby-dev

go,

sudo apt-get install golang gccgo-go

To work with bleeding edge Go, download the latest version for the target machine,

tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
export PATH=$PATH:/usr/local/go/bin

Some go tools,

go get code.google.com/p/go-tour/gotour # tutorial on go.

go get github.com/golang/lint # for golint
cd lint; go install ./...

go get github.com/mattn/goveralls # for goveralls
go install github.com/mattn/goveralls

go get github.com/axw/gocov # for gocov
cd lint; go install ./...

sudo apt-get install protobuf-compier # to install protobuf

Mercurial must be installed for go get command to work.

rust

Rust is probably the most ambitious systems language in past two decades. Has a fine balance between performance, abstraction, and code stability. Check out [rust installation page][https://www.rust-lang.org/en-US/install.html] on installing the rust compiler, toolchain and standard library.

Rust toolchain involves:

development tools,

use ncurses to author terminal applications.

sudo apt-get install automake autoconf  # Used for compiling C packages.
sudo apt-get install openssl  ncurses-examples # Secure socket layer
sudo apt-get install ncurses-base libncurses-dev ncurses-doc
sudo apt-get install libxml2-dev libxslt1-dev   # a tolerant HTML/XML parser
sudo pip install lxml
sudo pip3 install lxml

To configure DNS. Add this line in /etc/dhcp/dhclient.conf

option domain-name-servers 8.8.8.8

For development that does not consider full-screen terminal, just a reasonable control on keyboard-input line by line, readline is very good. There is also rlwrap tool that will give readline like interface for many interpreters.

sudo apt-get install readline rlwrap

Readline settings to use vim key-binding. Open /etc/inputrc and add the following line,

set editing-mode vi

Version control

Subversion is a great replacement for CVS, which have the concepts of tagging and branching straightened out when compared to CVS.

sudo apt-get install subversion

Mercurial,

When new to DVCS (distributed version control system) Mercurial is better place to start. Written in C and python is fast and fun to work with, although it might complain when committing large files (>10M).

sudo apt-get install mercurial

The following configurations might be helpful when working with hg (the command line program to access mercurial repositories). Add them under ~/.hgrc

[ui]
username = username <emailid>
verbose = True

If you are planning to use code.google.com or bitbucket with mercurial you might want your credentials to be automatically authenticated. For such cases add a list of credentials under [auth] section in the ~/.hgrc

[auth]
paenv-gc.prefix = code.google.com/p/paenv/
paenv-gc.username = prataprc
paenv-gc.password = <password>
paenv-gc.schemes = http https

pluggdapps-gc.prefix = code.google.com/p/pluggdapps/
pluggdapps-gc.username = prataprc
pluggdapps-gc.password = <password>
pluggdapps-gc.schemes = http https

In the above configuration paenv-gc and pluggdapps-gc prefixes group auth credentials for different repositories.

git,

Most popular among version control system is git, thanks to linux and github for doing that. Install a plugin for large file storage from github.

sudo apt-get install git git-lfs

After installing git, update the user configuration file ~/.gitconfig,

[color]
    ui = auto

To change your git username setting, use the git config command,

git config --global user.name  "Anand T"         # Set a new name
git config --global user.email "anand@gmail.com" # Set your emailid
git config --global core.editor /usr/bin/vim     # use editor

The –global flag writes this setting into your global git config. If you remove that flag you can override the setting for your current repository. You can learn more with these articles.

In case you want to publish mercurial repositories on github or with any other git respository-hosting service, you can use hg-git and dulwich

sudo pip install hg-git dulwich
sudo pip3 install hg-git dulwich

And add the following configuration settings under .hgrc file

[extensions]
hgext.bookmarks =
hggit=

ssh setup for github

ssh -T git@github.com

Few other version control systems,

sudo apt-get install bzr    # created and maintained by canonical-ubuntu
cabal install darcs         # written in haskell

In case you have not installed ghc and haskell-platform, it is explained else where in this article. Some say that darcs has the best support for cherry picking and in some sense true to the spirit of Distributed Version Control System.

Dictionary

sdcv is command line interface for stardict dictionary program.

sudo apt-get install sdcv
sdcv -l

You can download dictionaries and install them under ~/.stardict/ directory and add following exports in your bashrc or zshrc file.

export STARDICT_DATA_DIR=$HOME/.stardict/dic
export SDCV_HISTSIZE=10000

To learn hardware info

lspci will show you most of your hardware in a nice quick way. Some of the commonly used flags are:

It doesn’t show USB hardware other than the USB bus.

Here are three real world examples: Graphics:

$ lspci -nnk | grep VGA -A1
$ lspci -nnk | grep net -A2
$ sudo lshw | less
$ sudo lshw -c network

For something graphical:

sudo apt-get install hardinfo

Tools and applications

A collection of useful console application.

sudo apt-get install mc                 # Midnight-commander, file manager
sudo apt-get install mutt               # email client
sudo apt-get install muttprint muttprint-manual mutt-patched 
sudo apt-get install elinks elinks-doc  # browse web in text-mode
sudo apt-get install finch              # console version of pidgin
sudo apt-get install newsbeuter         # RSS / Atom feed reader
sudo apt-get install irssi              # IRC client
sudo apt-get install sc                 # spread-sheet calculator
sudo apt-get install cmus               # music player
sudo apt-get install urlview            # extracting url from text 
sudo apt-get install w3m
sudo apt-get install rename
sudo apt-get install ltrace htop atop iostat iotop
sudo apt-get install qpdfview			# pdf reader
sudo apt-get install cmake

More tools and utilities.

sudo apt-get install htop atop xclip rar curl apache2-utils
sudo apt-get install sqlite3    # Access SQL-like database as library
sudo apt-get install gimp       # Image processing tool

Add package repository for adobe acrobat.

# Application - adobe acrobat
sudo apt-add-repository "deb http://archive.canonical.com/ $(lsb_release -sc) partner"
sudo apt-get update
sudo apt-get install acroread

To share your file-system with Windows, use samba server and configure the user-name.

# Optional - samba
sudo apt-get install samba samba-common python-glade2 system-config-samba
# After adding the shared directory, do the following
sudo smbpasswd -a <username>

ssh and automatic authentication for tools using ssh. After generating the key, append id_rsa.pub to client’s authorized_keys under .ssh/authrized_keys

sudo apt-get install openssh-client openssh-server
ssh-keygen -t rsa   # Optional ssh auto login
chmod 700 $HOME/.ssh # security
sudo apt-get install ssh-askpass
service ssh restart

GUI tools and utilities.

# Optional packages - settings, configuration and desktop
sudo apt-get install firefox chromium-browser
sudo apt-get install myunity
sudo apt-get install indicator-multiload    # Load indicator applet

Sometimes default browser is picked from x-www-browser or gnome-www-browser

sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser /snap/bin/chromium 10
sudo update-alternatives --install /usr/bin/gnome-www-browser gnome-www-browser /snap/bin/chromium 10

Installing fonts for Konsole. I especially like inconsolata. After running fc-cache start the konsole and configure your desired fonts.

sudo apt-get install ttf-inconsolata fonts-inconsolata
sudo apt-get install xfonts-terminus console-terminus
sudo fc-cache 
fc-cache

Github, Jekyll for static sites

Github can also host blog-sites, project-sites, and other microsites, using Jekyll static generator platform. To set it up locally on linux before publishing it follow up with this link.

Useful gnome extension

Handy set of shortcuts

Gnome-Terminal, tmux, vi shortcuts

Browser shortcuts in linux

For mac

iterm2 is the pretty good. Download the .zip, unzip and cut paste the iterm2.app folder to /Applications, as of this writing iterm2 is not available via brew.

# Copy paste from clip-board
bind P run "pbpaste | tmux load-buffer -; tmux paste-buffer"
bind Y run "tmux save-buffer - | pbcopy"
brew install reattach-to-user-namespace

If you are using tmux, take a look at this

Use Option-key + mouse to select text inside tmux, then use CMD+c to copy the selected text. CMD+v works anyway