Closed AlphaTechnolog closed 2 years ago
you are using the function correctly and it also works on my end. you have to be using at least commit 0fc5f457adf1c8d8b8fefc94ab9d940cacb275b6 for stdout/stderr returns
and for this usage specifically, here is how delta does it, which is my own prompt
ah lol, well now i tried with this code, and seems that it's working more: (based in delta xd)
local hilbish = require 'hilbish'
local function branch ()
local _, gitbranch = hilbish.run('git rev-parse --abbrev-ref HEAD', false)
return gitbranch:gsub('\n', '')
end
print(branch())
but i don't really know how to remove that 1 (that changes to 0 when the command fails), do you know how can i remove it?
if i remove gitbranch:gsub('\n', '')
, it hide the number, but when i remove it, it doesn't trim the last line space, but if i add it (the string.gsub), for some reason, it adds the 0 or the 1
gsub returns 2 arguments: the resulting string and the amount of matches
just wrap the return in a () like return (str:gsub('h', 'ay'))
and that will only take the 1st return value. in the context of where it is used in delta it only takes the 1st but i should maybe change it to be bug prone
but also: can i recommend promptua, it would actually be nice to get some more stuff added to that.
tysm
Hello! :wave:
I'm trying to make support to the git branch in my prompt, but i tried using hilbish.run and trying to get the stdout and don't works :c
here is my code:
but that function always returns nil, and print the stdout in the terminal without catching it in my variable, here is the demonstration:
Idk if i'm doing smth wrong, please tell me if i'm doing something wrong lol