During a typical day, I would change to the main branch, pull the latest from the remote, delete the merged branches. Over and over all day, every day of the week. Now instead of all that checkout and pulling, I made a Git JERK!
Continue reading “Git Jerk”Tag: CLI
Shell commands with Node
Running CLI Node scripts, capture the return value of a shell command:
const execSync = require('child_process').execSync;
const nodeVer = execSync('node -v', { encoding: 'utf8' });
Shell command reports in the CLI:
const execSync = require('child_process').execSync;
execSync('npm -g ls', { stdio: 'inherit' });
Git Branch Print to CLI
Since the release of Git 2.16, the git branch
command runs as paged executable instead of printing the branches to the console. To revert back to the old way of printing branches to the console, update your ~/.gitconfig
as follows:
[pager] branch = false
Colored Console Output
const out = { end: '\x1b[0m', // Modifiers. blink: '\x1b[5m', bright: '\x1b[1m', dim: '\x1b[2m', hidden: '\x1b[8m', reverse: '\x1b[7m', underscore: '\x1b[4m', // Foreground Colors. black: '\x1b[30m', blue: '\x1b[34m', cyan: '\x1b[36m', green: '\x1b[32m', magenta: '\x1b[35m', red: '\x1b[31m', yellow: '\x1b[33m', white: '\x1b[37m', // Background Colors. bgBlack: '\x1b[40m', bgBlue: '\x1b[44m', bgCyan: '\x1b[46m', bgGreen: '\x1b[42m', bgMagenta: '\x1b[45m', bgRed: '\x1b[41m', bgYellow: '\x1b[43m', bgWhite: '\x1b[47m', };
Usage:
console.log(out.red, 'Something went wrong:', err, out.end);
Windows Recursively Delete Folders
Dreamweaver creates _notes folders in each directory when you upload a file. Recently switched to Aptana and wanted to remove all of these folders that are now useless clutter in my filesystem. Here’s how to do it on Windows CLI in one fell swoop:
> cd \path\to\my\project\folder > for /d /r . %d in (_notes) do @if exist "%d" rd /s/q "%d"
Links
Changing .html to .php on XP
Open the Windows CLI and cd to the directory where you want to change the file names, then enter the following command:
ren *.html *.php
Ta-da!