Windows is really horrible system for developers and especially for devops. It doesn’t even have a usable terminal and shell, so working with command line is really pain in the ass. If you really don’t want to switch to any usable system (OS X, Linux, BSD…), then this guide should help you to setup somewhat reasonable environment – usable terminal, proper shell, ssh client, git and Sublime Text as a default editor for shell.
- Download and install Git for Windows* with:
- [✘] Use Git from the Windows Command Prompt
- [✘] Checkout as-is, commit Unix-style line endings
- Download ConEmu Installer (stable or preview) and install x86 (32bit**) version.
- Download and install Sublime Text 3 – text editor for real coders. ;)
- If you’re using 64bit Windows, then download the 64bit version. If you don’t know what the heck this means, just pick the 32bit version.
* Wait a moment… why Git? Well, every developer needs a Version Control System and git is the best one! However, the main reason is that “Git for Windows” is not just a git, it’s a bundle of some basic “unix utilities” – the easiest way to install it on Windows.
** Why 32bit version when you’re maybe running 64bit Windows? Well, just because I didn’t want to test this guide twice, or risk that something will be different on 64bit version and people start to complain…
- Start ConEmu (press Win key, write ConEmu and hit enter), the fast configuration screen should appear on the first launch, just click on OK.
- Open Settings (Win+Alt+P) and set:
- Startup:
- [✘] Specified named task:
{Bash::Git bash}
- [✘] Specified named task:
- Startup/Environment:
-
Copy these lines to the text box:
set LANG=en_GB.UTF-8 set LC_ALL=en_GB.UTF-8
-
- Main:
- [✘] Clear Type
- Main/Confirm:
- [_] Confirm creating new console/tab (Win+W, toolbar [+])
- [_] Confirm tab closing
- Main/Update:
- [✘] Check on startup
- [✘] Stable (or Preview)
- Startup:
- Restart ConEmu.
- Generate SSH key, if you don’t have one yet:
ssh-keygen
(copy&paste to terminal and hit enter)- Use default key file location.
- Enter some password to protect your SSH key! You’ll be prompted to enter this password after opening terminal, but just once per Windows session (i.e. only after Windows reboot).
- Enable SSH Agent Forwarding in
.ssh/config
:cd; echo 'ForwardAgent yes' >> .ssh/config
(copy&paste to terminal and hit enter)
- Download preconfigured
.bashrc
:cd; curl https://gist.githubusercontent.com/jirutka/99d57c82fa8981f56fb5/raw/.bashrc > .bashrc
(copy&paste to terminal and hit enter)
- Restart ConEmu.
Just some basic shortcuts and commands for a decent productivity.
- Open new tab:
Win+W
- Close the tab:
Win+Del
- Switch to next tab:
Win+Alt+Arrow right
- Switch to previous tab:
Win+Alt+Arrow left
- Cycle tabs:
Ctr+Tab
- Copy text from console to the system clipboard:
- Press and hold
Shift
, use arrows to make a selection and then hitCtrl+C
. - Press and hold left mouse button, make a selection and release the button.
- Press and hold
- Paste text from the system clipboard to console:
- Press
Ctrl+V
to paste the first line from the clipboard, orShift+Insert
to paste all the clipboard content (use with caution!) - Press right mouse button to paste all the clipboard content.
- Press
Alternative keys in parenthesis are environment-specific (works in ConEmu).
- Autocomplete file/directory name:
- Type first few characters of the file/directory name and then hit
Tab
.
- Type first few characters of the file/directory name and then hit
- Scroll your command history:
Arrow up
andArrow down
- Search your commands history backwards:
- Press
Ctrl+R
, start typing what you’re looking for; hitCtrl+R
again and again to scroll through history.
- Press
- Move cursor to the beginning of the line:
Ctrl+A
(orHome
)
- Move cursor to the end of the line:
Ctrl+E
(orEnd
)
- Move cursor back (left) one word:
Alt+B
- Move cursor forward (right) one word:
Alt+F
- Remove one word before the cursor:
Ctrl+W
(orAlt+Backspace
)
- List content of the current directory:
ls
(orll
)
- Go up one directory:
cd ..
(or..
)
- Go to a subdirectory:
cd DIRECTORY
- Go to the home directory:
cd
- Connect to a remote machine as specified user using SSH:
ssh REMOTE-USER@SERVER-DOMAIN
- Open file in the default text editor (Sublime Text 3 if you’ve installed it) *:
edit FILE
- Copy content of a file to system clipboard (then you can paste it using
Ctrl+V
) *:cat FILE > clip
* This will work only on your local computer, not on a remote server via SSH!
Awesome. Thanks a lot.