This document describes how I set up my development environment with a fresh install of Xubuntu 16.04 (Xubuntu is Ubuntu with xfce).
Currently this document describes how to set up:
- Generic desktop environment with all the goodies (themes, keyboard, utilities).
- Python 2 & 3 development with PyCharm.
If you're using another distro (such as CentOS) or a newer version of Xubuntu,
most of this setup still works/applies. If you're not using the XFCE window
manager (standard Ubuntu, CentOS, etc.), the Theme, Keyboard, and Taskbar
sections will not apply. Specific directories may be different depending on
your distro and apt
commands need to be translated into your distro's package
manager equivalents (yum
for CentOS).
This will change you shell to zsh and add magic. See https://ohmyz.sh for more info.
sudo apt-get install -y zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Install arc theme.
Best to build and install locally.v
https://github.com/horst3180/arc-theme
Icons:
https://github.com/horst3180/arc-icon-theme
edit sudo vim /usr/share/icons/Arc/theme.index
Add elementary-xfce-dark to Inherits.
[Icon Theme]
Name=Arc
Inherits=elementary-xfce-dark,Moka,Adwaita,gnome,hicolor
Comment=Arc Icon theme
Then build the icon cache
sudo gtk-update-icon-cache /usr/share/icons/Arc/
Turn the theme on
- Settings > Apperance. Select Arc-Dark Style and Arc Icons.
- Settings > Window Manager. Style, select Arc-Dark.
Done
Install superkey https://github.com/hanschen/ksuperkey
Build locally. This makes it so pressing the windows key triggers Alt+F1
instead, but still allows windows+foo
key shortcuts.
Open "Session and Startup" and add ksuperkey to it.
Open Keyboard, and configure these key-combos:
(exists) xfce4-popup-whiskermenu Alt+F1 (which should now be windows key)
(exists) xfce4-appfinder Windows+Space
(exists) exo-open --launch FileManager Windows+e
xfce4-terminal --dropdown Ctrl+`
If not installed (can't remember if it comes by default), install
xfce4-screenshooter-plugin
.
Keyboard shortcuts:
xfce4-screenshooter -r
:Shift+Alt+$
(shift alt 4)xfce4-screenshooter -r -c
:Shift+Ctrl+Alt+$
(region straight to clipboard)
Right click task bar and select panel > preferences.
Create a new panel & drag it to the top left of the other monitor.
- Display Tab
Lock Panel: true
RowSize: 24
Length: 100%
- Apperance Tab
Alpha: 80%
- Items
Whisker Menu
Window buttons
Show flat buttons: true
Show windows from all monitors: false (set this on Panel 0 too)
Separator
Transparent & expand
Indicator Plugin
Separator
Workspace Switcher
Clock
Custom format: %d %b, %H:%M
Some of these are included already but I can't remember. It doesn't hurt to try to install them again, they will be skipped.
sudo apt-get install -y wget curl vim
git-all
provides gitk and other bail out programs. If you don't want the
bloat, just install git
.
sudo apt-get install git-all
Configure your username by running these commands.
git config --global user.name "John Smith"
git config --global user.email "[email protected]"
Configure a default editor to use for commit messages and interactive rebases.
I like vim
, but you can use nano
, gedit
, or whatever as long as you can
start it from a terminal.
git config --global core.editor vim
I set my default push to current
so I only push the current branch to remote
with the same name. This seems the most sane option IMO and requires the least
amount of configuration. Other options exist:
nothing
: do not push anythingmatching
: (THIS IS SUPER DANGEROUS DO NOT USE IT) push all matching branches. All branches having the same name in both ends are considered to be matching. This is the default in Git 1.x.upstream
: push the current branch to its upstream branch (tracking is a deprecated synonym for upstream)current
: push the current branch to a branch of the same namesimple
: (new in Git 1.7.11) like upstream, but refuses to push if the upstream branch's name is different from the local one
git config --global push.default current
With current
as your push strategy, you can simply git push -u
when you
create a new branch and you don't have to use the --set-upstream
option
separately.
A global git ignore is a .git_ignore
file that you will inherently use in any
git repo. The purpose is to ignore files generated by your operating system and
common files you make that you don't want to commit (virtual environments for
example).
git config --global core.excludesfile=~/.gitignore_global
Here's what's in my global ignore on my Mac:
*~
.DS_Store
._.DS_Store
.idea/
venv/
venv3/
.vagrant
.vscode/
__pycache__
Here's some samples for Linux, Mac, and Windows. Explore that repository for more examples.
Some additional settings I have that you may want to use. Research what they do before blindly applying them.
core.ignorecase=false
color.diff.whitespace=red reverse
alias.aa=commit -a --amend
Check ~/.ssh
for any keys that may exist. If you have no keys, generate them
now.
ssh-keygen -t rsa -b 4096
- Use the default location of
~/.ssh/id_rsa
. - If your drive is encrypted you may use an empty password. But be aware that anyone can impersonate you if they get a hold of your keys.
Upload your id_rsa.pub
key to gitlab so you can access git.
NEVER NEVER NEVER share your id_rsa
file, only the .pub
file can be
publicly shown. If ever asked for your key, you send the .pub
file.
NOBODY needs your id_rsa
file, that is your private key.
I use ack
instead of grep
. It's faster and eaiser to use.
sudo apt-get install -y ack-grep
ack --create-ackrc > ~/.ackrc
Add the following to the Python section of ~/.ackrc
(these are probably good to add to your global git ignore too)
--ignore-directory=is:venv
--ignore-directory=is:venv2
--ignore-directory=is:venv3
--ignore-directory=is:.tox
Lets you pipe to and from clipboard
sudo apt-get install -y xclip
Then in your .zshrc
or .bashrc
(depending on what shell you use)
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
Clipboard manager
NOTE:
I have had bad luck with ClipIt as of late and cannot get it to grab the
clipboard properly. My current solution is to use Diodon
.
sudo apt-get install -y clipit
Settings:
Use Copy: true
Use Primary: false
Sync clipboard: false
Automatically paste selected item: true
Show Indexes in history menu: true
Save URIs: true
Capture hyperlinks only: false
Confirm before cleaning history: true
Hotkeys:
History hotkey: CTRL+ALT+V
Clipboard manager
sudo apt-get install diodon
You may not need this, try inserting a CD first!
Removable devices should automount by default, but if CDs aren't automounting
and you can't be troubled to use the mount
command, add these lines to
/etc/fstab
. You may have to modify the devices and mount points.
/dev/sr0 /media/cdrom0 udf,iso9660 ro,users,auto,exec,nofail,utf8,x-systemd.automount,x-systemd.device-timeout=2 0 0
/dev/sr1 /media/cdrom1 udf,iso9660 ro,users,auto,exec,nofail,utf8,x-systemd.automount,x-systemd.device-timeout=2 0 0
It's the x-systemd.*
options that do it. You could also use udev
for this.
After applying, in lieu of restarting, run:
sudo systemctl daemon-reload && sudo systemctl restart local-fs.target
Python 2 should be installed. Python 3 might be installed, but for sure we need to install pip for both.
sudo apt-get install -y python3 python3-pip python-pip
sudo pip2 install virtualenv
sudo pip3 install virtualenv
Install PyCharm community edition from
https://www.jetbrains.com/pycharm/download/
This should auto bundle openjdk but if it fails to run because Java is missing,
install default-openjdk
with apt.
Pycharm will download as a zip (boo). I'd suggest putting it in /opt/
or at
worst in your home directory, but you can store it anywhere (except tmp).
Now add a desktop entry so you can easily start PyCharm with your start menu.
Barf the following into ~/.local/share/applications/pycharm.desktop
. Create
any directories as needed.
[Desktop Entry]
Name=PyCharm
Exec=/opt/pycharm-community/bin/pycharm.sh
Icon=/opt/pycharm-community/bin/pycharm.png
Type=Application
Categories=Development;IDE;
Now you can run pycharm like a regular program.
Pycharm can be launched with the charm
command, but they goofed and it runs
in the current shell.
It is possible this has been fixed in current releases.
This fixes it:
sudo vim /usr/local/bin/charm
Twoards the bottom, change (the os.execv line to os.spawnv):
def start_new_instance(args):
if sys.platform == 'darwin':
if len(args) > 0:
args.insert(0, '--args')
os.execvp('open', ['-a', RUN_PATH] + args)
else:
bin_file = os.path.split(RUN_PATH)[1]
os.execv(RUN_PATH, [bin_file] + args)
def start_new_instance(args):
if sys.platform == 'darwin':
if len(args) > 0:
args.insert(0, '--args')
os.execvp('open', ['-a', RUN_PATH] + args)
else:
bin_file = os.path.split(RUN_PATH)[1]
#os.execv(RUN_PATH, [bin_file] + args)
os.spawnv(os.P_NOWAIT, RUN_PATH, [bin_file] + args)
If you can't create key combinations with the Windows key (eg. windows + left):
Help –> Edit Custom Properties... –> keymap.windows.as.meta=true
(This is suggested, this is what I like, but is based on OS X bindings)
-
Editor Actions > Delete Line =
Alt+Backspace
-
Editor Actions > Clone Caret Above =
Ctrl+Shift+Up
-
Editor Actions > Clone Caret Below =
Ctrl+Shift+Down
-
Editor Actions > Move Caret to Line End =
Alt+Right
-
Editor Actions > Move Caret to Line End with Selection =
Alt+Shift+Right
-
Editor Actions > Move Caret to Line Start =
Alt+Left
-
Editor Actions > Move Caret to Line Start with Selection =
Alt+Shift+Left
-
Editor Actions > Move Caret to Previous Word =
Windows+Left
-
Editor Actions > Move Caret to Previous Word with Selection =
Windows+Shift+Left
-
Editor Actions > Move Caret to Next Word =
Windows+Right
-
Editor Actions > Move Caret to Next Word with Selection =
Windows+Shift+Right
-
Main menu > Navigate > File... =
Ctrl+P
-
Main menu > Window > Editor Tabs > Close =
Ctrl+W
-
Main menu > File > New Scratch File =
Alt+Shift+N
-
Plug-ins > Wrap to column > Wrap Line to Column =
Windows+W
-
Plug-ins > Wrap to column > Wrap Paragraph to Column =
Windows+Q
Install as you'd expect.
Here's a list of plugins I use:
To install manually, open extensions, click the ...
menu >
Install from VSIX...
These are my settings for VSCode. You don't have to use them.
File > Preferences > Settings
Click to show/hide settings.json
{
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"files.associations": {
"Vagrantfile": "ruby",
"rules": "debian",
"*.pp": "ruby"
},
"editor.tabSize": 2,
"editor.matchBrackets": false,
"window.zoomLevel": 0,
"workbench.editor.enablePreviewFromQuickOpen": false,
"workbench.editor.enablePreview": false,
"lualinter.interpreter": "luac",
"lualinter.enable": true,
"emmet.triggerExpansionOnTab": true,
"C_Cpp.clang_format_fallbackStyle": "Google",
"editor.rulers": [
79,
99,
119
],
"workbench.startupEditor": "newUntitledFile",
"search.useRipgrep": false,
// pip install yapf
"python.formatting.provider": "yapf",
"yaml.format.enable": true,
"markdown-preview-enhanced.protocolsWhiteList": "http://, https://, file://, mailto:",
"markdown-preview-enhanced.breakOnSingleNewLine": false,
"html.format.wrapLineLength": 99,
"editor.find.autoFindInSelection": true,
"[python]": {
"editor.rulers": [
72,79,99
]
}
}
These are my modified keybindings for VSCode. I'm most often on a Mac so this maps most of the keys to be similar because of muscle memory.
File > Preferences > Keyboard Shortcuts
, then click on the
keybindings.json
link.
Click to show/hide keybindings.json
[
{
"key": "alt+backspace",
"command": "editor.action.deleteLines",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "alt+right",
"command": "cursorEnd",
"when": "editorTextFocus"
},
{
"key": "shift+alt+right",
"command": "cursorEndSelect",
"when": "editorTextFocus"
},
{
"key": "alt+left",
"command": "cursorHome",
"when": "editorTextFocus"
},
{
"key": "shift+alt+left",
"command": "cursorHomeSelect",
"when": "editorTextFocus"
},
{
"key": "meta+left",
"command": "cursorWordStartLeft",
"when": "editorTextFocus"
},
{
"key": "ctrl+left",
"command": "-cursorWordStartLeft",
"when": "editorTextFocus"
},
{
"key": "shift+meta+left",
"command": "cursorWordStartLeftSelect",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+left",
"command": "-cursorWordStartLeftSelect",
"when": "editorTextFocus"
},
{
"key": "meta+right",
"command": "cursorWordEndRight",
"when": "editorTextFocus"
},
{
"key": "ctrl+right",
"command": "-cursorWordEndRight",
"when": "editorTextFocus"
},
{
"key": "shift+meta+right",
"command": "cursorWordEndRightSelect",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+right",
"command": "-cursorWordEndRightSelect",
"when": "editorTextFocus"
},
{
"key": "alt+p",
"command": "workbench.action.quickOpen"
}
]