I want to use unix command on save. Command return file path. Like below:
pseudo code
:w !command
# I name this command 'mami'
$ MAMI_DIR=~/work echo $MAMI_DIR/$(date "+%Y-%m-%d-%H-%M-%S").txt
#=> /Users/sane/work/2012-09-13-01-58-01.txt
https://gist.github.com/3713132
# my expectation
:w !mami
#=> to save /Users/sane/work/2012-09-13-01-58-01.txt
# or
:mami
#=> to save /Users/sane/work/2012-09-13-01-58-01.txt
But my exec is only return string or errors:
:w !mami
#=> This show only file path, /Users/sane/work/2012-09-13-01-58-01.txt and said "press key"
:w !$(MAMI_DIR=~/work echo $MAMI_DIR/$(date "+%Y-%m-%d-%H-%M-%S").txt)
#=> This return value 127
How do I achieve this? Is this the area of vim script? Please give me suggestion.
autocmd BufWritePost {pattern} !mami: running command after you save file, not running command to get filename to save to. Be careful with wording.