A nice linux terminal environment
I always want to have a nice environment when I log into my linux boxes. One way to achieve this is to use TMUX, It allows me to customize the terminal and keep all my sessions, if I loose my connection to the box. Here is a screen dump of one of my boxes from mobaxterm:
First we need to install TMUX.
apt-get install tmux
Then I put a configuration file (~/.tmux.conf) and customize it to my needs.
# remap prefix from 'C-b' to 'C-a' unbind C-b set-option -g prefix C-a bind-key C-a send-prefix # split panes using | and - bind | split-window -h bind - split-window -v unbind '"' unbind % # reload config file (change file location to your the tmux.conf you want to use) bind r source-file ~/.tmux.conf # switch panes using CTRL-arrow without prefix bind -n C-Left select-pane -L bind -n C-Right select-pane -R bind -n C-Up select-pane -U bind -n C-Down select-pane -D # Enable mouse mode set -g mouse on # Start numbering at 1 set -g base-index 1 # Activity monitoring setw -g monitor-activity on set -g visual-activity on # Scroll history set -g history-limit 30000 # Bind function keys for each terminal bind -n F1 select-window -t 1 bind -n F2 select-window -t 2 bind -n F3 select-window -t 3 bind -n F4 select-window -t 4 bind -n F5 select-window -t 5 bind -n F6 select-window -t 6 # Full screen on F12 bind -n F12 resize-pane -Z # F10 makes a pane into its own screen bind -n F10 break-pane # Status bar and colors set -g default-terminal "screen-256color" set -g set-titles on set -g set-titles-string '#H' setw -g window-status-format '#I:#W#F' set -g status-interval 1 set -g status-justify left set -g display-time 1500 set -g repeat-time 500 setw -g mode-attr bold setw -g mode-fg colour196 setw -g mode-bg colour239 set -g pane-border-bg colour235 set -g pane-border-fg colour239 set -g pane-active-border-bg colour236 set -g pane-active-border-fg colour199 set -g status-position bottom set -g status-bg colour234 set -g status-fg colour137 set -g status-attr dim set -g status-left '#[fg=colour255,bg=colour53,bold] #H #[bg=colour234] ' set -g status-right '#[fg=colour255,bg=colour53,bold] #(cut -d " " -f 1-3 /proc/loadavg) | %H:%M:%S %Z ' set -g status-right-length 50 set -g status-left-length 50 setw -g window-status-current-fg colour170 setw -g window-status-current-bg colour239 setw -g window-status-current-attr bold setw -g window-status-current-format ' #I#[fg=colour250]:#[fg=colour255]#W#[fg=colour170]#F ' setw -g window-status-fg colour138 setw -g window-status-bg colour235 setw -g window-status-attr none setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F ' setw -g window-status-bell-attr bold setw -g window-status-bell-fg colour255 setw -g window-status-bell-bg colour1 set -g message-attr bold set -g message-fg colour232 set -g message-bg colour166
The main features of this configuration file is:
- Function keys can be used to switch between sessions
- ctrl-a is mapped as the TMUX hotkey (yes I come from GNU screen, but tmux is just better)
- ctrl-a, – makes a horizontal split
- ctrl-a, | makes a vertical split
- ctrl-left/right/up/down changes between split windows.
- Mouse in windows can be used to select a session.
I made a startfile (~/tmux-start) that I refer to from my Putty or MobaXterm…
#!/bin/bash # Make sure tmux shows correct colors export TERM=xterm-256color # attach to existing tmux session or create a new session if ps ax | grep -v grep | grep -v tmux-start | grep tmux > /dev/null then tmux attach else tmux new-session fi
Now I setup a new session in my MobaXterm like this (important to set the startup command, and the terminal type in order to enable function keys)
My preferred editor is VI – it’s important for me that is has a nice color scheme. I control this by editing ~/.vimrc
syntax on set t_Co=256 " Fix backgroundcolor for themes. without this its always black set t_ut= " load theme from ~/.vim/colors - just put .vim file there and refer to it here without .vim colorscheme gentooish
To install the theme gentooish:
mkdir ~/.vim mkdir ~/.vim/colors wget http://www.vim.org/scripts/download_script.php?src_id=9630 -O ~/.vim/colors/gentooish.vim
And to install a color enabled VI i install VIM:
apt-get install vim
Now I am happy with my working environment 🙂 Example of my VIM: