ghqとpecoとhubを使ったリポジトリの管理
リポジトリをダウンロードして、見たりするときとかいいのかも
ずっとやろうって思ってたのをやっとできたから、メモメモ
それぞれをインストールする
ghq
go get github.com/motemen/ghq
peco
go get github.com/peco/peco/cmd/peco
hub
go get github.com/github/hub
エイリアスの設定
~/.bashrc
に以下を追加
alias gcd='cd $(ghq root)/$(ghq list | peco)' alias gh='hub browse $(ghq list | peco | cut -d "/" -f 2,3)'
gcd
して、検索して矢印キーで移動して、Enterでカレントディレクトリをそれに変更する
gh
して、検索して矢印キーで移動して、EnterでGitHubでそれを開く
ghqの使い方
ghq get {リポジトリのURL}
ghq get https://github.com/requests/requests.git
~/.ghq/github.com/requests/requests
にダウンロードされる
その他のコマンドの説明はmotemen/ghq: Remote repository management made easyで確認する
また、~/.gitconfig
に以下を追加することで、ダウンロード先を変えることもできる(デフォルトでは~/.ghq
にダウンロードされる)
[ghq] root = ~/src/repos
参考文献
複数行で書きたい時 - Python
()
でくくる
s = ('hello' 'world') print(s)
helloworld
print(('hello' 'world'))
helloworld
参考文献
PipenvでImportError: cannot import name 'get_installed_distributions'ってエラー出た
pipenvのgraphしたらエラーが出たから、その時の対処のメモと言うか、いらないと思うけど、メモっとく
$ pipenv graph Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pipdeptree.py", line 17, in <module> from pip._internal import get_installed_distributions ImportError: cannot import name 'get_installed_distributions' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/bin/pipenv", line 11, in <module> sys.exit(cli()) File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__ return self.main(*args, **kwargs) File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke return callback(*args, **kwargs) File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 922, in graph do_graph(bare=bare, json=json, json_tree=json_tree, reverse=reverse) File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 2363, in do_graph import pipdeptree File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pipdeptree.py", line 20, in <module> from pip import get_installed_distributions, FrozenRequirement ImportError: cannot import name 'get_installed_distributions'
ここに書いてあった
python3 -m pip install --upgrade pip python3 -m pip install --upgrade pipenv
でできた
参考文献
TNSLSNR.EXEの停止
JavaのWebプロジェクトを起動しようとしたら、8080のポートが使われてた。8080のポートを使っているプロセスを特定、停止までの道のり。
8080を使っているPIDをみつける
netstat -ao | find "8080" ... ... ... 4312
PID4312のプロセス名を取得する
tasklist | find "123" TNSLSNR.exe
TNSLSNRってなに
Oracleのなんかのソフトらしい
TNSLSNR.exeを停止
管理者権限のコマンドプロンプトで以下を実行
> lsnrctl LSNRCTL for 64-bit Windows: Version 11.2.0.2.0 - Production on 12-10月-2018 14:40:30 Copyright (c) 1991, 2014, Oracle. All rights reserved. Welcome to LSNRCTL, type "help" for information. LSNRCTL> stop (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))に接続中 コマンドは正常に終了しました。 LSNRCTL> exit
8080が使えるようになった!!
参考文献
tmuxで256色表示に対応させる - tmux
「ubuntu12.10+tmux+vim、できるだけ少ない手順で256色表示にする」 - StupidDog's blog
上の記事が参考というかそのまんま
aliasを追加する
# ~/.bash_profile alias tmux='tmux -2'
tmux(1) - Linux manual page を確認すると、-2
オプションがあった
-2 Force tmux to assume the terminal supports 256 colours.
tmuxに端末が256色をサポートしていることを強制します。
tmux -2
で256色を強制的にサポートできるのか!!!
参照文献
ENVは1行づつ記述すること - Docker
1つのENV内で定義した変数はそのENV内では使えないことがわかった
以下のものはTMP
に何も設定されない
# TMPはブランク ENV USER="tamago324" \ TMP="${USER}"
正しく設定される
# TMPにtamago324が設定される ENV USER="tamago324" ENV TMP="${USER}"
1行ずつ書くのが良い
Docker 1.10以降では、イメージのレイヤーが作成されるのは RUN、COPY、ADDの3つのみになっているとのことです
# この書き方が一番いい!! ENV NAME tamago324 ENV OS mac
RUNとCOPYとADDしかレイヤーが作成されないのは気が楽でいいね
ENVをわけない
FROM ubuntu:18.04 ENV USER="tamago324" \ TMP="${USER}" RUN echo ${TMP}
$ docker build -t test . Sending build context to Docker daemon 89.09kB Step 1/3 : FROM ubuntu:18.04 ---> cd6d8154f1e1 Step 2/3 : ENV USER="tamago324" TMP="${USER}" ---> Running in eadaba3299d3 Removing intermediate container eadaba3299d3 ---> ddb342c89ac5 Step 3/3 : RUN echo ${TMP} ---> Running in df55730ff6c8 Removing intermediate container df55730ff6c8 ---> 7f3914e78455 Successfully built 7f3914e78455 Successfully tagged test:latest
Step 3/3 : RUN echo ${TMP} ---> Running in df55730ff6c8
何も表示されない...
ENVを分ける
FROM ubuntu:18.04 ENV USER="tamago324" ENV TMP="${USER}" RUN echo ${TMP}
$ docker build -t test . Sending build context to Docker daemon 89.09kB Step 1/4 : FROM ubuntu:18.04 ---> cd6d8154f1e1 Step 2/4 : ENV USER="tamago324" ---> Running in 7869a22a685f Removing intermediate container 7869a22a685f ---> 02b76c851c06 Step 3/4 : ENV TMP="${USER}" ---> Running in 770fcb7d6444 Removing intermediate container 770fcb7d6444 ---> a91b0bf173e4 Step 4/4 : RUN echo ${TMP} ---> Running in f55ddbef02b3 tamago324 Removing intermediate container f55ddbef02b3 ---> 2de05b682fb3 Successfully built 2de05b682fb3 Successfully tagged test:latest
表示されてる!!
Step 4/4 : RUN echo ${TMP} ---> Running in f55ddbef02b3 tamago324
参考文献
shiftコマンド - shellscript
引数を1つずらす
#!/bin/bash echo $1; # 1つずらす shift; echo $1;
$ ./shift.sh 1 2 1 2
シェルスクリプトの引数は、$1
や$2
のように数値で指定する。そのため、shift
を使うことで、
引数を1つずつ処理したい場合に役に立つ!!