feat: Update 3 files
This commit is contained in:
@@ -197,7 +197,13 @@ namespace dropshell
|
||||
{
|
||||
debug << "Ensuring dropshell autocomplete is registered in ~/.bashrc..." << std::endl;
|
||||
|
||||
std::filesystem::path bashrc = localpath::current_user_home() +"/.bashrc";
|
||||
std::string home = localpath::current_user_home();
|
||||
if (home.empty()) {
|
||||
error << "Could not determine user home directory" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::filesystem::path bashrc = home + "/.bashrc";
|
||||
|
||||
std::string autocomplete_script = R"(
|
||||
#---DROPSHELL AUTOCOMPLETE START---
|
||||
@@ -212,10 +218,9 @@ _dropshell_completions() {
|
||||
return 0
|
||||
}
|
||||
|
||||
alias ds='dropshell'
|
||||
|
||||
# Register the completion function
|
||||
# Register the completion function for both dropshell and ds
|
||||
complete -F _dropshell_completions dropshell
|
||||
complete -F _dropshell_completions ds
|
||||
#---DROPSHELL AUTOCOMPLETE END---
|
||||
)";
|
||||
|
||||
@@ -223,12 +228,56 @@ complete -F _dropshell_completions dropshell
|
||||
return 0;
|
||||
}
|
||||
|
||||
int configure_symlink()
|
||||
{
|
||||
debug << "Creating symbolic link 'ds' for dropshell..." << std::endl;
|
||||
|
||||
std::string localbin_str = localpath::user_local_bin();
|
||||
if (localbin_str.empty()) {
|
||||
error << "Could not determine user local bin directory" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::filesystem::path localbin(localbin_str);
|
||||
std::filesystem::create_directories(localbin);
|
||||
|
||||
std::filesystem::path dropshell_path = localbin / "dropshell";
|
||||
std::filesystem::path ds_link = localbin / "ds";
|
||||
|
||||
// Remove old alias or link if it exists
|
||||
if (std::filesystem::exists(ds_link)) {
|
||||
std::filesystem::remove(ds_link);
|
||||
}
|
||||
|
||||
// Create symbolic link from ds to dropshell
|
||||
if (std::filesystem::exists(dropshell_path)) {
|
||||
std::filesystem::create_symlink("dropshell", ds_link);
|
||||
debug << "Created symbolic link: " << ds_link << " -> dropshell" << std::endl;
|
||||
} else {
|
||||
warning << "dropshell not found in ~/.local/bin, skipping symlink creation" << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int configure_localbin()
|
||||
{
|
||||
debug << "Ensuring ~/.local/bin is in the ~/.bashrc path..." << std::endl;
|
||||
|
||||
std::filesystem::path bashrc = localpath::current_user_home() +"/.bashrc";
|
||||
std::filesystem::path localbin = localpath::current_user_home() + "/.local/bin";
|
||||
std::string home = localpath::current_user_home();
|
||||
if (home.empty()) {
|
||||
error << "Could not determine user home directory" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::filesystem::path bashrc = home + "/.bashrc";
|
||||
std::string localbin_str = localpath::user_local_bin();
|
||||
if (localbin_str.empty()) {
|
||||
error << "Could not determine user local bin directory" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::filesystem::path localbin(localbin_str);
|
||||
std::filesystem::create_directories(localbin);
|
||||
// check if already in path
|
||||
const char* env_p = std::getenv("PATH");
|
||||
@@ -247,6 +296,7 @@ complete -F _dropshell_completions dropshell
|
||||
maketitle("Updating dropshell on this computer...");
|
||||
|
||||
configure_localbin();
|
||||
configure_symlink();
|
||||
configure_autocomplete();
|
||||
|
||||
// determine path to this executable
|
||||
|
@@ -95,6 +95,14 @@ namespace dropshell
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string user_local_bin()
|
||||
{
|
||||
std::string home = current_user_home();
|
||||
if (home.empty())
|
||||
return "";
|
||||
return home + "/.local/bin";
|
||||
}
|
||||
|
||||
std::string backups()
|
||||
{
|
||||
if (!gConfig().is_config_set())
|
||||
|
@@ -68,6 +68,7 @@ namespace dropshell {
|
||||
std::string agent_local();
|
||||
std::string agent_remote();
|
||||
std::string current_user_home();
|
||||
std::string user_local_bin(); // ~/.local/bin directory for user executables
|
||||
|
||||
std::string backups();
|
||||
std::string temp_files();
|
||||
|
Reference in New Issue
Block a user