Rawr!!!

[PotW] tmux

Written by
October 13th, 2010

Tmux-Fire

It’s another Tuesday (errm almost tuesday — I got a little busy), and that means another PotW! This program is a little more useful than the last program. And makes living a mac more bearable (or any non tiling window manager for that matter) Tmux is the bees knees when it comes to console multi-tasking. It allows you to do a faux-tiling window manager with all your console apps, and the best part is that it’s cross platform. Just a little info about tmux: It stands for terminal multiplexer (cool name for multiplier), tmux is like screen’s pretty cousin, tmux is highly configurable, and a lot more stuff that I’ll have to split up in a few more posts. (this is just a primer, and yes I will talk about tmux more ;)

Program: tmux

Site Link: http://tmux.sourceforge.net

Download:

  1. Download direct: http://downloads.sourceforge.net/tmux/tmux-1.3.tar.gz
  2. Use CVS & get the newest version: CVS instructions for tmux

Installation:

  1. Use your package manager (pacman -S tmux for archlinux)
  2. Mac (download homebrew && sudo brew install tmux)

Compile:


./configure

make -j8 (make with 8 jobs at once [compile faster on a core duo])

sudo make install

How to use:

Lets start with the basics. Fire up tmux, and lets learn how to get some, errrm, help!

  1. man tmux (best resource, and well documented)
  2. ^b ? (Ctrl-?) [Press Ctrl-b, then ?] (will show commands with short descriptions)

Lets start with some basics:

  • make a new vertical pane: ^b % (Carat ‘^’ means Ctrl)
  • make a new horizontal pane: ^b “
  • make a new window: ^b c
  • rename window: ^b ,
  • move around: ^b (use arrow keys)

Now that you know your way around, lets have some fun:

  • Find test in an open window: ^b f (this one tickles me pink, it’s so kewl that you can search for *anything*, and it will auto-move to the terminal your thinking of)
  • enter copy mode to copy text in buffer: ^b [
  • paste the text you've copied: ^b ]
  • what time is it?: ^b t
  • swap panes around: ^b { (previous pane) and } (next pane)

Screenshots:

Layout 1Layout 2Layout 3Layout 4Layout 5window-naming

Default Bindings (all the things you can do):

The default command key bindings are:

C-b         Send the prefix key (C-b) through to the application.
C-o         Rotate the panes in the current window forwards.
C-z         Suspend the tmux client.
!           Break the current pane out of the window.
"           Split the current pane into two, top and bottom.
#           List all paste buffers.
%           Split the current pane into two, left and right.
&           Kill the current window.
'           Prompt for a window index to select.
,           Rename the current window.
-           Delete the most recently copied buffer of text.
.           Prompt for an index to move the current window.
0 to 9      Select windows 0 to 9.
:           Enter the tmux command prompt.
=           Choose which buffer to paste interactively from a list.
?           List all key bindings.
D           Choose a client to detach.
[           Enter copy mode to copy text or view the history.
]           Paste the most recently copied buffer of text.
c           Create a new window.
d           Detach the current client.
f           Prompt to search for text in open windows.
i           Display some information about the current window.
l           Move to the previously selected window.
n           Change to the next window.
o           Select the next pane in the current window.
p           Change to the previous window.
q           Briefly display pane indexes.
r           Force redraw of the attached client.
s           Select a new session for the attached client interactively.
t           Show the time.
w           Choose the current window interactively.
x           Kill the current pane.
{           Swap the current pane with the previous pane.
}           Swap the current pane with the next pane.
~           Show previous messages from tmux, if any.
Page Up     Enter copy mode and scroll one page up.
Up, Down
Left, Right
Change to the pane above, below, to the left, or to the right of the current pane.
M-1 to M-5  Arrange panes in one of the five preset layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, or tiled.
M-n         Move to the next window with a bell or activity marker.
M-o         Rotate the panes in the current window backwards.
M-p         Move to the previous window with a bell or activity marker.
C-Up, C-Down
C-Left, C-Right
Resize the current pane in steps of one cell.
M-Up, M-Down
M-Left, M-Right
Resize the current pane in steps of five cells.

Arch Linux on iMac [Arch Only]

Written by
September 21st, 2010

So I just got an iMac for work, and decided to put linux on it. I could have stuck with Mac, but meh, I need linux! It makes me all warm and fuzzy inside. I wrote down a log of what I did to get everything working, enjoy.

New-Desk

1) Boot up Mac & install rEFIt (http://refit.sourceforge.net) && reboot twice (second reboot should show rEFIt menu.

2) Boot Archlinux CD ( I choose the x86_64 netinstall image) & append “nomodeset” <without quotes> to the end of the boot line

3) Convert disk from GUID to MBR
- login (root)
- dhcpcd eth0
- pacman -Sy && pacman -Su
- pacman -S gdisk
- [root@archiso ~]# fdisk -l | grep /dev (this will give you your disk)

Disk /dev/sda: 500.1 GB, 500107862016 bytes << this is the disk I want (I only have one disk in the system)

- [root@archiso ~]# gdisk /dev/sda

GPT fdisk (gdisk) version 0.6.10

Partition table scan:
MBR: MBR only
BSD: not present
APM: not present
GPT: present

Found valid MBR and GPT. Which do you want to use?
1 – MBR
2 – GPT
3 – Create blank GPT

Your answer:
1

1  – MBR (This really doesn’t matter since we are going to wipe GPT, but select it anyway)

Command (? for help): x

Expert command (? for help): z
About to wipe out GPT on /dev/sdc. Proceed? (Y/N): y
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
Blank out MBR? (Y/N): y

This will wipe out GPT & MBR for a brand new HDD, now you are ready to continue with your arch install as if it was a beige box.



4) Continue With Install (/arch/setup)
- Select Source (kernel.org)
- Set clock
- Prepare Hard Drive(s)
- You can autoprepare if you wish, this is what I did on my 500GB drive:
- Manually Partition
100GB /
398GB /home
2GB /swap
- Manually configure block devices
- UUID is king
- /dev/sda1 - xfs - /
- /dev/sda2 - xfs - /home
- /dev/sda3 = swap
- Ignore /boot missing error
- Select Packages
- asterisk base & base-devel
- openssh
- sudo
- Configure (change hostname & stuff)
- Install bootloader
- Configure menu.lst & add "nomodeset" to the end of the kernel lines
- Something like this: kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/15734824-7189-44e5-ac82-81b4215144f6 ro nomodeset

- Reboot

5) Insert MAC OS X disk (hold alt & boot)
- Utilities > Terminal:
- bless –device /dev/disk0 –setBoot –legacy –verbose (where /dev/disk0 is where I installed grub [I've heard there can be issues with installing grub on the root of the disk, but I've had no problems so far])

