Using the Numpad in vi over SSH

One of the things that kept on bothering me when SSH’ing is that the keys of the numpad would not work in vi: when pressing any key on the numpad, another key would be sent somehow.

Should’ve Google’d this a lot earlier because the fix is very simple: in the preferences of Terminal, go to Profiles → Your Profile → Advanced and uncheck the “Allow VT100 application keypad mode” option.

You can also tweak this setting from the CLI using PlistBuddy:

/usr/libexec/PlistBuddy -c "Delete 'Window Settings':Pro:StrictVTKeypad" ~/Library/Preferences/com.apple.Terminal.plist > /dev/null 2>&1
/usr/libexec/PlistBuddy -c "Set 'Window Settings':Pro:StrictVTKeypad bool true" ~/Library/Preferences/com.apple.Terminal.plist

There, much better 🙂

☝ I’ve also added this tweak to ./freshinstall, a tool which I built to automatically configure my MacBook (Preferences, Dotfiles, Installed Software, etc)

Did this help you out? Like what you see?
Thank me with a coffee.

I don't do this for profit but a small one-time donation would surely put a smile on my face. Thanks!

☕️ Buy me a Coffee (€3)

To stay in the loop you can follow @bramus or follow @bramusblog on Twitter.

Open your React Native’s Xcode project file from the CLI with xed

For a long time I always used the open command to open the Xcode project file contained inside React Native Projects.

bramus in ~/repos/projects/react-native/example
$ open ios/Example.xcodeproj

It wasn’t until I recently started a new React Native project that react-native init afterwards informed me to use xed instead.

The xed tool launches the Xcode application and opens the given documents, or opens a new untitled document, optionally with the contents of standard in.

With xed you don’t need to know the name of the project file. Just pass in the ios folder as an argument and it will handle things for you:

bramus in ~/repos/projects/react-native/example
$ xed ios

💁‍♂️ xed handles both workspaces (.xcworkspace) and regular project files (.xcodeproj) so no worries there 🙂

Furthermore, if you don’t want to remember yet another extra command, you can always add it as a script to your package.json:

{
	…
	"scripts": {
		…
		"xcode": "xed ios"
	},
	…
}
Did this help you out? Like what you see?
Thank me with a coffee.

I don't do this for profit but a small one-time donation would surely put a smile on my face. Thanks!

☕️ Buy me a Coffee (€3)

To stay in the loop you can follow @bramus or follow @bramusblog on Twitter.

Share terminal sessions as animated SVG with svg-term-cli

svg-term-cli is a tool that render asciicast (terminal recordings) to animated SVG. Pass the asciicast id into svg-term in order to convert it:

svg-term --cast=113643 --out examples/parrot.svg --frame

This asciicast for example:

Using the command above, it will render to this SVG:

svg-term-cli – Share terminal sessions as razor-sharp animated SVG everywhere →

ANSI Control Functions and ANSI Control Sequences (Colors, Erasing, etc.) for PHP CLI Apps

As a side project for Monolog Colored Line Formatter (which int itself also is a side project for Mixed Content Scan) I just published is ANSI PHP.

bramus/ansi-php is a set of classes to working with ANSI Control Functions and ANSI Control Sequences (ANSI Escape Sequences) on text based terminals.

  • ANSI Control Functions control an action such as line spacing, paging, or data flow.
  • ANSI Control Sequences allow one to clear the screen, move the cursor, set text colors, etc.

When it comes to ANSI Escape Sequences bramus/ansi-php supports SGR (Select Graphic Rendition) and ED (Erase Display)

  • SGR affords one to manipulate text styling (bold, underline, blink, colors, etc.).
  • ED allows one to erase the display.

Other Control Sequences – such as moving the cursor – are not (yet) supported.

It differs from other “PHP ANSI Color” attempts by not being limited to SGR only – it can easily be extended to support other ANSI Escape Sequences – and by supporting all SGR parameters.

The library ships with an Ansi helper class to easily use it.

use \Bramus\Ansi\Ansi;
use \Bramus\Ansi\ControlSequences\EscapeSequences\Enums\SGR;

// Create Ansi Instance
$a = new Ansi();

// Output some styled text on screen, along with a Line Feed and a Bell
echo $a->color(array(SGR::COLOR_FG_RED, SGR::COLOR_BG_WHITE))
       ->blink()
       ->text('My text will be white on a red background and I will be blinking.')
       ->nostyle()
       ->lf()
       ->text('I will be normally styled. Oh, a bell is coming up ...')
       ->bell()
       ->get();

Installation of course is possible via Composer:

composer require bramus/ansi-php ~2.0

ANSI PHP — ANSI Control Functions and ANSI Control Sequences (Colors, Erasing, etc.) for PHP CLI Apps →

Did this help you out? Like what you see?
Consider donating.

I don’t run ads on my blog nor do I do this for profit. A donation however would always put a smile on my face though. Thanks!

☕️ Buy me a Coffee ($3)

$://showterm

It’s showtime in a terminal near you! Put on your best colours, resize to 80 columns, and let your fingers fly!

Termshows are purely text based. This makes them ideal for demoing instructions (as the user can copy-paste), making fail-safe “live-coding” sessions (plain text is very scalable), and sharing all your l33t terminal hacks.

Great for teaching. Looks like I’ll need to replace my half-assed (and manual) attempts such as http://bramus.github.io/ws2-sws-course-materials/xx.git.html#/2/5 with this.

showterm →

Removing OS X “Open With” Duplicates

8479758031_b504e9bb2f_z

Most of the time Finder will show you multiple entries for each application when right clicking a file and choosing Open With. Getting rid of Open With duplicates gives us an alias to remove those duplicates. Below is not only the alias, but a one-line command to add the alias to your ~/.bash_profile. Just copy and paste it onto the shell and you’ll have the fixopenwith alias available.

Above that the version below is a slightly improved version: not only will it rebuild the index, it’ll also relaunch Finder and open TotalFinder (if you have it installed) after having rebuilt the index.

echo "alias fixopenwith2='/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder && open /Applications/TotalFinder.app'" >> ~/.bash_profile

Once done, just call fixopenwith and it’ll do it all automatically.

(via )

Note: also to be found in Mathias’ dotfiles, an exquisite resource I’ve been cherrypicking from lately 🙂