はじめに
Qiitaのタグフィードの代わりにするやつ という記事の続きです。
いちいちQiitaのマイページからフォロー中のタグを調べてURL作るのが面倒なのでQiita APIを使ってワンライナーを書いてみました。
動作環境や注意点など
Linux Mint 19.3 (Ubuntu 18.04LTSベース)
curl,jqは追加でインストールする必要があるかもしれません。
- QiitaAPIを使ってのフォロータグは1度に100個までしか取得できないので、100個を越えるフォロータグがある場合その対応が必要です。
- アクセストークンを使っていないので1つのIPアドレスにつき1時間に60回の回数制限があります。アクセストークンを取得してそれを指定すればその制限は緩和されるので必要であればそのように変更してください。
出来上がったワンライナー
curl -sS 'https://qiita.com/api/v2/users/(ここにQiitaのユーザ名を入れてください)/following_tags?per_page=100' | jq -r .[].id | awk '{if(NR==1){url="https://qiita.com/search?q=tag%3A" $0}else{url=url "+OR+tag%3A" $0}};END{print url "&sort=created"}'
Linuxのデスクトップ環境であれば、コマンドライン末尾に| xargs xdg-open
を追加するとダイレクトにブラウザでオープンすることができると思います。
curl -sS 'https://qiita.com/api/v2/users/(ここにQiitaのユーザ名を入れてください)/following_tags?per_page=100' | jq -r .[].id | awk '{if(NR==1){url="https://qiita.com/search?q=tag%3A" $0}else{url=url "+OR+tag%3A" $0}};END{print url "&sort=created"} | xargs xdg-open'
実行結果
出力結果をブラウザにコピペすれば検索結果画面が表示されると思います。
$ curl -sS 'https://qiita.com/api/v2/users/hidezzz/following_tags?per_page=100' | jq -r .[].id | awk '{if(NR==1){url="https://qiita.com/search?q=tag%3A" $0}else{url=url "+OR+tag%3A" $0}};END{print url "&sort=created"}'
https://qiita.com/search?q=tag%3AQiita+OR+tag%3ASyncthing+OR+tag%3APAM+OR+tag%3A自宅サーバー+OR+tag%3Afoxdot+OR+tag%3ASuperCollider+OR+tag%3Aansible_spec+OR+tag%3Aserverspec+OR+tag%3Afabric+OR+tag%3AStow+OR+tag%3ADocker+OR+tag%3Avimwiki+OR+tag%3AGitHub+OR+tag%3AGit+OR+tag%3AGhq+OR+tag%3Avimrc+OR+tag%3Afzf+OR+tag%3Aawk+OR+tag%3Ased+OR+tag%3Aシェル芸+OR+tag%3Amastodon+OR+tag%3AArduboy+OR+tag%3Apassword+OR+tag%3AKeePass+OR+tag%3Ataskwarrior+OR+tag%3AOpenBSD+OR+tag%3ACppUTest+OR+tag%3AAnsible+OR+tag%3Araspbian+OR+tag%3AEnglish+OR+tag%3Aサーバー管理+OR+tag%3AGo+OR+tag%3ARaspberryPi+OR+tag%3ATwitter+OR+tag%3AYAML+OR+tag%3Alifehack+OR+tag%3AWireshark+OR+tag%3AarchLinux+OR+tag%3AUbuntu+OR+tag%3AVirtualBox+OR+tag%3ACentOS+OR+tag%3Agame+OR+tag%3ATDD+OR+tag%3ATerminal+OR+tag%3AUNIX+OR+tag%3Acommand+OR+tag%3A開発環境+OR+tag%3Atmux+OR+tag%3ANetBSD+OR+tag%3AFreeBSD+OR+tag%3ALua+OR+tag%3APerl+OR+tag%3AC+OR+tag%3AC+++OR+tag%3AShellScript+OR+tag%3AVim+OR+tag%3ALinux+OR+tag%3A正規表現+OR+tag%3ASSH&sort=created