How to get output of a shell command async without any dependency

Hi,
I’ve had the need for a plugin, to get the current git branch I’m in (I don’t really care to check if I’m in the correct cwd). I’m aware of system but it is synchronous. I’ve tried to do some functions with jobstart but I wasn’t very successful.

What I’m locking for:

local branch = get_git_branch()
print(branch) -- Prints current branch

Look at plenary job.

vim.system (in 0.10)