Skip to content

Commit

Permalink
Add ability to autosave functions at the end of funced
Browse files Browse the repository at this point in the history
  • Loading branch information
Thom Chiovoloni committed Jan 17, 2018
1 parent 42fa841 commit 243839c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions doc_src/funced.txt
Expand Up @@ -16,3 +16,5 @@ If there is no function called `NAME` a new function will be created with the sp
- `-e command` or `--editor command` Open the function body inside the text editor given by the command (for example, `-e vi`). The special command `fish` will use the built-in editor (same as specifying `-i`).

- `-i` or `--interactive` Force opening the function body in the built-in editor even if `$VISUAL` or `$EDITOR` is defined.

- `-s` or `--save` Automatically save the function after successfully editing it.
7 changes: 6 additions & 1 deletion share/functions/funced.fish
Expand Up @@ -12,7 +12,7 @@ function __funced_md5
end

function funced --description 'Edit function definition'
set -l options 'h/help' 'e/editor=' 'i/interactive'
set -l options 'h/help' 'e/editor=' 'i/interactive' 's/save'
argparse -n funced --min-args=1 --max-args=1 $options -- $argv
or return

Expand Down Expand Up @@ -65,6 +65,9 @@ function funced --description 'Edit function definition'
echo -n $cmd | fish_indent | read -lz cmd
eval "$cmd"
end
if set -q _flag_save
funcsave $funcname
end
return 0
end

Expand Down Expand Up @@ -115,6 +118,8 @@ function funced --description 'Edit function definition'
continue
end
echo (_ "Cancelled function editing")
else if set -q _flag_save
funcsave $funcname
end
end
break
Expand Down

0 comments on commit 243839c

Please sign in to comment.