I use a portable, flash drive, Cygwin installation for all my day to day network administering needs. In addition to all the other miscellanious tools spread throughout my website there are a handful of Cygwin specific tweaks and utilities I have made.
I have two batch files: start_environment.bat and start_environment_readonly.bat The _readonly.bat file does not magically make Cygwin readonly - the hardware switch on my thumb drive does that. The _readonly.bat is the same as the other .bat it just doesn't try to make modifications when it starts up. It is very much worth noting that I am *not* the original author of those batch files - I started with somebody elses and built from there. I have however lost the link and cannot credit them.
For convenience, I have a utility called "wherever.exe". Wherever loops through your Windows drive letters in reverse order (that is, Z: to A: and looks for whatever argument you have specified. If it finds it, it runs it. This lets me have a shortcut on my desktop that runs "wherever start_environment.bat" that will start up my thumb drive regardless of what letter may have been assigned.
Once Cygwin starts up, I have some aliases and whatnot in my .bashrc file:
# cygwin ping needs to be admin, so lets avoid it alias ping='echo Redirecting to Windows ping via alias:;/cygdrive/c/Windows/System32/ping' alias tracert='echo Redirecting to Windows ping via alias:;/cygdrive/c/Windows/System32/tracert' alias addwinpath='PATH=/cygdrive/c/Windows/System32/:$PATH'
I have my utilities in a top level folder on the thumbdrive called "Programs" so that they are easily usable from the windows side as well. For Cygwin, I have .bashrc find the drive and mount it as .bin. I do the same for my top level Documents and Backups folders as well.
# find my programs directory cd /cygdrive for d in *; do if [ -d "$d/Programs" ]; then PATH=$PATH:/cygdrive/$d/Programs PATH=$PATH:/cygdrive/$d/Programs/SublimeText PATH=$PATH:/cygdrive/$d/Programs/PuTTYPortable PATH=$PATH:/cygdrive/$d/Programs/WinSCPPortable ln -f -s /cygdrive/$d/Documents ~/Documents ln -f -s /cygdrive/$d/Programs ~/.bin ln -f -s /cygdrive/$d/Backups ~/Backups fi done
I don't mount my paths to Desktop or Dropbox automatically, as Cygwin sometimes sticks immovable files there. Not sure why.(Edit: figured out why. I was neglecting to use the -T option with ln. Error in Eli, not in Cygwin.) I find the path to my windows profile using a utility I wrote called "DesktopPath.exe" since the windows profile location isn't predictable:
alias Desktop='cd `DesktopPath.exe --cygwin`' alias linkDesktop='ln -f -s $desktoppath ~/Desktop' alias linkDropbox='ln -f -s $desktoppath/../Dropbox ~/Dropbox'
Couple other aliases so I'm not dependent on $PATH
alias powershell='/cygdrive/c/Windows/system32/WindowsPowerShell/v1.0/powershell.exe' alias cmd='/cygdrive/c/Windows/system32/cmd.exe' alias ipconfig='/cygdrive/c/Windows/System32/ipconfig.exe' alias adapters="cmd /C ncpa.cpl";
Instant ssh socks proxy server. This uses "proxy.exe" and predefinition of the .ssh stuff in .ssh/config
alias socks='proxy set example-socks && ssh example-socks'
Some other miscellanious aliases and settings...
alias ls='ls -hF --color' alias h='history | grep $1' export HISTFILESIZE=30000000 # save 300000 commands export HISTCONTROL=ignoredups # no duplicate lines in the history. export HISTSIZE=10000000 shopt -s histappend #No clobbering alias rm="rm -i" alias cp="cp -i" alias mv="mv -i" #Lazy alias newxhtml="cp ~/.var/skel/xhtml.skel" alias newpy="cp ~/.var/skel/py.skel" alias clear='printf "\033c"' alias reload='source ~/.bashrc'
In order to have ssh-agent function properly, I have two scripts - startagent and checkagent
# Ok - we don't want to be harrassed every time we start up if agent isn't running, so just a reminder and a start it manually. # checkagent *should* fix the pid correctly in each new window. Maybe. alias startagent=". ~/.bin/startagent.sh" ~/.bin/checkagent
Finally, its important to always know where you are:
echo echo -e "\033[44m \033[40m" echo -e "\033[44m YOU ARE USING THE BLUE THUMB DRIVE \033[40m" echo -e "\033[44m \033[40m"
... and whether or not you've run your backup lately:
# if test `find "~/.var/personal_backup_last_run" --mmin +10080` if [ "$(( $(date +"%s") - $(stat -c "%Y" ~/.var/personal_backup_last_run) ))" -gt "604800" ]; then echo echo -e "\033[41m \033[40m" echo -e "\033[41m Personal Backup > 1 week old, you should run it. \033[40m" echo -e "\033[41m \033[40m" fi
Inside of .bin I have (more or less) all my utilities, but specifically for Cygwin purposes I have:
I keep a top level directory called "cygwin-maintenance" on the thumb drive to run the installer from. At the time of this writing, my installed packages (via cygcheck -c) are these.