diff options
| -rw-r--r-- | dotfiles/fish/conf.d/quickedit.fish | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/dotfiles/fish/conf.d/quickedit.fish b/dotfiles/fish/conf.d/quickedit.fish index b3ed9ab..c805bee 100644 --- a/dotfiles/fish/conf.d/quickedit.fish +++ b/dotfiles/fish/conf.d/quickedit.fish @@ -1,24 +1,21 @@ set -gx QUICKEDIT_DIR ~/QuickEdit -function quickedit - set -l prev_dir (pwd) - set -l grep_pattern . +function quickedit::postaction + set -l file_path $argv[1] + set -l make_run 0 - if test (count $argv) -gt 0 - set grep_pattern $argv[1] + if test -f Makefile + make + set make_run 1 end - cd $QUICKEDIT_DIR - set -l file_path (find -L . -type f -not -path '*/.*' | grep "$grep_pattern" | fzf) - $EDITOR $file_path - # Go to git toplevel dir (if exists) cd (dirname $file_path) set -l git_dir (git rev-parse --show-toplevel 2>/dev/null) if test $status -eq 0 cd $git_dir end - if test -f Makefile + if not $make_run -eq 1 -a test -f Makefile make end if test -d .git @@ -26,7 +23,21 @@ function quickedit git pull git push end +end + +function quickedit + set -l prev_dir (pwd) + set -l grep_pattern . + + if test (count $argv) -gt 0 + set grep_pattern $argv[1] + end + + cd $QUICKEDIT_DIR + set -l file_path (find -L . -type f -not -path '*/.*' | grep "$grep_pattern" | fzf) + $EDITOR $file_path + quickedit::postaction $file_path cd $prev_dir end |
