- 投稿日:2020-11-18T19:18:36+09:00
Macのターミナル上でTab補完を有効にしたら、Git操作が爆速になった話
エンジニアの先輩から教わったスキルハックです。
ターミナル上で、pushする際に、
git branch
でブランチ名確認して、
「feature/fix-password-form
いちいち打つのめんどくさいな〜。」って思っていました。Tab補完ができれば、
fe
くらいのタイミングでもう入力できます。
楽ちん楽ちん。コミットする際も地味にめんどくさい。
git commit -m "xxxxxxxx"
g → tab → c → tab → "xxxxxx"
てな感じでスイスイ行きます。Sourcetreeをaddする時くらいしか使わない自分からするとだいぶありがたい。
だまされたと思ってやってみてください。マジで捗ります。
導入方法
macOS CatalinaからMacのデフォルトのシェルがzshになったそうです。
それまでは、bashだったそう。
シェルについて詳しくないですが、以下の記事がわかりやすくまとまってました。
bashとzshの違い。bashからの乗り換えで気をつけるべき16の事柄zsh-completionsをインストール
https://formulae.brew.sh/formula/zsh-completions
上記サイトの通り、コマンドを叩く
-[注意]- 就業中や勉強中の方はビール飲みたくなるので、見ないほうがいい。brew install zsh-completions設定を有効にするために~/.zshrcに追記
if type brew &>/dev/null; then FPATH=$(brew --prefix)/share/zsh-completions:$FPATH autoload -Uz compinit compinit fiこれだけです。
ちなみに自身は.zshrc
ファイルがなかったのでtouch .zshrcでファイルを作ってから
vim
を使って追記しました。
エディタはなんでもいいと思います。vim .zshrcターミナルを開き直すのは面倒なので以下のコマンドで再読み込み
source .zshrcすると、Tab補完が有効になっているはずです。
これで今日から、Tab補完なしで生きれない体になったぜ!!
マジでgitの操作が捗ります。多分1.8倍くらい。ありがたや。アディオス。参考
- 投稿日:2020-11-18T17:00:14+09:00
Mac M1でhomebrewをインストールできるの?
Rosettaを使用しないとまだ使えない
現状、ターミナルからhomebrewをインストールしようとするとこのような出力が表示されます。
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" Homebrew is not (yet) supported on ARM processors! Rerun the Homebrew installer under Rosetta 2. If you really know what you are doing and are prepared for a very broken experience you can use another installation option for installing on ARM: https://docs.brew.sh/Installation出力通り、Rossetaを経由しないとダメみたいですね。
ターミナルをRossetaを使用して開くようにする
- ターミナルの情報を開きます。
Rosetta
を使用して開くにチェックそうすることでhomebrewのインストールが可能になります。
$ brew doctor Please note that these warnings are just used to help the Homebrew maintainers with debugging if you file an issue. If everything you use Homebrew for is working fine: please don't worry or file an issue; just ignore this. Thanks! Warning: You are using macOS 11.0. We do not provide support for this released but not yet supported version. You will encounter build failures with some formulae. Please create pull requests instead of asking for help on Homebrew's GitHub, Twitter or any other official channels. You are responsible for resolving any issues you experience while you are running this released but not yet supported version.
- 投稿日:2020-11-18T17:00:14+09:00
Mac M1(Apple Silicon)でhomebrewをインストールできるの?
今まで通りにインストールしようとしたら...
現状、ターミナルから今まで通りhomebrewをインストールしようとするとこのような出力が表示されます。
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" Homebrew is not (yet) supported on ARM processors! Rerun the Homebrew installer under Rosetta 2. If you really know what you are doing and are prepared for a very broken experience you can use another installation option for installing on ARM: https://docs.brew.sh/Installation今まで通りではダメみたいですね。
対策1 ターミナルをRossetaを使用して開くようにする
- ターミナルの情報を開きます。
Rosetta
を使用して開くにチェックそうすることでhomebrewのインストールが可能になります。
$ brew doctor Please note that these warnings are just used to help the Homebrew maintainers with debugging if you file an issue. If everything you use Homebrew for is working fine: please don't worry or file an issue; just ignore this. Thanks! Warning: You are using macOS 11.0. We do not provide support for this released but not yet supported version. You will encounter build failures with some formulae. Please create pull requests instead of asking for help on Homebrew's GitHub, Twitter or any other official channels. You are responsible for resolving any issues you experience while you are running this released but not yet supported version.対策2 /opt/homebrewに保存するように実行する
https://docs.brew.sh/Installation では
However do yourself a favour and install to /usr/local on macOS Intel, /opt/homebrew on macOS ARM, and /home/linuxbrew/.linuxbrew on Linux.
とあります。
macOS ARMでは/opt/homebrew
にインストールしてねと案内されています。実行コマンド
cd /opt mkdir homebrew curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrewまとめ
せっかくのARMなので極力Rosetta使用したくないですよね。
いずれはuniversalに移行するのに...状況に応じてインストールしましょう!
- 投稿日:2020-11-18T11:48:28+09:00
Mac に RISC-V の開発環境構築
Mac に RISC-V Toolchain をインストール
Mac に RISC-V の クロスコンパイラ等が含まれる、RISC-V Toolchain をインストールする。
インストール
homebrew をインストールする。
homebrew は大抵の人が入れていると思うのでここはスキップ。
tap する
$ brew tap riscv/riscv
- tap について
- 公式ではないリポジトリをHomebrewに追加するもの。
- install, uninstall, update ができるようになる。
- github で
<user>/homebrew-hoge
となっているリポジトリはbrew tap <user>/hoge
で tapできる。ToolChain をインストールする
64bit だけでいい人
# brew install riscv-tools32bit も欲しい人
# brew install riscv-gnu-toolchain --with-multilibアップデート
- アップデートは以下のコマンド
brew reinstall --build-from-source riscv-gnu-toolchain
インストールでエラーが出ました
fatal: Needed a single revision Unable to find current revision in submodule path 'qemu/roms/u-boot' Failed to recurse into submodule path 'qemu' Error: Failed to download resource "riscv-gnu-toolchain" Failure while executing; `git submodule update --init --recursive` exited with 1. Here's the output: fatal: Needed a single revision Unable to find current revision in submodule path 'qemu/roms/u-boot' Failed to recurse into submodule path 'qemu'
- とりあえずqemuを削除してもう一回手動でやってみる
$ cd ~/Library/Caches/Homebrew/riscv-gnu-toolchain--git $ rm -rf qemu $ git submodule update --init --recursive $ brew install riscv-gnu-toolchain --with-multilibできた
Big Sur の人
エラーが出て make に失敗します!!!