refactor: get rid of obsolete SSH stuff
This commit is contained in:
parent
d4ecaa56e5
commit
f6a7cc0e5c
1 changed files with 0 additions and 51 deletions
|
|
@ -120,54 +120,3 @@ vim.keymap.set("n", "<leader>p", ":TimerStart 30m<CR>", { desc = "Pomodoro" })
|
||||||
vim.keymap.set("n", "fc", function()
|
vim.keymap.set("n", "fc", function()
|
||||||
require("treesitter-context").go_to_context(vim.v.count1)
|
require("treesitter-context").go_to_context(vim.v.count1)
|
||||||
end, { silent = true })
|
end, { silent = true })
|
||||||
|
|
||||||
-- Claude wrote this SSH clusterfuck
|
|
||||||
local function get_ssh_hosts()
|
|
||||||
local known_hosts_path = vim.fn.expand("~/.ssh/known_hosts")
|
|
||||||
local hosts = {}
|
|
||||||
|
|
||||||
if vim.fn.filereadable(known_hosts_path) == 1 then
|
|
||||||
local file = io.open(known_hosts_path, "r")
|
|
||||||
if file then
|
|
||||||
for line in file:lines() do
|
|
||||||
-- Parse known_hosts format: hostname[,hostname] key-type key [comment]
|
|
||||||
local host = line:match("^([^%s,]+)")
|
|
||||||
if host and not host:match("^#") and not host:match("^%|") then
|
|
||||||
-- Remove bracketed IP addresses and ports
|
|
||||||
host = host:gsub("%[(.-)%].*", "%1")
|
|
||||||
host = host:gsub(":.*", "")
|
|
||||||
if host ~= "" and not vim.tbl_contains(hosts, host) then
|
|
||||||
table.insert(hosts, host)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
file:close()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return hosts
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>ss", function()
|
|
||||||
local hosts = get_ssh_hosts()
|
|
||||||
|
|
||||||
if #hosts == 0 then
|
|
||||||
vim.notify("No SSH hosts found in ~/.ssh/known_hosts", vim.log.levels.WARN)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
require("fzf-lua").fzf_exec(hosts, {
|
|
||||||
prompt = "SSH target: ",
|
|
||||||
actions = {
|
|
||||||
["default"] = function(selected)
|
|
||||||
if selected and #selected > 0 then
|
|
||||||
local host = selected[1]
|
|
||||||
local ssh_url = "oil-ssh://" .. host .. "/"
|
|
||||||
require("oil").open(ssh_url)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
-- winopts = { height = 0.2, width = 0.2, row = 0.5, border = "single", treesitter = true },
|
|
||||||
winopts = { height = 0.3, width = 0.5, row = 0.5, title = "Where do you want to go today?", backdrop = 100 },
|
|
||||||
})
|
|
||||||
end, { desc = "SSH to host" })
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue