You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a snippet where clicking the 'filename' module copies the text into my clipboard. I love it and use it intensively:
lualine_b = {
{
'filename',
path = 1,
on_click = function(_nb_of_clicks, button, _modifiers)
-- local bufnr = vim.fn.bufnr('%')
local filename = vim.fn.bufname('%') -- vim.fn.getreg('%')
local copy_fullpath = (button == 'r')
if copy_fullpath then
filename = vim.fn.fnamemodify(filename, ':p')
end
print('To clipboard: ' .. filename)
clip.copy(filename)
end,
},
},
I would like to do the same for the git and copy the branch name into the clipboard. Instead of fetching the git branch myself, I wonder if there is a generic way to call the lualine module and retreive its generated text, something like require'lualine'.get_module('git'):content()
lualine_a = {
{
'branch',
-- truncate too long branch names !
fmt = function(str)
return str:sub(1, 20)
end,
on_click = function(_nb_of_clicks, _button, _modifiers)
local branch_name = 'BRANCH_PLACEHOLDER' -- <- HOW TO get this value from lualine ?
clip.copy(branch_name)
print('To clipboard: ' .. branch_name)
-- the
end,
},
},
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a snippet where clicking the 'filename' module copies the text into my clipboard. I love it and use it intensively:
I would like to do the same for the git and copy the branch name into the clipboard. Instead of fetching the git branch myself, I wonder if there is a generic way to call the lualine module and retreive its generated text, something like
require'lualine'.get_module('git'):content()
Beta Was this translation helpful? Give feedback.
All reactions