Summary: By keeping a history of the directories you've visited, the Teleport command is an improvement on the Unix/Linux
cd command. By having a memory, Teleport lets you jump from one directory to any previously visited directory, easily.
January, 2015 Update: The Teleport command now supports Bash completion. For more details on this, see the Github INSTALL.md file.
A few quick notes:
I've named the command "teleport", and it's intended to be a replacement for the Unix/Linux cd command. Really, it's a wrapper around the cd command, first doing all of its own work related to keeping a history, and then issuing the appropriate Linux cd command.
The teleport command (
tp, for short) does everything the Linux cd command does, with these improvements:
Once installed, you can get help on the teleport command by issuing the
-h flag, like this:
This displays a usage statement similar to the following:
Usage: tp [DIR] Purpose: Provide the same capabilities as the 'cd' command, but with a memory of directories that you have previously visited. -h Show HELP (this output) -j PARTIAL-DIR JUMP to a directory found in your history (by partial directory name) -l LIST the history of visited directories -n [NUM] Go to a directory by NUMBER. NUM corresponds to the number printed by the -l option. If NUM is not specified then a list of visited directories is shown and user can pick a number. -s DIR SEARCH for and display a directory named DIR found in your history
Given that starter information, let's see what the teleport command can do.
For basic cases, you'll use the
tp command just like the
cd command. For instance, to move to your home directory, just type
tp by itself, just like you would with the
Or, if you prefer more typing, you can add the
Either one of those commands will take you to your home directory, just like
To move back to your last directory, just add a
-, again, just like
To move to a local subdirectory named
Pictures, again just replace the cd command with
To move to an absolute directory, like
tp works just like
And to move up two directory levels, again,
tp is the same:
Nothing too exciting yet ... so far it it works just like the Unix/Linux cd command. Now let's have some fun.
Where the tp command really shines is with its memory. For instance, let's say your current working directory is something like this:
Next, let's assume you want to move to another directory somewhere else in the filesystem, like this one:
cd command, you'd normally have to type something like this:
But with the
tp command, if you've already been to the
Talkeetna subdirectory, all you have to type is this:
The teleport command instantly takes you to that directory. In this case, that saves you over 30 characters of typing.
Here's an image showing a few more examples of how easily the Teleport command lets you jump around:
This is one example of what remembering your working directory history can do for you, and is the primary reason for the name "teleport".
The next nice thing teleport does is provide a listing of your teleport history. When you issue the teleport "list" command, like this:
teleport will show you all the directories you've visited recently, like this:
43 /Users/al/Projects/DD/Sketch 44 /Users/al/Desktop 45 /Users/al/Projects/DD/Imagen/release 46 /Users/al/Projects/DD/Hyde/build 47 /Applications/MAMP/htdocs/minime/sites/all/modules/minime 48 /Applications/MAMP/logs 49 /Users/al/Projects/DD/Imagen/build 50 /Users/al/Working/Cato-CRUD-Generator 51 /Applications/MAMP/htdocs/cato 52 /Users/al/Projects/DD/Imagen 53 /Applications/MAMP/htdocs/cato/templates 54 /Applications/MAMP/htdocs/sleetmute
I like this feature because (a) I work on a lot of different projects every week, and (b) I have a bad memory. With the teleport command, it's much easier to remember where all my project files are located.
Also, once you've seen this history, you can teleport to any of those directories very easily. For instance, no matter where I am currently in the filesystem, if I want to go to this directory:
all I have to type is this command:
and I'm instantly teleported to that directory. I think you'll agree that's a really nice time-saver.
The teleport command also includes an option to let you teleport to a directory by the number that is shown when you list the teleport history. For instance, using the listing shown above, I can teleport to the same 'minime' directory by typing this -n command:
tp -n 47
This is a nice feature for many purposes, especially when you have multiple directories that end with the same name.
New in Version 0.5: Thanks to a nice contribution by John Santos (somewhere in Portugal), the '-n' command has been significantly improved. Now, instead of typing '-l' and then using those results to feed the '-n' command, if you now type the -n command without a number, like this:
the Teleport command will automatically give you the -l history list, and prompt you for a selection, like this:
50 /Users/al/Working/Cato-CRUD-Generator 51 /Applications/MAMP/htdocs/cato 52 /Users/al/Projects/DD/Imagen 53 /Applications/MAMP/htdocs/cato/templates 54 /Applications/MAMP/htdocs/sleetmute Pick a number or press [Enter]
to cancel: _
If you've used the Teleport command before, you know this is a sweet addition. I suspect most people will now just use the -n option, and -l will mostly hang around for legacy purposes.
Thanks to a nice addition by SneakyBobito, Teleport now supports Bash completion. This is described in detail in the Github INSTALL.md file, but in short, if you have a directory named TwitterClient in your history and you begin to type this
tp command at the Unix command prompt:
$ tp Twit
and then hit the
[Tab] key, the new completion code will scan your Teleport history file, and if it finds any matches, it will automatically complete the directory name on the command line. For instance, I have a directory named TwitterClient in my .tp_history file, so when I type this:
$ tp Twit[Tab]
my command is expanded to this:
$ tp TwitterClient
This is a terrific new addition to the Teleport command.
In addition to all of these features, you can also use teleport aliases.
Teleport aliases provide a simple way for you to create aliases to directories. If you want to resolve conflicts between multiple directories with the same name (as I just showed in the previous section), or you simply want to make sure teleport always knows about a certain directory, you can create an alias for that directory.
Currently the teleport alias works as a separate command named
tpa. (I've thought about merging the
tpa commands into one command, but have not done so yet. After using the commands for a while, I'll be glad to hear your opinion on whether they should be merged together, or not.)
Here's the usage statement for the teleport alias (
Usage: tpa ALIAS Purpose: Transport to a directory that has an alias ALIAS associated with it. -a ALIAS DIR Add ALIAS as an alias/shortcut for the directory DIR -h Show HELP (this output) -l LIST the known directory aliases -r ALIAS Remove ALIAS from your list of known aliases
To add a new teleport alias, use the
-a option, and specify the alias first, followed by the actual directory name, like this:
tpa -a baz /tmp/bar/baz
After issuing that command you'll see output similar to this:
Alias "baz" was added for the directory "/tmp/bar/baz".
Once you've created an alias like that, no matter where you are on the filesystem, you can move to that directory using your alias with the
tpa command, like this:
To list your teleport aliases, just use the
-l option of the
tpa command, like this:
This will list all of the aliases you've defined, like this:
perl:/Users/al/AlsLife/DD/Perl arrays:/Users/al/AlsLife/DD/Perl/ArrayTests pub:/Users/al/AlsLife/DD/Perl/published
(I need to improve this format, but that's the way it looks currently.)
To remove a
tpa alias, just use the
-r option and the name of the alias, like this:
tpa -r pub
tpa command responds like this:
About to remove alias "pub" -- are you sure (y/[n])?: _ Remove operation cancelled.
At this point 'n' will cancel the remove operation, and 'y' will proceed with the remove.
I hope you like the teleport command. I think it makes some nice improvements to the standard Linux cd command.
The hardest part for me when I first started using it was remembering to type
tp instead of
cd. Once I made it through that mental hurdle, I now hate to work on systems where I haven't installed the teleport command yet.
You can download the teleport command as a tar'd and gzip'd file from the following link:
This file will extract to a directory named
teleport, and that directory will contain the following files:
teleport/tp_command teleport/INSTALL teleport/LICENSE
Once you've extracted the contents of this file, you can proceed with the installation. See the INSTALL file for more information.