6) boot & do some configging:
- pacman -S xorg
- lspci | grep VGA (http://wiki.archlinux.org/index.php/MacBook#Xorg)
- I have ATI drivers:
- I chose catalyst drivers over xf86-video-ati/radeonhd since they worked well, and were a breeze to install through yaourt:
- yaourt -S catalyst (or you can manually do everything [start here: http://aur.archlinux.org/packages.php?K=catalyst] )
- I got hung up with my ~/.xinitrc & it was causing problems, yet after removing it I was able to start twm with no issues

Here is my xorg.conf just in case anyone is interested:

Section "ServerLayout"
 Identifier     "Xorg Configured"
 Screen      0  "aticonfig-Screen[0]-0" 0 0
 InputDevice    "Keyboard0" "CoreKeyboard"
 InputDevice    "USB Mouse" "CorePointer"
EndSection

Section "Files"

# Additional fonts: Locale, Gimp, TTF...
#    FontPath     "/usr/share/lib/X11/fonts/latin2/75dpi"
#    FontPath     "/usr/share/lib/X11/fonts/latin2/100dpi"
# True type and type1 fonts are also handled via xftlib, see /etc/X11/XftConfig!
 ModulePath   "/usr/lib/xorg/modules"
 FontPath     "/usr/share/fonts/misc:unscaled"
 FontPath     "/usr/share/fonts/misc"
 FontPath     "/usr/share/fonts/75dpi:unscaled"
 FontPath     "/usr/share/fonts/75dpi"
 FontPath     "/usr/share/fonts/100dpi:unscaled"
 FontPath     "/usr/share/fonts/100dpi"
 FontPath     "/usr/share/fonts/PEX"
 FontPath     "/usr/share/fonts/cyrillic"
 FontPath     "/usr/share/fonts/Type1"
 FontPath     "/usr/share/fonts/ttf/western"
 FontPath     "/usr/share/fonts/ttf/decoratives"
 FontPath     "/usr/share/fonts/truetype"
 FontPath     "/usr/share/fonts/truetype/openoffice"
 FontPath     "/usr/share/fonts/truetype/ttf-bitstream-vera"
 FontPath     "/usr/share/fonts/latex-ttf-fonts"
 FontPath     "/usr/share/fonts/defoma/CID"
 FontPath     "/usr/share/fonts/defoma/TrueType"
EndSection

Section "Module"
 Load  "ddc"  # ddc probing of monitor
 Load  "dbe"
 Load  "dri"
 Load  "extmod"
 Load  "glx"
 Load  "bitmap" # bitmap-fonts
 Load  "type1"
 Load  "freetype"
 Load  "record"
EndSection

Section "ServerFlags"
 Option        "AllowMouseOpenFail" "true"
 Option        "AutoAddDevices" "False"
EndSection

Section "InputDevice"
 Identifier  "Keyboard0"
 Driver      "keyboard"
 Option        "CoreKeyboard"
 Option        "XkbRules" "xorg"
 Option        "XkbModel" "pc105"
 Option        "XkbLayout" "us"
 Option        "XkbVariant" ""
EndSection

Section "InputDevice"
 Identifier  "USB Mouse"
 Driver      "mouse"
 Option        "Device" "/dev/input/mice"
 Option        "SendCoreEvents" "true"
 Option        "Protocol" "IMPS/2"
 Option        "ZAxisMapping" "4 5"
 Option        "Buttons" "5"
EndSection

Section "Monitor"
 Identifier   "aticonfig-Monitor[0]-0"
 Option        "VendorName" "ATI Proprietary Driver"
 Option        "ModelName" "Generic Autodetecting Monitor"
 Option        "DPMS" "true"
EndSection

Section "Device"
 Identifier  "aticonfig-Device[0]-0"
 Driver      "fglrx"
 BusID       "PCI:1:0:0"
EndSection

Section "Screen"
 Identifier "aticonfig-Screen[0]-0"
 Device     "aticonfig-Device[0]-0"
 Monitor    "aticonfig-Monitor[0]-0"
 DefaultDepth     24
 SubSection "Display"
 Viewport   0 0
 Depth     24
 Modes    "1920x1200"
 EndSubSection
EndSection

Section "DRI"
 Mode         0666
EndSection

After I got X installed I went on to install dwm (my window manager of choice), and synergy so that I don’t have to use another keyboard/mouse. This is a minimalistic rundown of what I had to do to get things working, and well things work. Please let me know if you’re having problems, since I hit a few hitches along the way, most were very easy to solve, otherwise I would have added them in.

——

Sources:
- http://www.rodsbooks.com/gdisk/wipegpt.html
- http://mac.linux.be/content/single-boot-linux-without-delay
- http://wiki.archlinux.org/index.php/ATI
- http://wiki.archlinux.org/index.php/MacBook

Set Mac OS X background (wallpaper) via cli

Written by
September 6th, 2010

This was a hard one to figure out. I first tried a method outlined here http://thingsthatwork.net/index.php/2008/02/07/fun-with-os-x-defaults-and-launchd, and that didn’t work to well & you had to kill the Dock every time you set a background.

Well after much digging through google I found out that you can use osascript to set your background. I wrote a little osascript, and low and behold a way to change my background via cli:


osascript -e "tell application "System Events" to set picture of every desktop to "<path>/image.jpg""