Inside Out

Notes on seeking wisdom and crafting software

My USB stick setup

Some notes on setting a portable development environment in a USB stick. Ah well, let me start from the end. Here’s how my setup looks like currently :)

[![Portable Development Enviroment Setup]( "Portable Development Enviroment Setup")](

Directory structure in the device ---------------------------------

\\Documents -- Place for all documents, ebooks, todo.txt etc..

\Documents\{Music, Videos, Pictures}

\\Env -- Place for Languages, CoreOS utils, Development enviroment

\Env\{Python26, Ruby191}

\Env\{CygWin, GnuWin32}

\Env\Bin                      — Homegrown scripts and utilities go here (mostly small .ps1 and .py files). We add this path to $env:PATH.

\Env\Path                   — Interesting external tools. E.g. ProcExp, Reflector etc.. We add this path to $env:PATH.

\Env\Env.ps1            — This file is sourced into powershell. Sets up paths. Source below.

\Env\Profile.ps1      — Setups some powershell customizations. See below.

\\PortableApps -- All other utilities etc. go here. suite builds up a Menu from this folder. Cool stuff.

\PortableApps\{7zipPortable, gVimPortable, Console}

\PortableApps\{Git, PuttyPortable, WinSCPPortable}


Softwares for the USB stick ---------------------------

Install Portable Apps Platform ([download]( | for the brave souls, beta version is [here](

### Languages

- Python portable ([download](

### Editors/Shells

- GVim Portable ([download]( -- doesn't have Python + Ruby. Install this and the play the [replace magic]( ;) - CygWin Portable ([how to]( - Console (download latest \*\ from [here]( ConsolePortable from includes extra stuff which I don't use. - Customized Powershell. See below.

### Source control

- MSysGit - Portable git installation ([download]( PortableGit\*.7z file)

### Utilities

- 7zip portable - Archive/Extract files ([download]( - MRemoteNG - Manages your remote desktop connections ([download]( - Putty - Telnet, SSH client ([download]( - WinSCP Portable ([download](

Customized Powershell in Stick ------------------------------

Following modification requires powershell to be installed in the host machine. Comes by default with Windows 7. For other windows versions download [here]( Take my word, you will enjoy every minute w/ Powershell :)

Our goal here is:

- Hook up powershell with Console - Setup Python and GIT paths appropriately

### Modify \\PortableApps\\Console\\Console.xml to start Powershell at start

### Contents of \\Env\\Env.ps1

## Portable start script## Created: Sat 15 Jan 2011 01:45:57 PM India Standard Time## Last Modified: Sat 15 Jan 2011 02:51:52 PM India Standard TimeWrite-Host -ForegroundColor Green "--> Setup start"Write-Host -ForegroundColor Green "--> Setting enviroment variables"## Globals# Environment variables$env:PortableRoot = $(pwd).Drive.Root$env:PortableEnv = Join-Path $(pwd).Drive.Root "Env"$env:PortableApps = Join-Path $(pwd).Drive.Root "PortableApps"$env:PortableDocs = Join-Path $(pwd).Drive.Root "Documents"$env:TERM = 'cygwin'$env:LESS = 'FRSX'Write-Host -ForegroundColor Green " > Portable Root: $env:PortableRoot"Write-Host -ForegroundColor Green " > Portable Env: $env:PortableEnv"Write-Host -ForegroundColor Green " > Portable Apps: $env:PortableApps"Write-Host -ForegroundColor Green " > Portable Docs: $env:PortableDocs"# Languages$env:PATH = "$env:PortableEnv\Python26\App;$env:PortableEnv\Python26\App\Scripts;" + $env:PATH# GIT$env:PLINK_PROTOCOL = "ssh"$env:GIT_INSTALL_ROOT = "$env:PortableApps\git"$env:PATH += ";$env:GIT_INSTALL_ROOT\cmd"# Load custom profile$customProfile = $(Join-Path $(Get-ChildItem $MyInvocation.MyCommand.Path).Directory.FullName "\Profile.ps1")if (Test-Path $customProfile){ Write-Host -ForegroundColor Green "--> Loading custom profile: "$customProfile . $customProfile}Write-Host -ForegroundColor Green "--> Setup complete`r`n"

### Contents of \\Env\\Profile.ps1

## Portable Profile## Created: Sat 15 Jan 2011 02:15:57 PM India Standard Time## Last Modified: Sat 15 Jan 2011 03:02:54 PM India Standard Time## promptfunction prompt{ $date = $(date) $dateString = $date.Hour.ToString()+":"+$date.Minute.ToString()+":"+$date.Second.ToString() Write-Host $dateString" ["$(get-location)"]" -foregroundcolor green Write-Host $((get-history -count 1).Id+1)"$" -nonewline return " "}## Aliases#set-alias la ls -recurserm -force alias:whererm -force alias:cdset-alias cal gadget-calendarset-alias cd pushd;set-locationset-alias cd- popdset-alias grep select-stringset-alias l get-childitemset-alias whereis whereset-alias wc measure-object## Globals# Environment variables$env:Path = "$env:PortableEnv\Path;$env:PortableEnv\GnuWin32\bin;" + $env:Path$env:SCRIPTDIR = Resolve-Path("$env:PortableEnv\bin").ToString()$env:EDITOR = "gvim"# Script Directory$env:PATH += ";"+$env:SCRIPTDIR+";."## User applications# ACKfunction ack{ & $env:PortableApps\git\bin\perl.exe "$env:PortableEnv\bin\standalone-ack" $args}# YaGTDfunction gtd{ & $env:PortableEnv\Python26\App\Python.exe $env:PortableEnv\Python26\App\Scripts\ -q $args $env:PortableDocs\todo.txt}

The script \\Env\\Env.ps1 provides following environment variables for your scripting needs.

1. \$env:PortableRoot  -- Root of the USB stick 2. \$env:PortableDocs  -- Path to \\Documents 3. \$env:PortableEnv    -- Path to \\Env 4. \$env:PortableApps -- Path to \\PortableApps

Enjoy the portability.

*Down the memory lane,  last time I used usb sticks was in 2005-8. Used to be a life saver for the labs, the days before project/ppt deadlines (all kinds of file sync, backup and what not. Poor man's dropbox :D. Ok, DC++ did revolutionize things too).*

*My primary toolset then was DevC++, VNCViewer/WinSCP/Putty (escape switch for boring labs, to connect to dorm desktop :P). I was quite a bit into Java then, so Eclipse was there too. Good ol' times.*

*Well this time, primary reason was my GTD setup. More on that in another post.*