yasunori.xyz

Yasunori Toshimitsu | 利光泰徳

HOME / BLOG / My Programming Envir...


My Programming Environment Setup

2021年05月05日

Due to popular demand (?) at my lab in ETH Zürich, I will describe the tips & tricks for when I set up programming environements on my computer. Feel free to steal the ones you find useful. Suggestions and ideas are always welcome!

29.10.2021: updated with new entries like GitHub Copilot (this is a potential game-changer for coders) and Ubuntu-specific UI customizations.

enable autocomplete (and fancy themes) on your command shell

The command shell is what runs on your terminal to let you interact with the computer. For example, ls, cd, etc are all bash commands. By the end of this section, you will have

Zsh is an improved version (*citation needed) of the bash shell. Change from bash to zsh (for macOS zsh is already the default shell), for Ubuntu…

sudo apt install zsh
chsh -s $(which zsh)

Next, install Oh My Zsh, which among other things lets you use plugins and themes on the zsh shell. Installation can be done by

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Also install zsh-autosuggestions for the autocomplete feature.

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Edit ~/.zshrc and add the plugin to the corresponding line for example if you already have the git plugin it would look like

plugins=(git zsh-autosuggestions)

And now you have autocomplete features in the terminal! Use the arrow keys to autocomplete the entire line, or alt + f to autocomplete each word.

For the theme, I prefer powerlevel10k, though this is just a personal preference.

This is available from the start in bash and zsh and many other text input interfaces like the Python interpreter. Just press ctrl + r, and start typing to start searching your past commands. When the command that you want shows up, just press enter to execute that line.

move cursor one word at a time

This is the same for bash and zsh, and probably any other terminal emulator. use alt-f to go forward, and alt-b to go back one word at a time. This is also the emacs keybind for the same movements.

show multiple panes in a single terminal window

sudo apt install terminator

and use it as your terminal emulator. Use ctrl-shift-o and ctrl-shift-e to split panes.

if you want to do it over SSH: tmux

sudo apt install tmux

I recommend updating the default keybind / settings with something like this .tmux.conf- save it to ~/.tmux.conf

With the above configuration file, enter tmux with the command tmux and, press ctrl-t and

VSCode

use GitHub Copilot

This gives you AI-powered suggestions while you code, which you can choose to use by pressing tab. I really cannot stress how much more efficient this makes you at writing code, especially for writing menial code that are similar across different projects (e.g. initial setup of OpenCV windows). It works for many programming languages, even plain text; you can actually have a nice conversation with it, as I demonstrate in this video.

Sometimes it’s creepy how accurately it can guess my intensions when I code. However, there are just as many instances where it suggests completely off-the-mark code. Use with a healthy dose of caution.

It’s still in technical preview, so you’ll have to enroll in it on their website.

when doing CMake projects

If you are opening a project with a CMakeLists.txt file in the top directory, you can set up VSCode to compile your programs from GUI.

Install the cmake extension, ctrl + shift + p (the shortcut for VSCode commands) and select “CMake: Configure”. Then select compiler, probably gcc **.**.**.

Select the CMake icon in the sidebar, and it should have a list of all the executables and libraries in the project. Right-click and you can “build”, “run”, “debug”, etc.

sync your settings

Press ctrl + shift + p to enter the VSCode command terminal, and enable settings sync. It’s so much easier to use multiple computers when you can use your editor configured exactly the same way on all your devices.

Vim

Use the Vim extension for VSCode. It will let you do a lot of things, like moving the cursor or switching between files, without ever having to touch the mouse. If you will code anything over 100 lines, I recommend picking up these commands, as once you master them it will definitely let you code much faster and efficiently.

However there is somewhat of a steep learning curve to be able to use Vim, so you could run the vimtutor command for a tutorial, or try out this pretty cool RPG-style vim tutorial online.

Or use Emacs, that’s totally cool as well.

use jj to enter insert mode

I recommend setting it up so you can switch to insert mode with jj instead of the ESC key which can be hard to press.

bonus stuff

find a cool wallpaper

This site has basically every single macOS wallpaper that there has ever been.

get a cooler icon set (for Ubuntu)

Install papirus-icon-theme

sudo apt-get install papirus-icon-theme

If package is not found (probably for older Ubuntu versions), add PPA:

sudo add-apt-repository ppa:papirus/papirus
sudo apt-get update

To enable these icons, install GNOME Tweaks from the Software application and in Appearance→Themes→Icons, select Papirus.

automatically hide the dock (side / bottom panel) on Ubuntu

The dock takes up quite a bit of space even though it’s not used that much. I recommend setting it to automatically hide, and disabling non-panel mode for a cleaner look. It’s still accessible with either the Windows key or by bringing your mouse close to it. (screenshot is from Ubuntu 22.04)


New posts


Postmortem for the Real Robot Challenge
2022.12/06
【2/2】 Setting up a VPN server on Windows and connecting from iPhone without changing router settings: Client Settings & Setup & Management Tips
2022.04/05
【1/2】Setting up a VPN Server on Windows and Connecting from iPhone without Changing Router Settings: Overview & Server Settings
2022.04/04
My Programming Environment Setup
2021.05/05

more...