Wednesday, November 20, 2013

Sublime Text - The text editor of your dreams

I was introduced to Sublime Text last year by some friends at school.What is Sublime Text anyway? To put it simply, it is a text editor. One heck of a text editor ! You might used of have used Notepad++ in the past, Sublime Text is (in my opinion) even better.

Why do I give this editor such a reputation ? First of all, it looks awesome !




The colors are great. For people like me with eyes problem, this kind of color scheme is easy for the eyes. Also, notice the little map on the side, that little thing itself makes coding easier at some point. Sublime is not only about the GUI though. Where it begins to shine is within its functionalities. 

  1. Multiple selection: Sublime Text allows you to select a term, it could be a variable, a method name, a class name, multiple times. This will allow you to rename it everywhere in the code, all at once !
  2. Batch edit: You can modify multiple lines at once just my using multiple selection. 
  3. Syntax: Sublime adapts its colors depending on the programming language in the current file.
  4. Goto Anything: This is minor to some people but you can use Ctrl+P and type in a file name to actually reach that file immediately.
  5. Sublime Project: You can define a project file for your code and use many properties such as ignored files, build system and such.
Where Sublime Text gets really powerful is by its customization capabilities. Exploiting this makes your editor feel like a full fledge IDE. The first step is to download the Package Manager and install it. Then.. you have a universe of possibilities. You can change your colors, download source control plugins, linters, etc.  Begin my lauching the command palette (Ctrl+Shift+P) and type in "inst". You should see the option "Package Control: Install Package".

Here is my list of packages:
  • Soda Dark Theme: Change the look of my GUI to make it a little darker
  • Clouds Midnight: My color scheme
  • Alignment: This package is used to automate alignment in your code. For example, you have a series of assignment of variables in your code. It is easier to visualize if all the '=' where aligned along with the assigned values. Instead of doing it manually, Alignment does that for you.
  • Sublime ColorPicker: This package is great. With a simple keyboard shortcup, a color picker dialog pops up and when you choose a color, the RGB code is returned. Very useful for people doing CSS or WM configuration.
  • Clipboard History: Records all your Ctrl+C and allows you to view a list of everything you copied. 
  • SublimeLinter: This package is used to highlight potential errors in your code. It runs in the background but you can also ask it to show you a list of lint errors. 
  • SublimeCodeIntel: This package is my favorite. It allows you to jump to definitions (remember we are using a text editor), it has autocompletion and has function call tooltip.
All of the packages mentioned above are fully customizable using JSON configuration. They can all be installed through Package Manager !


At last, if you want a configuration hack for Sublime Text, I recommend this article: http://codethatworks.blogspot.ca/2013/02/hows-to-synchronize-sublime-text.html. It was writted by one of my ex-boss and it basically allows you to copy your Sublime Text configuration to DropBox, so everywhere you use ST, your packages will be loaded and your configurations too !


Enjoy your coding !

Friday, June 7, 2013

Minimal use of the mouse on Linux

I've said it before, I am a lazy person. But we are talking about a weird type of lazy, programmer lazy. I do a lot of stuff to save time later, it is one of my (perhaps bad) habits. Sometimes.. my laziness level reaches a point where I do not feel like using my mouse. I'd rather use key shortcuts than hover from my keyboard to my mouse.

