Archive | Linux RSS feed for this section

Colorized tail

28 May

I was tailing a logfile and I wanted to colorize some specific keywords in it. I found Andreas Schamanek’s mycolorize which serves perfectly for the purpose.

Download it and use it by doing

$ tail logfile | ~/mycolorize color 'regexp'

You can check additional examples and documentation on the website.

Advertisements

Issue with Terminator keybindings in Ubuntu 12.04

17 May

If Terminator keybindings with Ctrl-something are not working for you, it’s due to a bug.

Until it is fixed, you can edit your ~/.config/terminator/config and replace <Primary> by <Ctrl>.

Sending data to the clipboard from command line

26 Apr

In several occasions I find myself catting some file and then having to select the entire text with the mouse. If I want to keep my hands on the keyboard, I have to do a vim file, ggVG, “+y, :q.

Well, I found a way to do it faster and nicer simply by piping to the clipboard, thanks to xclip.

To use it, just install it and configure an alias in your .bashrc file, as follows:

$ sudo apt-get install xclip
$ alias clipboard='xclip -selection clipboard'

Then, when you need to do something like configuring your SSH key in GitHub, you just:

$ cat ~/.ssh/id_rsa.pub | clipboard

Thanks to Brian Racer for this snippet!

Enhancing vim for Scala

6 Apr

You like Scala. You like programming. You like vim. You are happy.

Here’s the 2-line solution to increase your happiness even more:

cd ~/.vim
svn export --force http://lampsvn.epfl.ch/svn-repos/scala/scala-tool-support/trunk/src/vim .

And there you go, nice indent and syntax highlighting support for Scala.

Massive thanks to Nico “@nfmelendez” Meléndez for pointing this excellent package!

Enhancing vim as an HTML/JS/CSS/PHP editor

11 Jan

I have enough of heavyweight, sometimes cluttered IDEs. I don’t know, maybe I’m getting too old-school or something, but I find myself working faster with plain old vim.

Of course, over time I have been optimizing the editor with the addition of several plugins and customization of its settings.

Here is my current vim setup focused on HTML, JS, CSS and PHP programming:

  1. Install NERDTree
    This gives you a nice tree view of the filesystem.
  2. Install IndentAnything
    Name says it all.
  3. Install JavaScript indentation
    A nice JS indentation for IndentAnything
  4. Install JSLint
    Validates the code for compilation errors as well as styling and informs you of this, almost in real-time!

You might want to throw in some visual enhancements as well. The railscasts color scheme along with the Monaco font are a pretty good combination.

Finally, my .vimrc file:

"Keyboard mappings
map :NERDTreeToggle

"FileType support
set filetype=on
filetype plugin on
filetype indent on

"Color scheme and font
autocmd FileType javascript,html,css,php colorscheme railscasts
autocmd FileType javascript,html,css,php set gfn=Monaco\ 10

"Hightlight current line
autocmd FileType javascript,html,css,php autocmd InsertLeave * set nocursorline
autocmd FileType javascript,html,css,php autocmd InsertEnter * set cursorline
autocmd FileType javascript,html,css,php highlight CursorLine ctermbg=40 cterm=NONE

"Indentation
autocmd FileType javascript,html,css,php set ai
autocmd FileType javascript,html,css,php set sw=2
autocmd FileType javascript,html,css,php set ts=2
autocmd FileType javascript,html,css,php set sts=2
autocmd FileType javascript,css,php set textwidth=79

"Enable autocompletion
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS

"Enable line numbers
autocmd FileType javascript,css,php set number

"Enable incremental search
autocmd FileType javascript,html,css,php set incsearch

And that’s it. Please feel free to post your suggestions!

One-liner for downloading and extracting a tar.gz

18 Nov

I’m not the typical Linux one-linerd, but there are some that I find very useful.

Why execute 3 commands to download a tar.gz file, extract its contents and delete the archive, when actually there’s no need to store the archive physically (you only care about its contents) and you could save one command in the process?

So that’s why I love
wget -O- <url> | tar zxv
I tried the same for zip files but it doesn’t work. According to man unzip:

Archives read from standard input are not yet supported, except with funzip (and then only the first member of the archive can be extracted).

If anyone knows a workaround, it will be very appreciated!

 

Ubuntu 10.10 suspend/resume issue

3 Nov

Tired of virtualboxing Linux for development (nothing wrong with VirtualBox, though) I’ve decided to dual-boot with Ubuntu 10.10 desktop edition. Everything was just fine until I close the lid and had some lunch. When I came back I found out that Ubuntu was booting from the start.

I had it fixed by adding the following option to GRUB_CMDLINE_LINUX in the /etc/default/grub file:
GRUB_CMDLINE_LINUX="acpi_sleep=nonvs"
Then I had to update grub by executing
sudo update-grub
And finally, had to restart Ubuntu in order to get the new boot configuration.

 

%d bloggers like this: