Skip to content

Commit

Permalink
fix: fix fish shell script to properly escape variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mklabs committed Apr 26, 2016
1 parent af9da60 commit 6f9664e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
3 changes: 2 additions & 1 deletion examples/bower-complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

A [tabtab]() plugin to implement bash / zsh / fish completion to [Bower][]

![bower-complete](http://i.imgur.com/KH3VQWU.png)

## Install

npm install bower-complete -g
Expand All @@ -26,7 +28,6 @@ Depending on your shell:
**zsh**
![zsh][]


[Bower]: http://bower.io
[tabtab]: https://github.com/mklabs/node-tabtab
[bash]: https://raw.githubusercontent.com/mklabs/node-tabtab/master/docs/img/bash-install.png
Expand Down
2 changes: 1 addition & 1 deletion examples/bower-complete/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
"devDependencies": {
"semantic-release": "^4.3.5"
},
"version": "0.0.1"
"version": "0.0.2"
}
3 changes: 1 addition & 2 deletions lib/complete.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,10 @@ class Complete extends EventEmitter {
var parts = str.split(':');
var name = parts[0];
var desc = parts.slice(-1)[0];
debug('test:', parts, str);

return {
name: name,
description: desc || 'tabtab'
description: desc === name ? 'tabtab' : desc
};
}

Expand Down
2 changes: 1 addition & 1 deletion lib/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default class Installer {
out.write('`tabtab uninstall ' + name + '`');

if (this.template === 'fish') {
out.write('\n[ -f ' + filename + ']; and . ' + filename);
out.write('\n[ -f ' + filename + ' ]; and . ' + filename);
} else if (this.template === 'zsh') {
out.write('\n[[ -f ' + filename + ']] && . ' + filename);
} else {
Expand Down
14 changes: 6 additions & 8 deletions scripts/fish.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
###-begin-bower-completion-###
function _bower_completion
###-begin-{pkgname}-completion-###
function _{pkgname}_completion
set cmd (commandline -opc)
set cursor (commandline -C)
echo $cmd > /tmp/debug.log
echo $cursor>> /tmp/debug.log
set completions (eval env DEBUG=\""tabtab*\"" COMP_CWORD=\""$cmd\"" COMP_LINE=\""$cmd\"" COMP_POINT=\""$cursor\"" bower-complete completion --json)
set completions (eval env DEBUG=\"" \"" COMP_CWORD=\""$cmd\"" COMP_LINE=\""$cmd\"" COMP_POINT=\""$cursor\"" {completer} completion --json)

for completion in $completions
set cmd "node -pe \"'$completion'.split(':').join('\n')\""
set parts (eval $cmd)
complete -f -c bower -a "'$parts[1]'" -d "$parts[2]"
complete -f -c {pkgname} -a "'$parts[1]'" -d "$parts[2]"
echo $parts[1]
end
end

complete -d 'tabtab' -c bower -a "(eval _bower_completion)"
###-end-bower-completion-###
complete -d 'tabtab' -c {pkgname} -a "(eval _{pkgname}_completion)"
###-end-{pkgname}-completion-###

0 comments on commit 6f9664e

Please sign in to comment.