Add a command for installing the CLI

This commit is contained in:
Max Brunsfeld 2022-04-19 16:15:00 -07:00 committed by Antonio Scandurra
parent eee1cec3d4
commit fbd1afc51f
4 changed files with 49 additions and 39 deletions

View file

@ -38,7 +38,8 @@ actions!(
DebugElements,
OpenSettings,
IncreaseBufferFontSize,
DecreaseBufferFontSize
DecreaseBufferFontSize,
InstallCommandLineTool,
]
);
@ -66,6 +67,20 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
cx.refresh_windows();
});
});
cx.add_global_action(move |_: &InstallCommandLineTool, cx| {
cx.spawn(|cx| async move {
let path = cx.platform().path_for_auxiliary_executable("cli")?;
let link_path = "/usr/local/bin/zed";
smol::fs::unix::symlink(link_path, path.as_path()).await?;
log::info!(
"created symlink {} -> {}",
link_path,
path.to_string_lossy()
);
Ok::<_, anyhow::Error>(())
})
.detach();
});
cx.add_action({
let app_state = app_state.clone();
move |_: &mut Workspace, _: &OpenSettings, cx: &mut ViewContext<Workspace>| {