@eightshone/sshman
Version:
A simple cli ssh manager
32 lines (24 loc) • 734 B
text/typescript
import updateConfigs from "../../utils/updateConfigs";
import init from "../functions/init";
import sshConnection from "../functions/ssh";
async function reconnectCommand() {
// intialize the cli app
let { config, logs } = await init();
// exit if there are no recent servers
if (!config.recentServers.length) {
console.log("❌ There are no recent sessions");
return;
}
// get last config
const connectTo = config.recentServers[0];
console.log(
`🔄 Reconnecting to "${
connectTo.name ?? connectTo.username + "@" + connectTo.host
}"`
);
// update logs
await updateConfigs(config, logs, connectTo, false);
// connect
sshConnection(connectTo);
}
export default reconnectCommand;