0.4.3 • Published 5 years ago

skal v0.4.3

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Installation

npm install --global skal

Run skal in your terminal to initialize, follow the instructions.

Usage

Create and manage profiles under $HOME/.skal/profiles, use skal to switch between them.

GIF showing terminal usage

$ skal --help

  Manage separate shell configurations with ease.

  Usage
    $ skal [<command>]

  Commands
    new         Create a new profile
    list        List available profiles
    which       Print path to active profile
    edit        Edit profile or configuration

    Run without arguments for an interactive prompt to switch active profile.

  Options
    --help      Show help
    --version   Print version

Configuration

Configure by editing the $HOME/.skal/config.json file.

editor

Used as a convenience together with the edit command. Opens configuration or profiles in your editor of choice.

Put the command name you use in your terminal to open your preferred editor.

Example:

{
  "editor": "vi"
}

Format:

type Editor = string;

hooks

Hooks allows you to optionally run commands in response to switching from/to certain profiles.

Example:

{
  "hooks": {
    "onSwitchFrom": {
      "work": ["cp ~/.npmrcs/default ~/.npmrc"]
    },
    "onSwitchTo": {
      "work": ["cp ~/.npmrcs/work ~/.npmrc"]
    }
  }
}

Format:

interface Hooks {
  onSwitchFrom: HookMap;
  onSwitchTo: HookMap;
}

interface HookMap {
  [profileName: string]: string[];
}

Keep in mind that hooks are run in a child process.

Gotchas

Re-sourcing after profile switch

After running skal and switching the active profile, the currently active shell needs to be reloaded. The easiest way to do this is to open up a new terminal window or running something equivalent to source "\$HOME/.skal/active" again.

One way to get around this would be to create a local function re-sourcing after skal has finished.

Zsh

# ~/.zshrc

source "$HOME/.skal/active"

function skal() {
  command skal "$@"

  if (( $# == 0 )) then
    source "$HOME/.skal/active"
  fi
}

Fish

# ~/.config/fish/config.fish

source "$HOME/.skal/active"

function skal
  command skal $argv

  if test (count $argv) = 0
    source "$HOME/.skal/active"
  end
end

Hooks run in a Node child_process

Node's child_process module is used to execute hooks. This means that they run in a child process, separate from your currently running shell. Doing something like source "$HOME/.skal/active inside a hook won't be applied to your terminal shell.

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.4.0-canary.0

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago