Quantcast
Channel: Bashタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 2872

Oh My Bash 導入メモ

$
0
0
1. はじめに 家のサーバ、職場のサーバx複数台など、複数のサーバを触っていると、システムのデフォルトシェルを変更すると使いわけが面倒なので、普段はbashを使用しています。 ただ、その場合、プロンプトの見た目や使い勝手が微妙なところがあり、bashの設定を簡単に統一したいな、と思っていました。 昔、zshを使用していたときはoh my zshを使っていて、便利だな、と思っていたのがあります。 先日のVSCode + Remote Container でtypescriptの開発環境を試す。にてMicrosofto社のdevcontainerを使用したとき、devcontainer内に「oh my bash」が導入されていることに気づき、家のサーバに導入してみました。 2. Oh My Bashについて サイトは以下のページにあります。 https://ohmybash.nntoan.com 以下のような標榜が掲げられています。Oh My Zshの(恥知らずな)フォークとのことです。 そんなことはないような… Oh-My-Bash is an open source, community-driven framework for managing your BASH configuration. It comes bundled with a ton of helpful functions, helpers, plugins, themes, and a few things that make you shout... If you heard about Oh-My-Zsh before, this project is a shameless fork of that one, but in "Bourne Again Shell". 3. 設定するホスト環境 OS : Ubuntu 20.04 CPU : Intel(R) Pentium(R) CPU G4560 @ 3.50GHz RAM : 8GB Software curl : 7.68.0 (インストールで使用します) 3. 導入 3.0 導入前 Ubuntuのbashで何も設定していないと以下のような見た目となっています。 3.1. インストール 公式サイトにならい、以下のコマンドを実行することでインストールできます。 tomoten@hogehoge:~$ sh -c "$(curl -fsSL https://raw.github.com/ohmybash/oh-my-bash/master/tools/install.sh)" sh: 33: [: Illegal number: Cloning Oh My Bash... Cloning into '/home/tomoyoshi/.oh-my-bash'... remote: Enumerating objects: 348, done. remote: Counting objects: 100% (348/348), done. remote: Compressing objects: 100% (312/312), done. remote: Total 348 (delta 20), reused 302 (delta 19), pack-reused 0 Receiving objects: 100% (348/348), 2.70 MiB | 15.91 MiB/s, done. Resolving deltas: 100% (20/20), done. Looking for an existing bash config... Found ~/.bashrc. Backing up to ~/.bashrc.pre-oh-my-bash Using the Oh My Bash template file and adding it to ~/.bashrc __ __ __ ____ / /_ ____ ___ __ __ / /_ ____ ______/ /_ / __ \/ __ \ / __ `__ \/ / / / / __ \/ __ `/ ___/ __ \ / /_/ / / / / / / / / / / /_/ / / /_/ / /_/ (__ ) / / / \____/_/ /_/ /_/ /_/ /_/\__, / /_.___/\__,_/____/_/ /_/ /____/ .... is now installed! Please look over the ~/.bashrc file to select plugins, themes, and options To keep up on the latest news and updates, follow us on GitHub: https://github.com/ohmybash/oh-my-bash 09:03:21 tomoten@hogehoge ~ → 3.2. インストール後のデフォルトの見た目 以下のような見た目になります。 3.3. カスタマイズ デフォルトで設定テーマが用意されているのと、各々の皆さんが作成されたテーマをインポートすることができます。 README : https://github.com/ohmybash/oh-my-bash を確認いただくのが確実です。 その中でも、すでに用意されたテーマを切り替える場合は、.bashrcに以下の環境変数を設定すればよいです。 デフォルトはfontが設定されています。例えばnwinklerにする場合は、以下のように書き換えます。 #OSH_THEME="font" OSH_THEME="nwinkler" 3.4. 個人的に便利に感じたこと(nwinklerの使用感) cdすると、フルパスを表示してくれます。 (10:10:50) ○ [tomoten@hogehoge] ~ → cd workspace/ /home/tomoyoshi/workspace ← ココ! (10:10:52) ○ [tomoten@hogehoge] ~/workspace → gitのリポジトリでは、ブランチや修正有無を表示してくれます。 (ブランチ名 ✓:修正なし or ✗:修正あり) (10:21:25) ± [tomoten@hogehoge] ~/workspace/study-page (master ✓) → touch .aaaaaaaaaa (10:21:32) ± [tomoten@hogehoge] ~/workspace/study-page (master ✗) → historyと打つと、時刻情報が残っています。 (10:23:30) ○ [tomoten@hogehoge] ~ → history (中略) 1885 2021-08-14 10:13:08 git status 1886 2021-08-14 10:21:32 touch .aaaaaaaaaa 1887 2021-08-14 10:22:54 ls 1888 2021-08-14 10:23:24 cd 1889 2021-08-14 10:23:26 pwd (10:23:30) ○ [tomoten@hogehoge] ~ → 4. 終わりに これまで.bashrcをちょこちょこ自作していましたが、不自由なく使えると感じました。git cloneして環境変数を設定すれば大体同じ使用感になるので、複数の環境に展開しようと思います。

Viewing all articles
Browse latest Browse all 2872

Trending Articles