Martin Valasek

Blog of a Drupal developer.

Current Git branch name in command prompt

Since we started using Git branches as part of our dev workflow at work, it has become essential to always be sure that you’re working with the right branch. You can either always check git branch, or let the current branch name be displayed as part of the command line all the time when you’re inside a Git project. This is very convenient and helps you not to mess the things up.

Useful command line keyboard shortcuts

I use these bash keyboard shortcuts every day and they save me plenty of time, so I find them worth sharing. Even if you’re developing on Windows, you can have (similar) experience of the Linux bash using the Cygwin tool.

CTRL + R, then arrow up/down
Search in the history of bash commands. Press CTRL + R, type a couple of letters, and the most recent matching command jumps out of history. Press CTRL + R again, and you get older result matching your search string. Once you find your command, you hit either Enter to execute the command directly from reverse search, or any other key to keep it in the command line and be able to edit it (I usually use ESC or right/left arrow or the End key). I use this all the time to recall my previous mysql and ssh commands, or other ones which are too long to type. You can use any keyword inside the command when searching.

How to catch emails sent with PHP on your local server

When developing websites using PHP on your local server, it's very useful to see all outgoing emails from your PHP application, if you use the mail() PHP function. This is even more important if you develop on base of a CMS, where you can use various emails templates, field tokens and many other things that you first want to test locally before you push it to your online dev environment.