bash - How to combine multiple commands when piped through xargs? -
i have following command:
!nohup fswatch -o ~/notes -e "\\.git.*" | xargs -n 1 -i {} sh ~/auto_commit.sh > /dev/null 2>&1 &
i want inline what's in auto_commit.sh
file:
cd ~/notes git add -a git commit --allow-empty-message -am ""
is there way this?
the solution ended was:
nohup fswatch -o ~/notes -e "\\.git.*" | xargs -n 1 -i {} sh -c 'cd ~/notes; git add -a; git commit --allow-empty-message -m ""' > /dev/null 2>&1 &'
thanks barnwell , whjm help.
also, vim script, formatting had different (in case others looking solution similar problem):
autocmd bufwinenter *.note silent! execute '!nohup fswatch -o . -e "\\.git.*" | xargs -n 1 -i {} sh -c ''git add -a; git commit --allow-empty-message -m ""'' > /dev/null 2>&1 &'
note barnwell wrong {..}
not subshell, , sh -c
command expects string. curly braces unnecessary, , in case added undesired git commit message.
also, when used in vim script vim execute
function, entire command had wrapped in quotes. doubling on single quotes (not double quotes mind you) allowed execute
function accept argument normal string, , things worked fine.
Comments
Post a Comment