fuzzel.lua 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. return {
  2. selector_cmd = function()
  3. return {
  4. command = "rofi",
  5. args = { "-dmenu", "-p", "Project: " },
  6. }
  7. end,
  8. editor_cmd = function(path, class)
  9. local dirName = path:match("([^/]+)$")
  10. -- Sanitize dirName for tmux session name (remove special chars)
  11. local tmuxSession = dirName:gsub("[^a-zA-Z0-9_]", "_")
  12. local tmuxCmd = string.format(
  13. [[ tmux has-session -t %s 2>/dev/null && tmux attach -t %s || tmux new -c %s -s %s 'nvim %s' \; split-window -h -c %s ]],
  14. tmuxSession,
  15. tmuxSession,
  16. path,
  17. tmuxSession,
  18. path,
  19. path
  20. )
  21. return {
  22. command = "kitty",
  23. args = {
  24. "-d",
  25. path,
  26. "-T",
  27. class,
  28. "--class",
  29. class,
  30. "sh",
  31. "-c",
  32. tmuxCmd,
  33. },
  34. }
  35. end,
  36. format_project_title = function(path)
  37. -- Extract project name for better display
  38. -- local projectName = path:match("([^/]+)$") or path
  39. return "📘 " .. path
  40. end,
  41. extract_path_from_title = function(title)
  42. -- Return back the path: 📘 work/project_1 -> work/project_1
  43. return title:gsub("^📘%s*", ""):gsub("\n$", "")
  44. end,
  45. -- Add error handling function
  46. handle_error = function(err)
  47. io.stderr:write("Error: " .. tostring(err) .. "\n")
  48. return false
  49. end,
  50. }