diff --git a/aliases.go b/aliases.go index 45dcd9c5..5ee96540 100644 --- a/aliases.go +++ b/aliases.go @@ -66,7 +66,8 @@ func aliasExpand(aliasedURL string, aliases map[string]string) (newURL string, e // if more splits found return if len(splits) == 2 { // remove any prefixed slashes - u, err := client.Parse(expandedURL + "/" + strings.TrimPrefix(splits[1], "/")) + trimmedURL := expandedURL + "/" + strings.TrimPrefix(strings.TrimPrefix(splits[1], "/"), "\\") + u, err := client.Parse(trimmedURL) if err != nil { return aliasedURL, iodine.New(errInvalidURL{url: aliasedURL}, nil) } diff --git a/ls.go b/ls.go index b5ca9c19..eb275e2c 100644 --- a/ls.go +++ b/ls.go @@ -17,6 +17,7 @@ package main import ( + "runtime" "strings" "github.com/dustin/go-humanize" @@ -45,7 +46,11 @@ func printContent(c *client.Content) { return "application/octet-stream" }() content.Size = humanize.IBytes(uint64(c.Size)) - content.Name = strings.TrimSuffix(c.Name, "/") + if runtime.GOOS == "windows" { + content.Name = strings.Replace(c.Name, "/", "\\", -1) + content.Name = strings.TrimSuffix(content.Name, "\\") + } + content.Name = strings.TrimSuffix(content.Name, "/") content.Time = c.Time.Local().Format(printDate) console.ContentInfo(content) } diff --git a/pkg/console/console.go b/pkg/console/console.go index a0cf56b7..621de220 100644 --- a/pkg/console/console.go +++ b/pkg/console/console.go @@ -20,6 +20,7 @@ import ( "encoding/json" "fmt" "os" + "runtime" "sync" "path/filepath" @@ -254,7 +255,7 @@ var ( // special cases only for Content where it requires custom formatting case themesDB[currThemeName].Time: mutex.Lock() - c.Print(fmt.Sprintf("[%s]", a...)) + c.Print(fmt.Sprintf("[%s] ", a...)) mutex.Unlock() case themesDB[currThemeName].Size: mutex.Lock() @@ -301,8 +302,12 @@ var ( mutex.Unlock() case themesDB[currThemeName].Dir: mutex.Lock() - // ugly but its needed - c.Printf("%s/\n", a...) + switch { + case runtime.GOOS == "windows": + c.Printf("%s\\\n", a...) + default: + c.Printf("%s/\n", a...) + } mutex.Unlock() case themesDB[currThemeName].File: mutex.Lock()