2016年6月1日 星期三

linux tmux install from source

Build from source
~~~~~~~~~~~~~~~

tmux depends on libevent 2.x. Download it from:

 http://www.monkey.org/~provos/libevent/

 
cd libevent/
./configure --prefix=/home/robert/opt
make && make install
 

You may need to modify:
LD_LIBRARY_PATH ="~/opt/lib:$LD_LIBRARY_PATH "
 
# For tmux 2.9a
cd tmux/

export CPPFLAGS='-I/home/robert/opt/include' LDFLAGS='-L/home/robert/opt/lib'
 
autoconf

./configure --prefix=/home/robert/opt

make
make install


Tmux config [~/.tmux.conf]
~~~~~~~~~~~~~

Make it screen-key compatible & vim-like split :

> cat examples/screen-keys.conf examples/vim-keys.conf >~/.tmux.conf


Append to do my customization:

> vi ~/.tmux.conf

############################################
#robert

# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf \; display-message "Config reloaded..."

# kill pane (overwrite lock-server in screen-keys.conf)
unbind x

bind x kill-pane

# window previous/next/rename
unbind -n F10
bind -n F10 command-prompt "rename-window %%"
unbind -n F11
bind -n F11 previous-window
unbind -n F12
bind -n F12 next-window

# Set status bar
set -g status-bg black
set -g status-fg white
set -g status-left ''
set -g status-right '%H:%M %d/%b/%Y'

# Highlight active window
# before tmux 2.9
#set-window-option -g window-status-current-attr bright
#set-window-option -g window-status-current-bg blue
#set-window-option -g window-status-current-fg yellow
#set-window-option -g window-status-fg red

# after tmux 2.9
set -g window-status-current-style bright,bg=blue,fg=yellow
set -g window-status-style fg=red

# window-status format -- default is ‘#I:#W#F’
set -g window-status-format '#I #W '
set -g window-status-current-format '#I #W '

# new windows and pane split keep your current directory
bind-key c new-window -c "#{pane_current_path}"
bind s split-window -v -c "#{pane_current_path}"
bind v split-window -h -c "#{pane_current_path}"

# swap window with the left/right window
unbind -n F7
bind -n F7 swap-window -t -1
unbind -n F8
bind -n F8 swap-window -t +1




For more STYLES, search STYLES in "tmux man".



Tutorial
~~~~~~~

Help:
CTL-a ?


1. Session

You create a session.

> tmux
> tmux ls
0: 1 windows (created Sat Dec 12 15:04:45 2015) [143x38] (attached)

Detach (but not delete) this session:
CTL-a d

Attach to previous session:
> tmux a


2. Window

You can have multiple windows.
But only one window can show at a time.

Create a new window:
CTL-a c

Go to previous window:
CTL-a p

Go to next window:
CTL-a n       (or space)

Rename a window:
CTL-a A

Kill window:
CTL-a K


3. Pane

You can have many panes in a window.
And panes in a window can show at the same time.

Vertically splitting a window to create a pane:
CTL-a v

Horizontally:
CTL-a s

Move the current pane to a new window:
CTL-a !



5. Server

Kill tmux server:
CTL-a \



Tmux script for project
~~~~~~~~~~~~~~~~~~

My tmux script will 
* create a session
* create several windows


> vi tmux_open.sh

###########################
#!/bin/bash

tmux start-server
tmux new-session -d -s OK

tmux rename-window win1
tmux new-window -n win2 -c ~/work/xx1
tmux new-window -n win3 -c ~/work/xx2 
tmux select-window -t 0

tmux attach



ref:
How to add libraries path to the ./configure command?
http://askubuntu.com/questions/386315/how-to-add-libraries-path-to-the-configure-command
* 進化版screen
http://forum.j2eemx.com/forum44/thread9789.html
* Tmux 教學 + Screen 到 Tmux 的無痛轉換
http://blog.longwin.com.tw/2011/04/tmux-learn-screen-config-2011/
* A sample to customize status bar
  http://dotshare.it/dots/830/
* simple tmux configuration
http://blog.hawkhost.com/2010/07/02/tmux-%E2%80%93-the-terminal-multiplexer-part-2/

2014年3月26日 星期三

Hide GPT partitions from Windows

You want to hide Linux GPT partitions from Windows.

Under Ubuntu:
1. Install GPT tool : gdisk
> sudo apt-get install gdisk

2. Set interested GPT partition attributes to Windows hide and no automount:
> sudo sgdisk -A <part>:set:62 <disk>
> sudo sgdisk -A <part>:set:63 <disk>
(62: hide ; 63: no automount)

As a note, use "-A <part>:clear:<attribute_bit_pos>" to clear a attribute bit.

robert$ sudo sgdisk /dev/sdc -A 5:set:62
The operation has completed successfully.

robert$ sudo sgdisk /dev/sdc -A 5:set:63
The operation has completed successfully.

3. Print the partition#<part> attributes:
> sudo sgdisk -A <part>show <disk>

robert$ sudo sgdisk -A 5:show /dev/sda
5:62:1 (hidden)
5:63:1 (do not automount)




2012年12月24日 星期一

[debian] disable pc beeper

Just append one line to /etc/modprobe.d/blacklist :


> echo "blacklist pcspkr" >> /etc/modprobe.d/blacklist


> reboot


Ref:

http://arsgeek.hubpages.com/hub/How-to-turn-off-the-annoying-system-beep-in-linux-DebianUbuntu

[debian] How to move /etc into ramfs easily


> vi /etc/init.d/rcS

Add these lines before "exec /etc/init.d/rc S":

echo "* Initialize RAM /etc..."
[ ! -d /etc-model ] && mkdir /etc-model
mount --rbind /etc /etc-model
mount -n -t tmpfs none /etc
cp -a /etc-model/* /etc/

> vi /etc-model/init.d/umountfs

Add "/etc" in the line:
case "$MTPT" in |/proc|/dev/|..........|/etc)


基本上它運作的邏輯是: 開機時, rcS會自動把 /etc 掛成RAM,然後把舊的 /etc (位在/etc-model)copy進來。
所以之後要手動改系統預設的設定,都是要改 /etc-model 底下的。

2012年3月27日 星期二

u-boot dhcp request, no ack

In u-boot> dhcp

discover ->
offer <-
request ->

no ack!

discover, offer, request, loop...

While the same board can run dhcp client without problem in Linux.

It turns out that the problem is on dhcp server: some dhcp servers will ignore too fast request.

I found this fix to u-boot:

Just put a short delay (50~100ms) between offer and request.

2012年2月24日 星期五

"route: SIOCDELRT: No such process"

"route: SIOCDELRT: No such process"

this message comes from "route del"

ref:
http://lists.busybox.net/pipermail/busybox/2010-December/074073.html

2012年2月20日 星期一

Invalid FAT entry (uboot)

Did you encounter

Invalid FAT entry

when using fatload or fatls command in uboot?
possibly the filesystem is corrupted (from the view of uboot).
For instance,

U-Boot > fatls mmc 0
2187544 uimage
Invalid FAT entry

1 file(s), 0 dir(s)

Try to format the partition to fat. (mkfs.vfat)
Copy origin files into it and try again.