Well, I have been able to set a somewhat efficient environment that allow me to use my computer almost without using a mouse. First, if you have seen my last post, you read that I installed dwm as my window manager. I dropped it because I found a better one: i3. Why did I change ? Because one main reason: recompiling the whole thing everytime I changed something was annoying me. Additionally, i3 has some better features (and little things that sparks my interest):

  • easy to configure;
  • infinite combination of keybindings possible;
  • can be restarted on the fly;
  • windows can be moved (let's say you want to move a window from left to right);
  • bar only shows workspaces who have windows currently assigned to them;
  • orientation of the next window can be chosen;
  • integrated i3 bar supports conky.

Over that, I use customizable applications such as Sublime Text 2. I really recommend you to check this. Learning to use vim also helps when you use the console a lot. So here is my setup, as a developper: i3, urxvt, Sublime Text 2. What about my music ? Simple ! I finally went on to use MPD with MPC and set some keybinds to control it !

Though, this was not enough for me. One app I use a lot still makes me use my mouse non-stop: my web browser. While browsing (yea..) on the ArchLinux forum, I found something interesting: luakit and learnt about a not so popular trend which is keyboard driven web browers. luakit is basically a web browser with vim-like key bindings. I can navigate the web without using my mouse just by following links ! And it is lightweight and still manages to have Flash ! Wow.

Tuesday, April 23, 2013

dwm: For lazy people who like to complicate things first

I am a programmer, therefor I am lazy. It is what is it, programmers are lazy but productive people (ironic isn't it ?) In my last blog post, I explained how I got back to Linux after a quick break and how Arch Linux was fit for me. Even though I was happy with my setup, I wanted more.. and I wanted something simpler. Why ? Because I am lazy ! And on my quest for simpleness, I tried other terminals, I tried GNU screen, I tried to add more and more things to my pypanel..

I ended up browsing the Arch Linux Forum and came across some picture of a window manager that looked simple as 1, 2, 3. I made a little research and found out it was dwm (Dynamic Window Manager) by suckless. OH. MY. GOD. It is what I have been looking for. There is one problem though: unlike OpenBox whose config (or what I have been configuring) was in xml, DWM must be compiled each time you make a change.. and it's in C !!! I am pretty conscious that C is probably one of the must know for programmer but I just did an embedded system class and I hated it so I was a bit skeptical. But I still went on, installed it, tried it, changed the .h (booyaa, I only had to change that file), re-build. The result is beautiful. Minimalist yet powerful. Enough talk, here is the result with very few changes to the original config file:


clean desktop


busy desktop

You might say.. "meh", but to me, this is a palace for a work station. Here are the features I exploited:
  • I discovered Alt+p which launches dmenu (another feature of dwm) which lets me run ANY command without opening a terminal.
  • Each tag (more or less desktops) will be used for one and only one thing. And I have named them just so I know. 
    • You can establish rules like "Chromium will only open in the web tag" or "Sublime Text will only open in the dev tag".
    • You can easily switch tag with alt + x where x is the position of the tag (Alt + 2 would display what's in dev)
  • I can launch a terminal with Shit+Alt+Enter, BUT I had to set which one because somehow dwm assumes you are using urxvt.
  • You can switch between the Tiled mode (which is how it looks on the busy screenshot) or Floating mode. Tiled mode means you let the WM place your windows as long as it fills the screen. Floating mode is what most people are used to but this time, to move a window you must hold the Alt key before dragging it.
  • I can switch between windows easily with my keyboard too !


I kept conky from my setup with OpenBox and the auto-changing wallpaper but that is all. I like this one. 
My status bar font is called ohsnap(.icons). It can be found in AUR.

It's simple, neat and I barely use my mouse. I don't mind recompiling the wm each time. I don't mind if it's in C (C is great anyway, I need to make peace with it). It is worth it. After all, a programmer will spend more time working on something that will save him time than the actual time he saves.

Config can be found at : https://github.com/nylogavins/arch-config

Saturday, April 20, 2013

Back to the sources... open sources !

I have been using Windows for quite some time now (I remember using Ubuntu a few years ago), but I always had an interest in Linux and I never was able to justify why. Recently, as my bachelor degree final project, I released an open-source project (perhaps, a blog post about it will come :D) and after making some researches I am now somewhat able to explain why I like free open-source software. In short: I like collaboration, I like sharing and I like having total control. When using almost any Linux distribution, you get all that and more ! Now, I am not skilled enough to contribute to the Linux kernel or to any distribution base system but I like the idea. But giving me total control on my operating system ? Shut up and take my money ! Oh.. it's free ?! Yay !!

In the past, I scrapped a lot of my Linux or BSD installation by doing things I didn't quite understand. With great power comes great responsibilities after all. But today, I am less immature (because I cannot say I am mature yet) and more aware of what I can and should do. So, I decided to install Arch Linux on my workstation !


Why Arch Linux ? Actually, why installing a certain Linux distribution instead of another ? It is a matter of choice. I tried Gentoo in the past and as much as I like the total control and the range of things I can customize, I just didn't like how emerge was pretty long to install or update some packages (i.e.: x11.. oh boy grab yourself a few movies). As mentioned before, I used Ubuntu before but it is "too" user-friendly for me. So much that when I tried the latest version, I just didn't know how to do simple things (because I like to do things, the complicated way). Fedora.. I like it, but I feel it is waaaaay to heavy but maybe that's just me. I also used FreeBSD for a few years but I wanted to see more.


So I ended up with Arch Linux. I tried it before on my eeePC because it decided to stop working. What I liked about it is that it was relatively easy to install, fast and you decide to install what YOU want. After a fresh install, you do not end up with apps you will discover a few months later and realize you never used. Pacman is also really fast and easy to use in my opinion. It is also backed by a very large community (3 official repositories and a users' project repository).
After messing around for hours, I got something I am pretty much proud of:

















So my installation consists of:

  • OpenBox: No Desktop Environment, just a Window Manager. Onyx is my OB theme but I also applied a GTK+ theme for the look and feel: Orta by using lxappearance.
  • SLiM: My login manager, works and looks great.
  • My "desktop" only has 3 things: conky (that line of text at the top of the screen), pypanel (the taskbar at the bottom of the screen) and feh to apply a wallpaper that actually switches every 15 minutes (I wrote a bash script that those that). You decide what Conky and PyPanel are displaying, which is why it got my attention.
  • Very basic "essential" packages: chromium, sublime text 2, xterm, git. Everything else are extras.
    EDIT: I switched to tilda for my terminal. Tilda is basically a drop-down terminal that I make appear by pressing a single button and i can also make it disappear with that same button. And it opens multiple tabs !!
  • python, ruby, Apache, etc. Things I must have to program.
I discovered some pretty nice packages too along the way:
  • cmus: C* Music Player. A text-based music player. It works great ! You can add medias to your library and just play them, create playlists and pretty much do whatever you want to do with a music player.
  • beets: A text-based media manager. It even corrects the tags of your files and it acts as the database of your mp3 files.
  • yaourt: Yet AnOther User RepOsitory. Same as pacman but you can also update AUR packages.
  • ranger: a text-based file manager with vi-like key bindings
  • task warrior (task): A simple text based todo list.
I seem to like text-based programs huh ? Well yeah. They are usually faster and once you get a grip of the basic, pretty much easy to use.
Now, I am learning the shell more in depth to automate more oft-repeated tasks and I hope to find more cool packages in the repositories.


Config can be found at: https://github.com/nylogavins/arch-config