Conversation
|
This is climate if anyone is wondering :) |
share/completions/climate.fish
Outdated
| @@ -0,0 +1,82 @@ | |||
| # fish completion for climate | |||
There was a problem hiding this comment.
This comment is useless. You should probably write a short description of the tool with a link to the project's man page (or github) instead.
There was a problem hiding this comment.
Yeah. While you're at it, ditch the first line. The rest is okay, and I appreciate the link!
share/completions/climate.fish
Outdated
| # Meta | ||
| complete -f -n '__fish_climate_already_has_argument' -c climate -a help -d 'Show help' | ||
| complete -f -n '__fish_climate_already_has_argument' -c climate -a update -d 'Update your climate install' | ||
| complete -f -n '__fish_climate_already_has_argument' -c climate -a uninstall -d 'uninstall your climate installi' |
There was a problem hiding this comment.
Typo: uninstall your climate installi → Uninstall your climate install.
Maybe use something shorter like Uninstall climate.
share/completions/climate.fish
Outdated
| complete -f -n '__fish_climate_already_has_argument' -c climate -a download-dir -d 'Download dir from server' | ||
| complete -n '__fish_climate_already_has_argument' -c climate -a upload -d 'Upload to server' | ||
| complete -f -n '__fish_climate_already_has_argument' -c climate -a ssh-mount -d 'Mount a remote path' | ||
| complete -n '__fish_climate_already_has_argument' -c climate -a ssh-unmount -d 'nmount a ssh mount' |
share/completions/climate.fish
Outdated
| complete -f -c climate -n '__fish_is_git_repository and __fish_climate_already_has_argument' -a user-stats -d 'Calculate total contribution for a user' | ||
|
|
||
| # Performance | ||
| complete -f -n '__fish_climate_already_has_argument' -c climate -a overview -d 'Display an performance overviewj' |
There was a problem hiding this comment.
Display an performance overviewj → Display a performance overview?
share/completions/climate.fish
Outdated
| # Network | ||
| complete -f -n '__fish_climate_already_has_argument' -c climate -a speedtest -d 'Test your network speed' | ||
| complete -f -n '__fish_climate_already_has_argument' -c climate -a local-ip -d 'Retrieve your local ip address' | ||
| complete -f -n '__fish_climate_already_has_argument' -c climate -a is-online -d 'Verify if you''re online' |
There was a problem hiding this comment.
'Verify if you''re online' → 'Verify if you\'re online'
> echo 'Verify if you''re online'
'Verify if youre online'There was a problem hiding this comment.
Here, fish concatenates the two strings. It's useful when you want to expand variables:
> set var 'Hi there!'
> echo 'Did you say "'$var'"?'Did you say "Hi there!"?
It works like a charm with lists as well:
> set var 'Hi there!' 'Hello world!'
> echo 'Did you say "'$var'"?'Did you say "Hi there!"? Did you say "Hello world!"?
share/completions/climate.fish
Outdated
|
|
||
| function __fish_is_git_repository | ||
| git rev-parse --is-inside-work-tree ^/dev/null >/dev/null | ||
| return $status |
There was a problem hiding this comment.
You don't need return $status.
share/completions/climate.fish
Outdated
|
|
||
| function __fish_climate_already_has_argument | ||
| set cmd (commandline -opc) | ||
| if not set -q cmd[2] |
There was a problem hiding this comment.
You don't need the if statement with the returns.
Just write: not set -q cmd[2]
share/completions/climate.fish
Outdated
| CE3F end | ||
|
|
||
| function __fish_climate_already_has_argument | ||
| set cmd (commandline -opc) |
There was a problem hiding this comment.
You want a local variable here: set → set -l
share/completions/climate.fish
Outdated
| return $status | ||
| end | ||
|
|
||
| function __fish_climate_already_has_argument |
There was a problem hiding this comment.
I'm a bit confused by what this function is supposed to do given its name.
__fish_climate_already_has_argument implies that it should return 0 (true) if the command line has an argument but it clearly does the exact opposite. Have I missed something?
There was a problem hiding this comment.
I renamed the function to __fish_climate_has_no_argument.
72b79ed to
a501aac
Compare
share/completions/climate.fish
Outdated
| complete -n '__fish_climate_has_no_argument' -c climate -a ssh-unmount -d 'Unmount a ssh mount' | ||
|
|
||
| # git | ||
| complete -f -c climate -n '__fish_is_git_repository and __fish_climate_has_no_argument' -a undo-commit -d 'Undo the latest commit' |
There was a problem hiding this comment.
This doesn't work because of a missing ";" - __fish_is_git_repository; and. The way it is now, __fish_is_git_repository gets the rest as argument, and __fish_climate_has_no_argument is never executed.
share/completions/climate.fish
Outdated
| # but complex combination of Linux commands. | ||
| # The tool can be found at https://github.com/adtac/climate | ||
|
|
||
| function __fish_is_git_repository |
There was a problem hiding this comment.
This might be useful elsewhere, so it should probably be extracted into its own function file. Not a priority though.
There was a problem hiding this comment.
It's already implemented in git.fish. Maybe split it?
There was a problem hiding this comment.
That one prints the working directory, though completion conditions are implicitly silenced.
Yeah, we should extract it. I can do that later though.
There was a problem hiding this comment.
I added __fish_is_git_repository.fish into share/functions folder (also into /usr/share/fish/functions, .config/fish/functions) and I get __fish_is_git_repository: command not found
share/completions/climate.fish
Outdated
| @@ -0,0 +1,82 @@ | |||
| # fish completion for climate | |||
There was a problem hiding this comment.
Yeah. While you're at it, ditch the first line. The rest is okay, and I appreciate the link!
|
The failing tests here are a result of bad timing - this is based on a broken master. Nothing to worry about here. |
| @@ -0,0 +1,3 @@ | |||
| function __fish_is_git_repository --discription 'Check if current directory is a git repository' | |||
There was a problem hiding this comment.
You've made a typo, that's why it's not loading: --description.
There was a problem hiding this comment.
fixed the typo but still not loading.
There was a problem hiding this comment.
That's strange... it works with me.
Have you tried to do a source path/to/__fish_is_git_repository.fish? Did you put it in ~/.config/fish/functions with the typo fixed to test it?
There was a problem hiding this comment.
Now it works after I did source /usr/share/fish/functions/__fish_is_git_repository.fish. Perhaps /usr/share/fish/functions/is only sourced at login ?
There was a problem hiding this comment.
It's loaded when you request it for the first time. It sources the first __fish_is_git_repository.fish it finds the directories listed in fish_function_path.
> echo $fish_function_path
/home/clement/.config/fish/functions /etc/fish/functions /usr/share/fish/vendor_functions.d /usr/share/fish/functionsMy guess is that you have a file named __fish_is_git_repository.fish without the correction in one of the directories listed before /usr/share/fish/functions.
|
Thx. Merged as a5e8b81. |
No description provided.