mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-10 04:54:03 -08:00
parent
0813ef5af6
commit
40238b8226
|
@ -47,8 +47,8 @@ locations before doing a replacement.
|
|||
|
||||
- mapped_locations_enabled: `boolean` - replace known locations in the path with the replacements before applying the
|
||||
style. defaults to `true`
|
||||
- mapped_locations: `map[string]string` - custom glyph/text for specific paths (only when `mapped_locations_enabled`
|
||||
is set to `true`)
|
||||
- mapped_locations: `map[string]string` - custom glyph/text for specific paths. Works regardless of the `mapped_locations_enabled`
|
||||
setting.
|
||||
|
||||
For example, to swap out `C:\Users\Leet\GitHub` with a GitHub icon, you can do the following:
|
||||
|
||||
|
|
|
@ -200,9 +200,7 @@ func (pt *path) getPwd() string {
|
|||
if pwd == "" {
|
||||
pwd = pt.env.getcwd()
|
||||
}
|
||||
if pt.props.getBool(MappedLocationsEnabled, true) {
|
||||
pwd = pt.replaceMappedLocations(pwd)
|
||||
}
|
||||
pwd = pt.replaceMappedLocations(pwd)
|
||||
return pwd
|
||||
}
|
||||
|
||||
|
@ -211,10 +209,11 @@ func (pt *path) replaceMappedLocations(pwd string) string {
|
|||
pwd = strings.Replace(pwd, "Microsoft.PowerShell.Core\\FileSystem::", "", 1)
|
||||
}
|
||||
|
||||
mappedLocations := map[string]string{
|
||||
"HKCU:": pt.props.getString(WindowsRegistryIcon, "\uF013"),
|
||||
"HKLM:": pt.props.getString(WindowsRegistryIcon, "\uF013"),
|
||||
pt.env.homeDir(): pt.props.getString(HomeIcon, "~"),
|
||||
mappedLocations := map[string]string{}
|
||||
if pt.props.getBool(MappedLocationsEnabled, true) {
|
||||
mappedLocations["HKCU:"] = pt.props.getString(WindowsRegistryIcon, "\uF013")
|
||||
mappedLocations["HKLM:"] = pt.props.getString(WindowsRegistryIcon, "\uF013")
|
||||
mappedLocations[pt.env.homeDir()] = pt.props.getString(HomeIcon, "~")
|
||||
}
|
||||
|
||||
// merge custom locations with mapped locations
|
||||
|
|
|
@ -571,10 +571,12 @@ func TestGetPwd(t *testing.T) {
|
|||
|
||||
{MappedLocationsEnabled: false, Pwd: "", Expected: ""},
|
||||
{MappedLocationsEnabled: false, Pwd: "/usr/home/abc", Expected: "/usr/home/abc"},
|
||||
{MappedLocationsEnabled: false, Pwd: "/a/b/c/d/e/f/g", Expected: "/a/b/c/d/e/f/g"},
|
||||
{MappedLocationsEnabled: false, Pwd: "/a/b/c/d/e/f/g", Expected: "#/e/f/g"},
|
||||
{MappedLocationsEnabled: false, Pwd: "/usr/home/c/d/e/f/g", Expected: "/usr/home/c/d/e/f/g"},
|
||||
{MappedLocationsEnabled: true, Pwd: "/usr/home/c/d/e/f/g", Expected: "~/c/d/e/f/g"},
|
||||
|
||||
{MappedLocationsEnabled: true, Pwd: "/w/d/x/w", Pswd: "/z/y/x/w", Expected: "/z/y/x/w"},
|
||||
{MappedLocationsEnabled: false, Pwd: "/f/g/k/d/e/f/g", Pswd: "/a/b/c/d/e/f/g", Expected: "/a/b/c/d/e/f/g"},
|
||||
{MappedLocationsEnabled: false, Pwd: "/f/g/k/d/e/f/g", Pswd: "/a/b/c/d/e/f/g", Expected: "#/e/f/g"},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
|
|
Loading…
Reference in a new issue