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.ahk
withCapslock::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
(top
command + 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.conf
and enter correct server and credential information;sendmail
is 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 emacsbin
directory in order for doc-view to work properly (eg, needlibpng14-14.dll
for 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-name
compiled 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
HOME
environment variable toC:\Documents and Settings\my_username
(Windows XP) orC:\Users\my_username
(Windows 7+); setLC_ALL
andLANG
toen_US.utf-8
(for perl dbi error); setCYGWIN=nodosfilewarning
- Within a Cygwin Terminal, create a soft link from
$HOME/.ssh
path to/home/username/.ssh
(ssh
in 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 thePATH
environment 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,
PATH
to bepath1;path2;%PATH%
) - If the settings aren't saved for future sessions (eg, in Citrix), then create a symbolic link from
/home/user_id
to 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:$PATH
andexport 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
~/.bashrc
and~/.bash_profile
:(set -o igncr) 2>/dev/null && set -o igncr; # this comment is needed
- Run
touch ~/.startxwinrc
to preventxterm
from launching whenever X server is started.- For recent version of Cygwin, run
echo "exec sleep infinity" > ~/.startxwinrc
andchmod +x ~/.startxwinrc
- For recent version of Cygwin, run
- Copy
XWin Server
shortcut 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'elpy
to work - emacs
elpy
dependency:pip install rope jedi flake8 importmagic autopep8 yapf
- Add the 3 Anacondas binary locations to
- Get
tramp
in emacs to work properly in order to visit remote servers easily in emacs by first getting the latest copy of tramp, thenconfigure
and 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_rsa
toid_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
sshfs
to work on Windows to mount my servers - Install Dropbox and symlink my
.bashrc
and.screenrc
files - Python packages:
numpy
,pandas
,csvkit
(easy_install
works butpip install
does 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
screen
initiated: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/sshd
to 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.