LoginSignup
0
1

More than 5 years have passed since last update.

新しい言語のチュートリアルをやるときの5つのTips

Posted at

最近、Rustなど新しい言語を勉強する機会が多いのだが、いちいち言語を変えるたびに環境を作るのが面倒なので、楽にやる方法を工夫してみた。なお、環境はMacOS。

エディタ

ま、ご自由に

fswatch

チュートリアルは、コードを少し書き換えては実行コマンドを繰り返すので、保存するたびに実行コマンドが走ってくれると便利。

Macなら

brew install fswatch

でインストールし、

fswatch -o src/ | xargs -n1 -I{} cargo run

で実行するとsrc配下の変更があるたびにcargo runが実行される。

bash + peco

historyに日付を入れると便利なのでbash_profile

export HISTTIMEFORMAT='%F %T ';

という一行を入れておく。

pecoはhistory | pecoと打つと昨日にやったことを絞り込んで表示できる。

スクリーンショット 2019-02-17 22.56.32.png

today.sh

ソースコードに、こんな感じで2行目に参照するページ、3行目にfswatchのコマンドを書いておき、

/*
https://doc.rust-jp.rs/book/second-edition/ch05-03-method-syntax.html
fswatch -o src/ | xargs -n1 -I{} cargo run
*/

fn main(){
}

こんな感じでtoday.shを実行すると、エディタが開き、2行目に書かれていたURLが開き、fswatchが起動される。

cd rust/book
atom src/main.rs
head -n 2 src/main.rs | tail -n 1 | xargs open
fswatch -o src/ | xargs -n1 -I{} cargo run

alacritty

ターミナルもご自由に。最近はRust厨なのでAlacrittyを使ってる。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1