Created
April 30, 2020 03:55
-
-
Save rigelrozanski/da05a6f274b85fab88681551869a4be8 to your computer and use it in GitHub Desktop.
Iterm2 imgcat image output from golang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"encoding/base64" | |
"fmt" | |
"io/ioutil" | |
"os" | |
) | |
func main() { | |
r, err := os.Open("yourimagehere.png") | |
if err != nil { | |
panic(fmt.Sprintf("debug err: %v\n", err)) | |
} | |
bz, err := ioutil.ReadAll(r) | |
if err != nil { | |
panic(fmt.Sprintf("debug err: %v\n", err)) | |
} | |
fmt.Printf("\033]1337;File=;inline=1:%s\a\n", base64.StdEncoding.EncodeToString(bz)) | |
} | |
// for more complex implementations checkout these repos: | |
// https://github.com/martinlindhe/imgcat/blob/master/lib/imgcat.go#L43 | |
// https://github.com/olivere/iterm2-imagetools/blob/master/cmd/imgcat/imgcat.go |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment