mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Changes to xdg to append powershell path
This commit is contained in:
committed by
Andrew Schwartzmeyer
parent
29e97bf1aa
commit
237c659b5e
@@ -192,13 +192,13 @@ namespace Microsoft.PowerShell
|
||||
//check if the user has set an XDG path in their environment variables
|
||||
profileDir = Platform.SelectProductNameForDirectory(Platform.XDG_Type.PROFILE);
|
||||
}
|
||||
|
||||
/*
|
||||
if (!Directory.Exists(profileDir)) //xdg value may have been set but not a valid directory
|
||||
{
|
||||
Console.WriteLine("The selected directory for the profile does not exist. Using the default path.");
|
||||
Console.WriteLine("The selected directory (" + profileDir +") for the profile does not exist. Using the default path.");
|
||||
profileDir = Platform.SelectProductNameForDirectory(Platform.XDG_Type.DEFAULT);
|
||||
}
|
||||
|
||||
*/
|
||||
ClrFacade.SetProfileOptimizationRoot(profileDir);
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -181,29 +181,27 @@ namespace Microsoft.PowerShell
|
||||
{
|
||||
//PSReadline does not have access to Utils.CorePSPlatform. Must set PSReadline path seperately
|
||||
string modulepath = System.Environment.GetEnvironmentVariable("XDG_CACHE_HOME");
|
||||
|
||||
if (String.IsNullOrEmpty(modulepath))
|
||||
{
|
||||
modulepath = System.IO.Path.Combine(
|
||||
Environment.GetEnvironmentVariable("HOME"),
|
||||
".config/powershell/modules");
|
||||
|
||||
HistorySavePath = System.IO.Path.Combine(
|
||||
Environment.GetEnvironmentVariable("HOME"),
|
||||
modulepath,
|
||||
"PSReadLine",
|
||||
hostName + "_history.txt");
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
if (!String.IsNullOrEmpty(modulepath))
|
||||
{
|
||||
modulepath = System.IO.Path.Combine(modulepath, "powershell");
|
||||
HistorySavePath = modulepath;
|
||||
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
modulepath = System.IO.Path.Combine(
|
||||
Environment.GetEnvironmentVariable("HOME"),
|
||||
".config/powershell/modules");
|
||||
|
||||
HistorySavePath = System.IO.Path.Combine(
|
||||
Environment.GetEnvironmentVariable("HOME"),
|
||||
modulepath,
|
||||
"PSReadLine",
|
||||
hostName + "_history.txt");
|
||||
}
|
||||
#else
|
||||
}
|
||||
#else
|
||||
HistorySavePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
|
||||
+ @"\Microsoft\Windows\PowerShell\PSReadline\" + hostName + "_history.txt";
|
||||
#endif
|
||||
|
||||
@@ -106,10 +106,11 @@ namespace System.Management.Automation
|
||||
};
|
||||
|
||||
// function for choosing directory location of PowerShell for profile loading
|
||||
public static string SelectProductNameForDirectory (Platform.XDG_Type dirpath){
|
||||
public static string SelectProductNameForDirectory (Platform.XDG_Type dirpath)
|
||||
{
|
||||
|
||||
string xdgconfighome = System.Environment.GetEnvironmentVariable("XDG_CONFIG_HOME");
|
||||
string xdgdatahome = System.Environment.GetEnvironmentVariable("XDG_DATA_HOME");
|
||||
string xdgdatahome = System.Environment.GetEnvironmentVariable("XDG_DATA_HOME");
|
||||
string xdgcachehome = System.Environment.GetEnvironmentVariable("XDG_CACHE_HOME");
|
||||
string profileDefault = Path.Combine ( System.Environment.GetEnvironmentVariable("HOME"), ".config/powershell");
|
||||
string moduleDefault = Path.Combine ( System.Environment.GetEnvironmentVariable("HOME"), ".config/powershell/modules");
|
||||
@@ -117,12 +118,14 @@ namespace System.Management.Automation
|
||||
switch (dirpath){
|
||||
case Platform.XDG_Type.PROFILE:
|
||||
//the user has set XDG_CONFIG_HOME corrresponding to profile path
|
||||
if (!String.IsNullOrEmpty(xdgconfighome)){
|
||||
|
||||
if (!String.IsNullOrEmpty(xdgconfighome))
|
||||
{
|
||||
xdgconfighome = Path.Combine(xdgconfighome, "powershell");
|
||||
return xdgconfighome;
|
||||
}
|
||||
|
||||
else {
|
||||
else
|
||||
{
|
||||
//xdg values have not been set
|
||||
return profileDefault;
|
||||
}
|
||||
@@ -130,10 +133,12 @@ namespace System.Management.Automation
|
||||
case Platform.XDG_Type.MODULES:
|
||||
//the user has set XDG_DATA_HOME corresponding to module path
|
||||
if (!String.IsNullOrEmpty(xdgdatahome)){
|
||||
xdgdatahome = Path.Combine(xdgdatahome, "powershell");
|
||||
return xdgdatahome;
|
||||
}
|
||||
|
||||
else{
|
||||
else
|
||||
{
|
||||
//xdg values have not been set
|
||||
if (!Directory.Exists(profileDefault)) //module folder not always guaranteed to exist
|
||||
{
|
||||
@@ -146,9 +151,11 @@ namespace System.Management.Automation
|
||||
case Platform.XDG_Type.HISTORY:
|
||||
//the user has set XDG_CACHE_HOME
|
||||
if (!String.IsNullOrEmpty(xdgcachehome)){
|
||||
xdgcachehome = Path.Combine(xdgcachehome, "powershell");
|
||||
return xdgcachehome;
|
||||
}
|
||||
else{
|
||||
else
|
||||
{
|
||||
return profileDefault;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user