Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim autocommand on write - pass full file path

Tags:

bash

vim

I want to execute a bash script whenever I save a file in Vim. The problem is I don't how can I, or if it's possible to pass the full path to the file, rather than just the file name, or relative path that was opened.

This is the code I'm using, it works, however only relative paths, which is useless to me.

autocmd BufWritePost * !~/.config/nvim/scripts/on_save.sh <afile> 

Is there any way to pass the full file path to the bash script?

like image 706
Maciej Krawczyk Avatar asked Jul 10 '18 19:07

Maciej Krawczyk


1 Answers

I found it:

autocmd BufWritePost * !~/.config/nvim/scripts/on_save.sh %:p  

The %:p does it

like image 166
Maciej Krawczyk Avatar answered Sep 18 '22 10:09

Maciej Krawczyk