Author

The Archives

  • 01.09.12
    Greping from inside Vim shell | n0str0m0 | (0)
    Hi there, First things first: Happy New Year! :) One task I usually perform when I am writing code is grepping the code for a certain string. In order to do that, I used to exit Vim (either with :q or suspending the process), grep the files and then go back to my Vim session. This approximation has one main drawback: I usually don't remember all the matches reported by grep. Vim provides a mechanism for invoking grep from a Vim session. The command is: :grep string files This way, one can invoke his local grep command and the results will be integrated into the ...
  • 10.15.11
    Creating shell archives shell | n0str0m0 | (0)
    shar(1) is a FreeBSD base system utility for creating shell archives that is, a kind of self-extracting archive of a hierarchy of files and directories. The archive will recreate the file hierarchy specified at creation time. It is fast and the result is easy to handle as the shell archive is a text file (good to email a file hierarchy). To create a shell archive: $ shar `find my_directory` > my_hierarchy.shar To recreate the hierarchy: $ sh my_hierarchy.shar That is, shar is a simpler version of ar and tar. Enjoy!
  • 09.13.11
    Audio settings on FreeBSD shell | n0str0m0 | (0)
    mixer(8) is a FreeBSD base system utility for setting and displaying sound card mixer levels. It resembles the Linux's command line utility alsamixer. Invoked with no parameters it shows the current values of the mixer devices: $ mixer Mixer vol is currently set to 85:85 Mixer pcm is currently set to 75:75 Mixer speaker is currently set to 75:75 Mixer mic is currently set to 0:0 Mixer mix is currently set to 0:0 Mixer rec ...
  • 04.08.11
    Screenshots from the command line (FreeBSD) shell | n0str0m0 | (0)
    vidcontrol is a nice utility that among other things allows one to capture the state of a video buffer and dump it to a file. The format of this file is specified in the man page as it is not a regular image file. For this reason one needs a specific tool to convert it to something one can play with. These commands are scr2txt (/usr/ports/textproc/scr2txt) and scr2png (/usr/ports/graphics/scr2png). They can then be combined using one single line: $ vidcontrol -p < /dev/ttyv0 | scr2txt > /tmp/screenshot.txt The -p flag instructs vidcontrol to get the current content of the corresponding video buffer. ...
  • 02.04.11
    Easy svn blame vim mapping shell | n0str0m0 | (0)
    The other day, this colleague of mine asked me how he could use svn blame on the same file he was editing without leaving his vim session. This is a mapping I wrote for that purpose. :map <F3> :sp %.tmp_svnblame \| :r! svn blame $(basename % .tmp_svnblame)<CR> Enjoy!
  • 12.21.10
    Limiting resources with limits (1) shell | n0str0m0 | (0)
    limits is a FreeBSD's base system utility for displaying and setting system resources limits. To some extent it is equivalent to the limit and ulimit commands. It can set limits for filesize, coredumpsize, maxproc, memoryuse and other parameters. Convenience modifiers like k, m or g for kilobytes, megabytes and gigabytes or s, m, h for seconds, minutes and hours can be used in all cases. limits can be used to achieve three different goals: Set resource limits. For example: $ limits -t 1s ls -R / launches the ls -R command with a cputime limit of 1 second. In general, this is the ...
  • 10.23.10
    Vim. Macros shell | n0str0m0 | (0)
    You have probably seen something like this in other editors. Macros (or "complex repetitions" as Vim's help puts it) is a way to repeat complex commands sequences. In order to get the most out of this feature, you need to master movement and insertion commands. The work cycle is the following: start recording, execute commands, stop recording. Then, you are ready to execute the whole sequence of commands you have recorded. Let us see this in more detail. To start recording, we use the "q" command followed by a register name in which the sequence of commands will be stored. qa At that ...
  • 09.04.10
    Vim. Key mapping shell | n0str0m0 | (2)
    Maps are a way to create an association between a set of key strokes and a set of actions. They are really powerful. However, in this post, I will not explain them in the deepest detail. If you need further information, you will need a good Vim manual. As it happens with abbreviations, maps can be used regardless of the mode you are in Vim or they can be restricted to a certain operation mode. They work the same way in every mode. Type :help :map to know which map commands work in which mode. First off, :map ... ... <Esc>OM       <CR> <Esc>Ol ...
  • 07.30.10
    Vim. Saving keystrokes: abbreviations shell | n0str0m0 | (1)
    Welcome to a new issue of this short Vim tutorial! As we saw in previous posts, Vim is the perfect tool if you want to save time in your daily work. It helps you in the write-compile-debug cycle, it indents and autoindents code, it is extremely powerful for searching, replacing and many other frequent tasks. In this post I will introduce an interesting feature meant to make you type less: abbreviations. Abbreviations are, as their name indicates, a way to create an association between a short set of characters and a piece of text (or a command). Abbreviations can be used in insert, replace ...
  • 07.03.10
    Which package does this file belong to? cmd | n0str0m0 | (0)
    On FreeBSD, we use the pkg_info command this way: $pkg_info -W /usr/local/bin/mysql /usr/local/bin/mysql was installed by package mysql-client-5.5.2 Enjoy!