~razzi/fish-functions

8a9d7354c30d4c7118e87321631305d51e417877 — Razzi Abuissa 2 months ago 4044d5d
New function ensure-trailing-newline used in gitignore.fish
2 files changed, 8 insertions(+), 1 deletions(-)

A functions/ensure-trailing-newline.fish
M functions/gitignore.fish
A functions/ensure-trailing-newline.fish => functions/ensure-trailing-newline.fish +5 -0
@@ 0,0 1,5 @@
function ensure-trailing-newline --argument file
    if test -n (tail -c 1 $file)
        echo >> $file
    end
end

M functions/gitignore.fish => functions/gitignore.fish +3 -1
@@ 1,3 1,5 @@
function gitignore --argument pattern
    echo $pattern >>(git root)/.gitignore
    set gitignore_file (git root)/.gitignore
    ensure-trailing-newline $gitignore_file
    echo $pattern >> $gitignore_file
end