New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iTerm image support #2

Merged
merged 2 commits into from Sep 6, 2018
Jump to file or symbol
Failed to load files and symbols.
+15 鈭0
Diff settings

Always

Just for now

Copy path View file
@@ -2,6 +2,7 @@ namespace GiphyCli
{
using System;
using System.ComponentModel.DataAnnotations;
using System.Net.Http;
using McMaster.Extensions.CommandLineUtils;
[Command(Description = "Global CLI to quickly get a Giphy link or markdown for your search (which should always be lolcats).")]
@@ -40,6 +41,20 @@ private void OnExecute()
Console.WriteLine("GIF URL");
Console.WriteLine($"{result.GifUrl}");
Console.WriteLine("");
if (Environment.GetEnvironmentVariable("TERM_PROGRAM") == "iTerm.app")
{
Console.Write("\u001B]1337");
Console.Write(";File=;inline=1:");
using (var httpClient = new HttpClient())
{
var bytes = httpClient.GetByteArrayAsync(result.GifUrl).GetAwaiter().GetResult();
Console.Write(Convert.ToBase64String(bytes));
}
Console.Write("\u0007");
Console.WriteLine("");
}
Console.WriteLine("MARKDOWN:");
Console.WriteLine($"![{result.Title}]({result.GifUrl})");
Console.WriteLine("");
ProTip! Use n and p to navigate between commits in a pull request.