Skip to content

Commit

Permalink
Merge pull request #51 from cmbankester/master
Browse files Browse the repository at this point in the history
Fish Shell Completions
  • Loading branch information
jamesob committed Jan 23, 2016
2 parents 3c85589 + a549ba6 commit 3c31a79
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ services:
- docker

before_install:
- wget http://ftp.debian.org/debian/pool/main/s/shellcheck/shellcheck_0.3.7-1_amd64.deb
- ar x shellcheck_0.3.7-1_amd64.deb
- wget http://ftp.debian.org/debian/pool/main/s/shellcheck/shellcheck_0.3.7-5_amd64.deb
- ar x shellcheck_0.3.7-5_amd64.deb
- tar xvf data.tar.xz
- cp ./usr/bin/shellcheck .

env:
- PATH=$PATH:$(pwd)

script:
script:
- make lint
- SHELL_CMD='-c ./run_tests.sh' make bash zsh
- SHELL_CMD='-c ./run_tests.fish' make fish
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ There are no dependencies other than `bash`. Desk is explicitly tested with `bas
Usage:

desk
List the current desk and any associated aliases. If no desk
List the current desk and any associated aliases. If no desk
is being used, display available desks.
desk init
Initialize desk configuration.
Expand All @@ -43,7 +43,7 @@ Usage:
desk run <desk-name> <cmd>
Run a command within a desk's environment then exit. Think '$SHELL -c'.
desk edit [desk-name]
Edit (or create) a deskfile with the name specified, otherwise
Edit (or create) a deskfile with the name specified, otherwise
edit the active deskfile.
desk help
Show this text.
Expand Down Expand Up @@ -122,14 +122,24 @@ or by manually adding shell scripts into your deskfiles directory (by default `~

### Enabling shell extensions

**NB**: Shell extensions are automatically enabled if Desk is installed via Homebrew.

#### Using bash

0. Add `source /path/to/desk/repo/shell_plugins/bash/desk` to your `.bashrc`.

#### Using fish

```fish
mkdir -p ~/.config/fish/completions
cp /path/to/desk/repo/shell_plugins/fish/desk.fish ~/.config/fish/completions
```

#### Using zsh

0. Add `fpath=(/path/to/desk/repo/shell_plugins/zsh $fpath)` to your `.zshrc`.


Optionally, use one of the zsh plugin frameworks mentioned below.

#### Using [oh-my-zsh](http://ohmyz.sh/)
Expand All @@ -141,12 +151,12 @@ or
0. `cd ~/.oh-my-zsh/custom/plugins`
0. `git clone git@github.com:jamesob/desk.git /tmp/desk && cp -r /tmp/desk/shell_plugins/zsh desk`
0. Add desk to your plugin list

#### Using [Antigen](https://github.com/zsh-users/antigen)

0. Add `antigen bundle jamesob/desk shell_plugins/zsh` to your `.zshrc`
0. Open a new terminal window. Antigen will clone the desk repo and add it to your path.

#### Using [zgen](https://github.com/tarjoilija/zgen)

0. Add `zgen load jamesob/desk shell_plugins/zsh` to your `.zshrc` with your other load commands
Expand Down
40 changes: 40 additions & 0 deletions shell_plugins/fish/desk.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# desk.fish - desk completions for fish shell
#
# To install the completions:
# mkdir -p ~/.config/fish/completions
# cp desk.fish ~/.config/fish/completions

function __fish_desk_no_subcommand --description 'Test if desk has yet to be given a subcommand'
for i in (commandline -opc)
if contains -- $i init list ls . go run edit help version
return 1
end
end
return 0
end

# desk
complete -c desk -f -n '__fish_desk_no_subcommand' -a init -d 'Initialize desk configuration'

# desk list|ls
complete -c desk -f -n '__fish_desk_no_subcommand' -a "ls list" -d 'List all desks along with a description'
complete -c desk -A -f -n '__fish_seen_subcommand_from ls list' -l only-names -d 'List only the names of the desks'
complete -c desk -A -f -n '__fish_seen_subcommand_from ls list' -l no-format -d "Use ' - ' to separate names from descriptions"

# desk go|.
complete -c desk -f -n '__fish_desk_no_subcommand' -a "go ." -d 'Activate a desk. Extra arguments are passed onto shell'
complete -c desk -A -f -n '__fish_seen_subcommand_from . go' -a "(desk ls --only-names)" -d "Desk"

# desk run
complete -c desk -f -n '__fish_desk_no_subcommand' -a run -d 'Run a command within a desk\'s environment then exit'
complete -c desk -A -f -n '__fish_seen_subcommand_from run' -a '(desk ls --only-names)' -d "Desk"

# desk edit
complete -c desk -f -n '__fish_desk_no_subcommand' -a edit -d 'Edit (or create) a deskfile with the name specified, otherwise edit the active deskfile'
complete -c desk -A -f -n '__fish_seen_subcommand_from edit' -a '(desk ls --only-names)' -d "Desk"

# desk help
complete -c desk -f -n '__fish_desk_no_subcommand' -a help -d 'Show help text'

# desk version
complete -c desk -f -n '__fish_desk_no_subcommand' -a version -d 'Show version information'

0 comments on commit 3c31a79

Please sign in to comment.