Skip to content

epmoyer/majortom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Navigate your file system from the command line using shortcuts.

List shortcuts

Use to (with no arguments) to list your current shortcuts.

Navigate

Use to <shortcut> to navigate (change directory) to an existing shortcut.

You can also abbreviate the shortcut name (e.g. to apa for apache).

See where you are

When you run to (with no arguments) all shortcuts matching your current directory will be marked.

Add a shortcut

Use to -a <shortcut> to add a shortcut to your current working directory.

Delete a shortcut

Use to -d <shortcut> to delete an existing shortcut.

Supported Color Modes

MajorTom defaults to terminal color mode 16m (24-bit RGB). It also supports 256,16, and no-color modes via the following command-line options.

  • -color=16m
  • -color=256
  • -color=16
  • -no-color

If you want to force a color mode other than the default (16m), then add it to the to() function in your .bashrc/.zshrc like this:

to () {
    result=$(majortom -color=16 $@)
...

Supported Shells

MajorTom supports zsh and bash. During installation it will look for ~/.zshrc and ~/.bashrc and will prompt you to install its helper function to() into each (if found).

To to() function is extremely simple, so if you're running a different shell and have some basic familiarity with shell scripting then you should have no trouble porting it to a different shell.

Installation

Installing From a Pre-Made Build

  • Download one of the pre-made builds from Releases.
  • Extract the archive
    • For tar archives: tar -xvzf <archive> e.g. tar -xvzf majortom_1.4.0.linux.arm.tgz
  • cd into the extracted archive.
  • run ./install.sh

Installation example

Installing From Source

  • Follow the Build Instructions to build the installation images.
  • cd into the build for your OS and processor architecture under dist/builds
  • Run ./install.sh

Uninstalling

  • Delete the to() helper function from your ~/.bashrc and/or ~/.zshrc.
    • Delete the lines from:
      • # majortom:start -----------------------------------------------------------------
    • Through:
      • # majortom:end -----------------------------------------------------------------
  • Delete the executable:
    • sudo rm /usr/local/bin/majortom

Configuration File

By default, MajorTom's config file location defaults to ~/.config/majortom/majortom_config.json. You can override that by setting the environment variable MAJORTOM_CONFIG. (e.g. export MAJORTOM_CONFIG=~/my_config_dir/mt.json).

If you don't yet have a config file, you can create one by running majortom -init, which will create a new (blank) config file at the currently configured location.

The -init command will never erase/overwrite/clear an existing config file.

A typical config file containing a few shortcuts might look like this:

{
    "locations": {
        "apache": "/var/log/apache2",
        "dne": "~/this/path/does/not/exist",
        "hello": "~/code/golang/helloworld",
        "launch": "~/Library/Preferences/com.apple.LaunchServices",
        "my": "~/code/golang/myproject"
    }
}

Build Instructions

(These instructions presume that you have a working go environment set up on your machine)

Building from source

  • Clone the repo.
  • cd into the repo.
  • Run go get . to fetch the dependencies.
  • Run ./build.sh
    • The builds will be created in /dist/builds
    • the zip/tar images will be created in /dist/images

Building for other architectures/processors

The build script creates cross-compiled builds for multiple OS's and processor architectures. If you need to create a build for different OS or architecture, add a new one to the end of the .build.sh script.

For example, this line creates a release for the linux OS and the amd64 architecture, and packages the output as a tar image:

do_build linux amd64 tar

The API of the do_build() function is basically do_build(GOOS, GOARCH, [tar|zip]) so you can pass any GOOS or GOARCH that go supports.

NOTE: For clarity, if the GOOS is set to darwin then the name macos gets used when creating build outputs.

How it works

The to command (defined in /dist/resources/shell_init_snippet.sh) is a shell script function which gets added to your shell init script (.bahsrc, .zshrc).

to() calls majortom (which gets installed in /usr/local/bin/majortom), and if majortom returns a path (which it will prefix with :) then to will cd to it.

You can see this behavior if you run majortom directly...

...versus running it via to...

About

Command line tool for navigating your file system using shortcuts.

Resources

License

Stars

Watchers

Forks

Packages

No packages published