github 必須スニペット管理

github 必須スニペット管理

質問が十分にはっきりしていないようで、書き直します。

私はgithub gistからコンテンツを抽出して、そのコンテンツを端末自体、新しい文書、またはすでに生成された文書に追加する方法を見つけたいと思います。

これを行うには、次のような構文を使用して端末にコマンドを入力したいと思います。

gist <source> <output>

ソースはポイントのURLで、出力はテキストを生成/追加するために使用される端末またはファイルの正確な場所です。


元の質問:

私はRuby gemを使ってターミナルからGithubにGistを投稿する方法を見つけましたが、実際にはこれらのGistを検索する方法、つまりスニペットとして使用する方法が欲しいです.これは可能だと確信していますが、Gist APIに慣れていないため、Linuxシステムに少し遅れて参加しました。

私はLinux Mint 17.1とCinnamonを使用していますが、テストしたLinux Mint KDEバージョンのLive CDを持っています。私はCLIの使いやすさを学びたいので、GUIベースのソリューションとCLIベースのソリューションの両方を含む答えを好みます。

特定の編集者のための要点オプションがあることを知っていますが、機能するために特定のプログラムを必要としないオプションを好みます。

ベストアンサー1

まあ、あなたが望むのは、Webブラウザを使用せずに指定されたポイントをダウンロードするスクリプトだと思います。このような:

#!/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

使用法:

$ # 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>

おすすめ記事