github gist snippet management

1

Estou reescrevendo minha pergunta, já que parece não ter sido claro o suficiente ...

Estou tentando encontrar uma maneira de extrair o conteúdo de um github e colocar esse conteúdo no próprio terminal, em um novo documento ou anexado a um documento já criado.

Para fazer isso, eu gostaria de digitar um comando no meu terminal com sintaxe semelhante à seguinte:

gist <source> <output>

em que source é a url para a essência, e a saída é terminal ou a localização exata de um arquivo para criar / anexar o texto.

Pergunta original:

I found a way to post gists to Github in the terminal with a ruby gem, however, I would actually like a way to retrieve those gists, aka, use them as snippets, as well. I'm quite sure it's possible, but I'm not very familiar with the Gist api, and I'm also a bit of a latecomer to the Linux systems.

I'm using Linux Mint 17.1 with Cinnamon, though I do have a live CD for the KDE variation of Linux Mint that I've been testing out. I would prefer an answer that includes both a gui based and cli based solution, as I'm trying to learn to better use CLI.

I know there are gist options for specific editors, but I'd prefer something that doesn't require a specific program to work.

    
por Jackie KayE 03.03.2015 / 22:09

1 resposta

0

Ok, acho que o que você quer é um script para baixar uma essência específica sem a necessidade de usar seu navegador da web. Algo parecido com isto:

#!/bin/sh

# gist-dl.sh: download a Github gist from a specified link to either a
#             standard output (when no second argument passed) or to a
#             specified file (with second argument passed). The first
#             argument is a gist URL and is obligatory

if [ "$1"a = a ]
then
    echo No gist URL passed. Bye
    exit 1
fi

if [ "$2"a = a ]
then
    wget -q -O - "$1"/raw
else
    wget -q -O "$2" "$1"/raw
fi

Uso:

$ # display a gist in terminal
$ ./gist-dl.sh https://gist.github.com/kylejohnson/6c6c0ca2d300ffce4bea
<VirtualHost *:80>
    ServerName zm
    ServerAdmin webmaster@localhost

    DocumentRoot "/var/www/zm"
    <Directory "/var/www/zm">
        Options FollowSymLinks
        AllowOverride All
    </Directory>

    ScriptAlias /cgi-bin/ "/usr/lib/cgi-bin/"
    <Directory "/usr/lib/cgi-bin">
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        AllowOverride All
    </Directory>

    ErrorLog /var/log/apache2/zm-error.log
    LogLevel warn
    CustomLog /var/log/apache2/zm-access.log combined
</VirtualHost>
$ # download a gist to GIST.txt
$ ./gist-dl.sh https://gist.github.com/kylejohnson/6c6c0ca2d300ffce4bea GIST.txt
$ cat GIST.txt
<VirtualHost *:80>
    ServerName zm
    ServerAdmin webmaster@localhost

    DocumentRoot "/var/www/zm"
    <Directory "/var/www/zm">
        Options FollowSymLinks
        AllowOverride All
    </Directory>

    ScriptAlias /cgi-bin/ "/usr/lib/cgi-bin/"
    <Directory "/usr/lib/cgi-bin">
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        AllowOverride All
    </Directory>

    ErrorLog /var/log/apache2/zm-error.log
    LogLevel warn
    CustomLog /var/log/apache2/zm-access.log combined
</VirtualHost>
    
por 04.03.2015 / 01:18