Skip to content

Commit

Permalink
Merge pull request #140 from thshdw/fix-editor-settings
Browse files Browse the repository at this point in the history
Feature add open_in and default_theme. Fix editor settings
  • Loading branch information
Matt Turner committed Nov 6, 2015
2 parents da68154 + addb62a commit 8731643
Show file tree
Hide file tree
Showing 5 changed files with 313 additions and 137 deletions.
175 changes: 155 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,190 @@ A simple SSH shortcut menu for OS X

![How Shuttle works](https://raw.github.com/fitztrev/shuttle/gh-pages/img/how-shuttle-works.gif)

***Sidenote***: *Many people ask, so here's how I have [my terminal setup](https://github.com/fitztrev/shuttle/wiki/My-Terminal-Prompt).*
**Sidenote**: *Many people ask, so here's how I have [my terminal setup](https://github.com/fitztrev/shuttle/wiki/My-Terminal-Prompt).*

## Installation

1. Download [Shuttle](http://fitztrev.github.io/shuttle/)
2. Copy to Applications

## Customization
## JSON Path Change

The default, out-of-the-box configuration should be good enough to get started. However, if you're looking to customize the appearance further, here are a few advanced tips.
In your home directory create a file called ```~/.shuttle.path```
In this file should be a single line with the path to the JSON settings file.

### Disabling `~/.ssh/config` hosts
```
/Users/thshdw/Dropbox/shuttle/shuttle.json
```
shuttle will read ```~/.shuttle.path``` first and use its contents as the path to your JSON file.

## JSON Options
### Global settings
#### ```"editor": "VALUE",```
_This changes the app that opens settings.json for editing (Global Setting)_

Possible values are ```default```, ```nano```, ```vi```, ```vim``` or any terminal based editor.
```default``` opens settings.json in whatever app is registered as the default for extension ```.json```
```
"editor": "vim",
```
would open ```~/.shuttle.json``` in vim

----

#### ```"launch_at_login": VALUE,```
_This allows you to flag the shuttle.app to start automatically (Global Setting)_

Possible values are ```true``` or ```false```

----

#### ```"terminal": "VALUE",```
_This allows you to set the default terminal (Global Setting)_

Possible values are ```Terminal.app``` or ```iTerm```

----

#### ```"iTerm_version": "VALUE",```
_This changes the applescripts for iTerm (Global Setting)_

Possible values are ```stable``` or ```nightly```

**If ```terminal``` is set to ```iTerm``` this setting is mandatory**

_This setting is ignored if your terminal is set to ```Terminal.app```_

----

#### ```"default_theme": "Homebrew",```
_This sets the Terminal theme for all windows. (Global Setting)_

Possible values are the Profile names in your terminal preferences. iTerm ships with one Profile named "Default". OS X Terminal ships with several. To see the names see the preferences area of the terminal you are using.

In iTerm the profile names are case sensitive.

**Please ensure the theme names you set are valid. If shuttle passes theme "Dagobah" and it does not exist in iTerm or OS X Terminal then your command won't run. This is because the applescripts are not making any checks to see if the theme you passed actually exists within the terminal application.**

This setting can be overwritten by the command level ```"theme"``` settings

----

#### ```"open_in": "VALUE",```
_This changes the default action for how commands are opened (Global Setting)_

Possible values are ```tab``` or ```new```.

```tab``` opens the command in the active terminal in a new tab.

```new``` opens the command in a new window.

This setting can be overwritten by the command level ```"inTerminal"``` settings

----

#### ```"show_ssh_config_hosts": VALUE,```
_This changes parsing ssh config. By default, Shuttle will parse your ```~/.ssh/config``` file for hosts. (Global Setting)_

Possible values are ```false``` or ```true```

----

By default, Shuttle will parse your `~/.ssh/config` file for hosts.
#### ```"ssh_config_ignore_hosts": ["VALUE", "VALUE"],```
_This will ignore hosts in the ssh config. (Global Setting)_

##### To disable all ~/.ssh/config entries:
Possible values are the hosts in your config that you want to ignore. If you had github.com and git.example.com in your ssh config, to ignore them you set:

```"ssh_config_ignore_hosts": ["github.com", "git.example.com"],```

----

#### ```"ssh_config_ignore_keywords": ["VALUE"],```
_This will ignore keywords in your ssh config. (Global Setting)_

Possible values are the keywords in your ssh config that you want to ignore.

----

**Additional ssh config customization**
#### Nested menus for `~/.ssh/config` hosts

##### Create a menu item at "work" > "servers" > "web01"

```
"show_ssh_config_hosts": false,
Host work/servers/web01
HostName [email protected]
```

#### Disable specific hosts:
\- *or* -

```
"ssh_config_ignore_hosts": ["github.com", "git.example.com"],
Host gandalf
# shuttle.name = work/servers/web01 (webserver)
HostName [email protected]
```

#### Disable hosts that contain a keyword:
### Command level settings
_Command level settings are unique to your command and will overwrite the Global setting equivalent_

#### ```"cmd": "VALUE"```
_This is the command / script that will be launched in the terminal. (Command setting)_

Where Value is a command or script.
```
"ssh_config_ignore_keywords": ["git"],
"cmd": "ps aux | grep [s]sh"
```
Would check for ssh processes.

### Nested menus for `~/.ssh/config` hosts
----

#### Create a menu item at "work" > "servers" > "web01"
#### ```"name": "VALUE"```
_This sets the text that will appear in shuttles drop down menu. (Command setting)_

Were Value is the text you want to see in the drop down menu for this command.
```
Host work/servers/web01
HostName [email protected]
"name": "SSH to my wordpress blog"
```
\- *or* -

This value can also set the title of the terminal window if ```"title" :"VALUE"``` is not set.

----

#### ```"inTerminal": "VALUE",```
_This sets how command will open in the terminal window. (Command setting)_

Possible values are ```new```, ```tab```, or ```current```

```new``` opens the command in a new terminal window.

```tab``` opens the command in the active terminal window in a new tab.

```current``` opens the command in the active terminal's window.

When using using ```current``` I recommend that you wrap the command in some user input like this:

```
Host gandalf
# shuttle.name = work/servers/web01 (webserver)
HostName [email protected]
echo "are you sure y/n"; read sure; if [ "$sure" == "y" ]; then echo "running command" && ps aux | grep [s]sh; else echo "exiting..."; fi
```

Do this as a precaution as it could be possible to run a command on the wrong host.

----

#### ```"theme": "VALUE",```
_This sets the theme for the terminal window. (Command setting)_

Possible values are the profile names for iTerm or OS X Terminal.

If ```"theme"``` is not set and ```"default_theme"``` is not set then shuttle passes Profile ```Default``` for iTerm and Profile ```basic``` for OS X terminal.

----

#### ```"title": "VALUE"```
_This sets the text that will appear in the terminal's title bar. (Command setting)_

Where VALUE is the text you want to set in the terminals title bar.

If ```title``` is missing shuttle uses the menu's name and sets this as ```title```

## Roadmap

Expand Down
13 changes: 9 additions & 4 deletions Shuttle/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@

NSStatusItem *statusItem;
NSString *shuttleConfigFile;
NSString *shuttleJSONPath;

// This is for the JSON File
NSDate *configModified;
NSDate *sshConfigUser;
NSDate *sshConfigSystem;

NSString *terminalPref;
NSString *editorPref;
NSString *iTermVersion;
//Global settings Pref in the JSON file.
NSString *shuttleJSONPathPref; //alternate path the JSON file
NSString *terminalPref; //which terminal will we be using iTerm or Terminal.app
NSString *editorPref; //what app opens the JSON fiile vi, nano...
NSString *iTermVersionPref; //which version of iTerm nightly or stable
NSString *openInPref; //by default are commands opened in tabs or new windows.
NSString *themePref; //The global theme.

//used to gather ssh config settings
NSMutableArray* shuttleHosts;
NSMutableArray* ignoreHosts;
NSMutableArray* ignoreKeywords;
Expand Down
Loading

0 comments on commit 8731643

Please sign in to comment.