Posts Tagged “terminal”

  • Shell Tricks: halp -- a universal help tool

    I have a lot of aliases and functions in my terminal, in addition to the plethora of UNIX commands. If I'm not sure what the source of a command is, getting info on it can require multiple tries. First a man` check, then a `type` or `alias` command to see if it's custom, then a `man -k to see if I misspelled something, and so on. I eventually decided to just write an automated way to sift through those possibilities.…

  • Shell Tricks: shorten every line of output

    Updated: Dr. Drang pointed out that the original functions were mostly working but flawed. I've updated this whole post.…

  • Shell Tricks: list files with most text matches

    Here's a Bash function for searching all text files in the current directory for a pattern, then listing the files containing matches in ascending order by number of matches. It's mostly a proof of concept, but a useful companion to a basic grep search.…

  • Quick reminders from Terminal

    Here's a script for creating simple delayed alerts from Terminal. It doesn't use system notifications, Calendar, or Reminders, just the sleep`, `afplay`, and `say commands (making it Mac-only), and optionally LaunchBar large text display.…

  • Shell Tricks: Quick line numbering

    It's often useful to quickly see line numbers when viewing source code files. The less` command and related tools can display with line numbers. There's also the `nl` command, but it doesn't number blank lines and tends to mess up formatting. There's are ways that are more flexible and better looking. Enter `grep` and `paste.…

  • Shell Tricks: convert file urls to UNIX paths

    Today's shell trick is for converting file:// urls into valid shell paths. This isn't a terribly common scenario, but I occasionally work with tools, especially in GUI applications, that output file urls and need to change something like:…

  • mdless: Better Markdown in Terminal

    I wanted to be able to view Markdown README files quickly and pleasantly from Terminal. More often than not, I'm working in an iTerm2 visor window, so opening any app---including a simple qlmanage -p---will make my current view slide away. Not a big deal, of course, but it seemed like it could be easier.…

  • Shell Tricks: .inputrc binding fun

    If you've never explored Bash's ~/.inputrc file, there's a lot of customization you can do in there. From setting completion and Readline options to creating custom keybindings, you can greatly improve your command line efficiency with a little tweaking.…

  • CodeReminder: don't forget to play

    I put together a little utility this morning to help me remember what GitHub repositories I've grabbed with the intention of playing with later. I often clone or fork a repo and plan to explore it over a weekend, but then quickly forget about it if I don't add a reminder.…

  • A universal clipboard command for Bash

    I frequently use pbcopy` in the shell to get output to the OS X clipboard. I'm constantly using `[command] | pbcopy, and figured it would be worth making a little easier, so I wrote this little function this morning.…

  • OS X shell tricks: speaking in tongues

    I have an always-on Mac mini that sits in the corner of my office. It toils away running staging servers for media, web development, and home automation. It also runs a lot of scheduled scripts.…

  • Intrepid command line directory traversal

    I use Terminal (well, iTerm 2) for file management on my Mac more often than I use Finder. Typing out long path names is often more tedious than drilling through Finder folders, though. I have enough tag-based Spotlight (mdfind) tools worked out in Bash that traversal in the shell has most of the same conveniences, but still, some of those paths...…

  • A Bash function for finding your Bash functions

    As you may have noticed if you've followed this blog lately, I write a lot of Bash functions and aliases. I keep them in distinct files using a plugin system based on bash-it. It works really well, and makes upkeep simple. However, I very often lose track of exactly where I defined a function or alias after a few months go by.…

  • Shell trick: printf rules

    This post is about a simple trick for printing a horizontal rule in the Terminal, but I would like to start by saying that the headline is not entirely an attempt at humor. I spent a long time working with the limitations of echo`, with its `-e` annoyances and `-n` inconsistencies between shells. Then I started using `printf more, and it's made string formatting and terminal output so much simpler. Check out the man page (and some more info on format strings)if you're not already familiar with…

  • Keybindings for multiple clipboards

    It's been a while since I brought up keybindings. If you haven't followed my obsession with them in the past, you can catch up on all the fun in older posts and by browsing through the massive KeyBindings project I've assembled. To summarize, KeyBindings on OS X can provide all kinds of text editing assistance that's available and consistent across every app you use.…

  • Reiki, a fix for my convoluted Rakefiles

    I just published project called Reiki, a shell function that I've been using to make it easier to run the various (and often overly complex) Rake tasks that I use in a lot of my projects. The headline should probably have been "a stopgap for my convoluted Rakefiles." To summarize, it turns:…

  • Vitag 1.0.2

    Vitag has proven useful enough to me that I've added a bit of polish and some new features. I do think this is going to end up being a RubyGem eventually for ease of install, but at this point still only requires a single script file to run.…

  • sizeup: tidy filesize information in Terminal

    alias sizes="du -sh * | sort -n" That outputs all of the file and folder sizes in the current directory, sorted by size, and lists them in human-readable format. Of course, I wanted to make it a more painful endeavor.…

  • Vitag: batch Finder tagging from the command line

    Vitag is a quick script I wrote today that I think might be useful to others. I don't know how many people both live in Terminal and make use of Finder tags in OS X 10.9+, but if anyone does, this will make life easier.…

  • Preview the OS X clipboard in Terminal

    I apologize for being a little slow on posting for a bit now. Here's a quick one for the Shell Tricks series, though.…

  • Solve command line mysteries with 'type'

    I have dozens of aliases and functions available in any shell in any terminal on any of my machines. If I add Homebrew installs and PATH priorities, it can be a lot to keep track of.…

  • Safer command line paste in iTerm 2

    If you've ever copied a shell command from somewhere and accidentally included a trailing newline, you know that hitting paste in your terminal can run the command before you have a chance to edit it. There are a few ways around this, but here's a quick tip for iTerm 2 users.…

  • The "Shell Tricks" video course

    It's $11.99 for the full course, and covers tricks for working with files and directories on the command line, clever git tricks, web design tools, and more fun on the command line.…

  • Shell tricks: A time to kill

    I detailed the open command in the last Shell Tricks post, so I thought I'd go over some tricks for doing the opposite next: closing and quitting apps.…

  • Shell tricks: the OS X open command

    You may already be familiar with the open command in Darwin (OS X's flavor of Unix). It allows you to open files and URLs in their default app or one that you specify. In its simplest form:…

  • Shell Tricks: man pages

    Man pages make Unix go 'round. I can't think of any system that's better documented, and the answers are almost always right at your fingertips.…

  • Making cd in bash a little better

    The Bash command cd` is pretty good with tab completion (though not as good as Z shell). I often want to complete a path like `~/Scripts/`, though, and get caught up on directories such as `~/ScriptingAdditions`, which I never need to get to through Terminal. There's an easy way to ignore those pesky directories, though, using the `$FIGNORE variable.…

  • Mavericks tags and coreutils, a warning

    This won't affect too many people, but if you've installed the GNU Coreutils, you should be aware that the mv` and `cp commands strip extended attributes from your files. If you do any tagging in Mavericks (or with OpenMeta), you'll find your tags disappearing after shell scripts or command line filing act on a file.…

  • Fast, fuzzy directory navigation for Tag Filer

    This script provides an easy way to jump around the filesystem if (and only if) you're using my Tag Filer system. In that system, you tag main "context" folders with "=Tagname," and target subfolders (project folders) with "@projecttag." The Tag Filing system allows me to tag individual files and folders with a "#Tagname" (target context) and ":project:chain" tags to have Hazel automatically move them to their destination and maintain both a shallow folder system and a tag-based search system.…

  • Even better random filenames

    This is an evolution of the random filename generator I posted last week. Based on comments from BrianEnigma, this script allows you to specify "starts with" arguments to get an adjective and a noun using the WordNet dictionaries.…

  • (Potentially) funny random filenames for Bash scripts

    It's been a busy week, and I'll be writing up my WWDC thoughts and a couple of TUAW posts after a plane ride today. In the meantime, I made you a thing.…

  • tmux even easier: tm with fuzzy completion

    You may have seen the "fuzzy" Bash completion I linked to in my up` post yesterday. I applied the same technique to my `tm] utility for [completing tmux session and window names.…

  • up: fuzzy navigation up a directory tree

    Here's a (relatively) simple shell function for navigating up the tree from your current working directory. It was inspired by bd, but I got frustrated with some aspects (and the fact that it's not really OS X-compatible anymore).…

  • Making my tmux life easier

    Have you heard of tmux? Do you ache for terminal mutiplexing and persistent shell sessions? If not, you can probably skip this post. Hang tight, I have something more generally palatable in the works. In the meantime, if you want to read up, head to the tmux homepage.…

  • Bash and Dash

    I know, "bash and dash" sounds like a sadistic game for frat boys. But it rhymed and was so apropos.…

  • Thinking in the shell

    My doing` project has been a great tool for me, and it's evolved into a fairly complete time tracking system of sorts. Using the `done`, `finish`, and `meanwhile` commands, you can include time intervals for your entries and see them with `--totals` in most `view` and `show variations. I'll need to do a whole post on that to explain it properly, but I wanted to mention something different today.…

  • Quick Tip: caffeinate your Terminal

    This command can be run in a couple of ways. First, you can add a timer and tell it to prevent sleep for a certain duration. Alternatively, you can attach it to another command to keep the computer awake as long as that process is running, allowing the system to sleep after the command finishes.…

  • Remote pbcopy on OS X systems

    I've been using this great tip from Sean Coates for years now on my remote Linux servers. It allows you to simulate the pbcopy command (which copies piped text to the OS X clipboard) on remote SSH servers, but copies to your local clipboard instead. I've primarily been using OS X servers for a while now, though, and it took a few changes to get it working.…

  • Quick Tip: Automating your Mac's wifi power

    This is a quick one, and many of you probably know it, but you can quickly toggle wifi on your Mac with the networksetup command. To turn your wifi on:…

  • Bash completion for Mac app aliases

    I have a slew of aliases that launch various apps. Quite a few of them launch apps that I generally only use with one type of file. Xcode and TaskPaper, for example. I wanted a completion system that would find just the applicable files in the directory. In most cases with these apps there's only one file per project, so being able to type xc` and hit tab to open the `xcodeproj file for the current project is handy.…

  • Mavericks tags, Spotlight and Terminal

    I've actually begun work on a book about tagging, and Mavericks in particular. It's a subject I truly enjoy, and so far it's kind of been writing itself. I hope to wrap it up faster than some of my other side projects. Bits that I think aren't mass-consumable enough for publication will end up here, where my gentle readers can decide for themselves if they want to do anything with it.…

  • Easily save that wicked awesome shell command

    This isn't a brand new trick. It's based on a Bash function for "alias last" that I've seen in a few places. The original version uses history to get the last command you ran and turn it into a temporary alias. I expanded it a little with some escaping for quotes and trimming whitespace, but it's the same function.…

  • Bash image tools for web designers

    Here are a couple of my Bash functions for people who work with images in CSS or HTML. Nothing elaborate, just things that supplement my typical workflow.…

  • Thumbnail icons for Delish bookmarks

    I've been messing around with some more ideas surrounding the future of bookmarking and information gathering. As part of that process, I bought Delish and started messing around with some Spotlight/Finder integration. I won't go into all of the kMDItemAwesome of that, but I did work out a trick on the way that might actually be useful.…

  • A few more of my favorite Bash aliases

    I love my aliases. It's part of the reason I need a better dotfile management setup --- porting them to any server environment I'm working on is a must for my sanity. I thought I'd share a few of the ones I find handy, especially in OS X environments.…

  • A multi-purpose EDITOR variable

    Here's a quick trick I've been using to load different editors from the command line based on the type of file. It can be extended to whatever file types you want to handle and use whichever editor you prefer.…

  • More command line handiness

    These are just a few tricks that have come in handy lately that I thought I'd pull out of my .bash_profile and stick on a web page.…

  • GMail in the shell

    Here are a couple of nifty (I think) bash functions which probably won't work for anyone else. The first one checks GMail and reports unread messages on the command line, the second one keeps a vigilant watch for new messages and streams the sender and subject lines using rsstail.…

  • Quick Tip: Jumping to the Finder location in Terminal

    I'd been meaning to write a script to do this for a while, and a post by Dr. Drang inspired me to whip it up. Dr. Drang's is a TextExpander snippet (which also works fine in shell if you use "quoted form of" to be safe). This method is just a tad more convenient for Terminal usage. It's a two-line bash function for quickly cd`-ing to the location of the front Finder window with a simple command (`cdf).…

  • Scheduling posts with Jekyll

    After my downloads system was sorted (post coming up) and I had a writing workflow worked out, my big concern with my Jekyll system was scheduling future posts. I tend to write in streaks and, given that very little of my work is exactly time sensitive, spread the posts out to make up for the days I decide to sleep in my free time. That's a little harder to do with static blogs.…

  • Clip Text File: more surprisingly handy dumb tricks

    As you may know, I store a lot of information in plain text files. Among the things I enjoy about this has always been that I can grab the contents of any file straight to the clipboard --- without opening it --- when I'm on the command line. I just use cat FILENAME|pbcopy and boom, done. I wrote a function a long time ago to make this a little safer and more convenient. It avoids clipping non-text files accidentally and provides a little feedback.…

  • Next Actions CLI updated, time to meet the parents

    I just updated my trusty na script a little bit. Nothing major: some more colorful output and graceful error handling and cache updating when folders it's recorded go missing. In the process, though, I realized how much I've come to love this little guy.…

  • Matrix(ish): a bash script with no practical application

    Ok, just for (nerd) fun, here's a Bash shell script that will output a Matrix-ish display in Terminal. I have no idea if it works outside of BSD on OS X, but it has a chance.…

  • Launching your entire Dock at once

    I keep my Dock very trim. The only apps that have a permanent home there are apps that I either have to have running all day, or apps that I choose to have running all day. However, I don't make them launch items. Booting up can be slow enough without trying to launch five heavy apps at the same time that everything else is loading.…

  • Mountain Lion Notifications from Terminal with terminal-notifier

    Via a post on OneThingWell, I discovered a new Ruby library and accompanying CLI called terminal-notifier. It allows you to quickly interface with Mountain Lion's Notification Center from the command line. terminal-notifier will be available as part of the filesystem-watching tool Kicker, but you can put it to use as a general notification system for Terminal right now.…

  • Overthinking it: fast bundle ID retrieval for Mac apps

    Ok, I told the world and myself (in a podcast you haven't heard yet) that I wouldn't admit to putting time into this, but... I kinda like it. Given that you'll probably need it at least once at some point, I might as well share it and save you the time.…

  • Quick Tip: system-wide notifications with notifyutil

    I just discovered this, thus don't know a lot about it, but notifyutil is a pretty cool command line utility in OS X. I know it exists in both Lion and Mountain Lion, not sure how long it's been around before that.…

  • Bash completion for defaults domains

    There are a lot of things you can do with the OS X defaults command. This post isn't intended to detail them, but a little searching can turn up a lot of neat tricks.…

  • Desktop cleanup scripts for screencasting

    I don't screencast a lot, but I do it enough to have a set pattern for preparing to record. I automated the process a few months ago and figured I'd share it.…

  • A simple but handy Bash function: console

    I've long had an alias in my ~/.bash_profile` called `console`. It simply tailed the system log with 'alias console=tail -f /var/log/system.log'. Bam I decided to amp it up a little for added convenience. The function below allows me to add additional arguments which are translated into a regular expression for filtering the log output. Arguments, separated by spaces on the command line, are joined into a regular expression as OR matches. You can specify as many as you like to track each as…

  • na: per-project todos in Terminal

    As I've mentioned before, I keep todo.taskpaper files in my web and code project folders. These allow me to keep track of bugs, ideas, notes, etc., and the archive it creates helps me remember what I did, when I did it and how it worked. I like having them separated per project it's the way my one-track mind works. I like the plain-text format because I can use any variety of methods (including TaskPaper itself) to manipulate and quickly update the files. This gave me the idea to have Terminal…

  • Bash auto-complete for running applications

    I'm not up for doing a full Bash autocomplete tutorial tonight, but wanted to share something I figured out instead of eating lunch. Here it is with a modicum of explanation.…

  • Quick Tip: some .inputrc fun

    Quick tips are random posts regarding something I discovered on my way to something bigger. They usually get longer than "quick" would imply, for which I refuse to apologize.…

  • GVoice command line SMS revisited

    Thanks to a comment from Evaryont on the original SMS from the command line with Google Voice post, a problem that was causing Error 500s in the script has been solved.…

  • Quick Tip: This command line trick is tops

    Quick tips are random posts regarding something I discovered on my way to something bigger. They usually get longer than "quick" would imply, for which I refuse to apologize.…

  • Quick Tip: Extracting Mac App Store reviews as text

    Quick tips are random posts regarding something I discovered on my way to something bigger. They usually get longer than "quick" would imply, for which I refuse to apologize.…

  • Option-arrow navigation in iTerm2

    I've been trying to get Option-arrow keys to move by word in iTerm2. I figured out a solution, but it's weird. If anyone has an explanation or a better way to do this, let me know.…

  • oft: Bash function for opening a specific filetype

    Here's another simple Bash function that I've used so much recently I thought I should share. It's called oft`, which stands for Open File Type, and can be used as a standalone shell script or as a function in your `.bash_profile. When run, it looks in the current directory for files with extensions that match (or partially match) the first argument and opens them.…

  • A Bash function for Markdown bloggers

    I store all of my writing as separate Markdown files. A basic tagging system adds more "searchability," and I can quickly locate any file with Spotlight. Given the amount of time I spend in Terminal (well, iTerm 2 these days), I use mdfind quite a bit to do the Spotlight searching. This function just makes it a little more convenient to search for and quickly edit an existing document.…

  • Quick Link: Terminal navigation utilities

    If you follow me on Twitter, you've probably seen me express my adoration for autojump, a command-line utility for navigating frequently-used folders. The only problem is that I deal with a lot of repetitive folder hierarchies for example, the multiple site structures in my web development folder. j css almost certainly isn't going to take me to the one I was thinking of.…

  • Quick Tip: throttling parallel batch processes in Terminal

    Quick tips are random posts regarding something I discovered on my way to something bigger. They usually get longer than "quick" would imply, for which I refuse to apologize.…

  • Automated HTML5 video encoding revisited

    A little while ago I approached the subject of scripting automated encoding for HTML5 video formats. I started using the process regularly as I built the Blogsmith Bundle video site. Pretty soon I got some help from friend and TUAW editor Mike Rose, and working together we refined the script and improved the speed tremendously. It was built for use on Mac OS X, but with just a few lines modified, it should work on any *NIX system.…

  • Address Book search and Skype from the command line

    Here's a neat little command-line utility for searching your address book: aboo. It's not complex... it just takes a single word or phrase and searches your Address Book entries' names for it. It can output vcards and YAML, too. I created a fork that adds a few things, most importantly I extended search to business names and notes. It also does a better job of realizing there's no proper name and substituting the Company name in the output, if it exists. There's a compiled binary of my fork on…

  • Automating HTML5 video encodes

    I spent an inordinate amount of time not doing useful things today. During this non-productivity bender, I got a little obsessed with making the HTML5 video encoding process easier. I've been working on a tutorial site for the Blogsmith Bundle, so this whole deal needed to be sped up. I came out with a script which, when combined with the right command line utilities, takes 90% of the manual labor out of creating the multiple formats needed.…

  • Grabbing a Mac app's icon: Automator style

    We've covered a small truckload of Bash scripting ideas for Mac and OS X in the previous two posts. It's time to put them to use and create an Automator app that we can use as a droplet in Finder. If you skipped straight here, it probably means you don't really want to know about the messy details of the scripts, so this post won't go into a lot of Unix mumbo jumbo.…

  • Grabbing a Mac app's icon: advanced Bash usage

    In the previous post in this series, we looked at the basic Terminal commands we'd use to grab a Mac application's icon from the command line. In this post, we'll flesh out the script a little and turn it into a Bash function with some added features:…

  • Grabbing a Mac app's icon: building blocks

    I spent a few hours last night nerding out over an easy way to grab a Mac application's icon. I sent the basic Bash script and an example Automator action off to the other writers at TUAW. Then there was dinner, a movie, drinks and dessert. I found myself back at it when I got home. I am Jack's complete inability to leave well enough alone.…

  • Quick calculations in Bash

    This is probably going to seem stupid, but every time I decide to do something in Bash that should only take me a minute, I end up losing an hour. I obsess over "better" ways to do everything. Not surprisingly, my motivation often wanes before I actually find the better, more elegant way, so these little projects end up lackluster. Fortunately, I end up learning all kinds of new, mostly unrelated things in the process, which is what happened this evening. It's amazing to me that I use UNIX…

  • SMS from the command line with Google Voice

    I needed a script send an SMS today, and I found a very handy post at sudocode to send one via Google Voice, using PHP. I wanted to make it a little more command-line-friendly, so I rewrote it (ham-handedly) in Ruby and added some options parsing to it. It's designed for --- and only tested on --- OS X, but may work fine elsewhere.…

  • Things tasks from the command line

    If you're a Things.app user (and a Terminal user), I've got a quick function for your .bash_profile that will allow you to quickly add todo items to your inbox with notes and natural-language date parsing.…

  • Is your URL too short? Try our system, free!

    I was sifting through my previous blog after Jeffery Zeldman kindly sent a lot of visitors in that direction for some TextMate starter tips. Whilst milling around, I stumbled upon an old trick I used to use in Quicksilver (before I gave up on it), but had forgotten about since.…

  • A quick TextMate KeyBindings tip

    I love the keyboard, and I love keyboard shortcuts. It's one of the reasons TextMate and I get along so well. There's one thing that bothers me any time I'm editing text (in any application), though: having to move my right hand all the way over to the arrow keys just to move forward a couple of characters, say, after an auto-paired set of parenthesis that I want to get out of.…

  • TextMate drag command for Base64 encoding images

    Just a quick hit on this one... when hacking away at the styles of things one probably shouldn't be hacking away at, embedding images right in the CSS is a handy trick. It's done by Base64 encoding the image, removing line breaks from the resulting string, and using it to set the background property for the CSS rule.…

  • fk: redux

    Just a quick change to my post on the bash function fk` that I've been using. A small modification has greatly improved its usability: make the cancel option always be first in the menu. Just move "Cancel" before the `$(fp $1) bit. It's a little odd that I didn't do that to begin with...…

  • My new favorite Bash prompt

    I do a lot in Terminal. Sometimes, it's easier. Sometimes it's faster. Sometimes I'd just rather type it out. Whatever the reason, I've never been able to stand looking at a boring shell prompt. Bash is my primary shell, mostly because I've never taken the time to learn much else. I'll get there someday. For now, here's my current Bash shell prompt...…

  • fk: a useful bash function

    This is a function from my OS X .bash_profile. 'fk' is short for Find and Kill, and it lets you do a quick search of your running processes for a case-insensitive partial match of the first parameter passed to it. It's useful for quickly finding a process without worrying about its capitalization or full spelling, and without having to sift through (or manually grep) a long ps ax list.…