Make Windows like Linux
Linux
I'm back to a job that only allows Windows on our laptops and desktops. Here's how I configured my workstation to be more Linux-like in order to increase my productivity:
- Install Google Chrome and Firefox
- Install an antivirus or security suite (Norton or Mcafee?); a free one is Avast
- Map my caps lock key to control; if Admin access is not available, then use AutoHotKey by creating
caps_to_control.ahkwithCapslock::Control, compiling it as an executable, and creating a shortcut in the Startup folder - Download Cygwin and install the following:
xinit(X server),python(2 and 3),gcc-*,openssh,screen,rsync,python-setuptools(easy_install)),git,subversion,xwinclipboard,procps(topcommand + others),aspell(I use flyspell in emacs),aspell-en,make,zip,unzip,patch,wget,perl,perl-dbi,libcrypt-devel(for perlDBD:ODBC),automake,autoconf,ghostscript,email(modify/etc/email/email.confand enter correct server and credential information;sendmailis not needed for sending outbound emails, only needed to send internal emails) - Install the emacs binaries to
C:\Documents and Settings\my_username\bin\emacs-ver_num(Windows XP) orC:\Users\my_username\bin\emacs-ver-num(Windows 7+) and copy relevant image library dll files into the emacsbindirectory in order for doc-view to work properly (eg, needlibpng14-14.dllfor emacs 24.3; Ghostscript (gs) is needed so install that via Cygwin)- See Vincent Goulet's emacs distro to see the list of dll files are needed (different versions of emacs uses different versions of the libraries, so use the latest version of emacs and match up the files listed on Vincent's site)
- One could also use emacs w32 provided by cygwin, but ESS doesn't seem to work because that version of emacs does not have the function
w32-short-file-namecompiled with it as needed by ESS; tentative solution can be found here, but it's probably better to use the compiled emacs binaries available on GNU
- Set the
HOMEenvironment variable toC:\Documents and Settings\my_username(Windows XP) orC:\Users\my_username(Windows 7+); setLC_ALLandLANGtoen_US.utf-8(for perl dbi error); setCYGWIN=nodosfilewarning- Within a Cygwin Terminal, create a soft link from
$HOME/.sshpath to/home/username/.ssh(sshin Cygwin uses the keys from this location)
- Within a Cygwin Terminal, create a soft link from
- Edit environment variables by running the following in the command prompt:
rundll32 sysdm.cpl,EditEnvironmentVariables. Add the following to thePATHenvironment variable:path_to_R;path_to_JRE;C:\Documents and Settings\my_username\My Documents\bin;C:\Documents and Settings\my_username\My Documents\bin\emacs-24.3\bin;C:\cygwin\bin- If Admin rights are not available, then modify the user's environment variables instead (eg,
PATHto bepath1;path2;%PATH%) - If the settings aren't saved for future sessions (eg, in Citrix), then create a symbolic link from
/home/user_idto the desired home (eg,C:/Users/user_id), and add the following to~/.bashrc:export PATH=/cygdrive/f/R/R-3.1.1/bin/x64:/cygdrive/f/bin/emacs-24.3/bin:/cygdrive/f/bin:/cygdrive/f/bin/cygwin64/bin:$PATHandexport JAVA_HOME=F:/bin/jre7.
- If Admin rights are not available, then modify the user's environment variables instead (eg,
- Add the following to
~/.bash_profile:. ~/.bashrc - Add "export DISPLAY=:0.0" to
~/.bashrc - On Windows XP, fix the carriage return issue by adding the following to the beginning of
~/.bashrcand~/.bash_profile:(set -o igncr) 2>/dev/null && set -o igncr; # this comment is needed - Run
touch ~/.startxwinrcto preventxtermfrom launching whenever X server is started.- For recent version of Cygwin, run
echo "exec sleep infinity" > ~/.startxwinrcandchmod +x ~/.startxwinrc
- For recent version of Cygwin, run
- Copy
XWin Servershortcut from the Cygwin folder in the Start Menu to the Startup folder to start the X Windows Server at startup - Install CutePDF Writer (also download and install Ghostscript from CutePDF) for printing to PDF files
- Install R using the Windows installer (works with Emacs ESS)
- Install Microsoft R Open (optimized R) instead of CRAN R
- Install RStudio
- Install Anacondas (Python that is optimized; includes my usual data/analytics stack)
- Add the 3 Anacondas binary locations to
PATH; need this for emacs'elpyto work - emacs
elpydependency:pip install rope jedi flake8 importmagic autopep8 yapf
- Add the 3 Anacondas binary locations to
- Get
trampin emacs to work properly in order to visit remote servers easily in emacs by first getting the latest copy of tramp, thenconfigureand byte-compile the code (make) per the proper installation.- Add
plink,pageant, and allputty-related binaries into the PATH (~/bin). - After creating an ssh key, use the putty kegen to convert
id_rsatoid_rsa.ppk. Create a shortcut at startup that launchespageant /path/to/id_rsa.ppk. Then in emacs, one could access remote files using tramp viaplink:/plink:username@host:/path/to/dir.
- Add
- Get
sshfsto work on Windows to mount my servers - Install Dropbox and symlink my
.bashrcand.screenrcfiles - Python packages:
numpy,pandas,csvkit(easy_installworks butpip installdoes not),jedi,epc,pyodbc,mysqldb,pymssql,psycopg;ddlgenerator(Python 3). - R packages:
RODBC,RMySQL,RPostgreSQL,ggplot2,plyr,glmnet - Perl packages (for edbi in emacs):
cpan RPC::EPC::Service,cpan YAML,cpan -i DBD::ODBC(gcc4 error; edit Makefile and change "CC=gcc4" to "gcc"; "LD=g++") - Set up ssh server via Cygwin and open up port 22 in Windows Firewall; freeSSHd is also an alternative
- On Windows 8, the user might not be able to change group permissions (eg, can't ssh using keys because the key is "too open"); fix by changing files/directories group to 'User'
- Use Autopatcher to install download all necessary updates and install them all at once
- Have the following shortcut in the startup folder in order to have a a terminal open up at startup with
screeninitiated:C:\cygwin\bin\mintty.exe -e screen -s bash; in the shortcut, specify the home directory as the 'Start In' path - Install UniKey for typing in Vietnamese (place in
~/Documents/bin), 7-Zip for handling archive files, and Virtual CloneDrive for handling disk image files - Install Java Runtime Environment (JRE); if admin privileges aren't available, then extract the files manually into
~/Documents/bin/jre/ - Other tools per Lifehacker: VLC, PDF-XChange, Foxit PDF Viewer
- Configure sshd using
openssh, make sure it starts at startup (Start > Run > Services; look forCYGWIN sshd), and allow/usr/sbin/sshdto pass through the Firewall; one could alternatively use freeSSHd - Bash shell in emacs via
shell: add(setq shell-file-name "bash")
and (setq explicit-shell-file-name shell-file-name) to the emacs init file, and add the following to ~/.bashrc:
# http://stackoverflow.com/questions/9670209/cygwin-bash-does-not-display-correctly-in-emacs-shell
if [ "$EMACS" == "t" -a "$OSTYPE" == "cygwin" ]; then
PS1='\u@\h \w\n$ '
fi
If Dropbox cannot be installed then symlink my ~/.emacs.d directory (need to use mklink in order for symlink to work properly).
If the computer is a dual-boot with Linux installed first, then one can change the order of the bootloader to Windows by following these instructions.
This is a good post to review.