4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Oh My Bash 導入メモ

Last updated at Posted at 2021-08-14

1. はじめに

  • 家のサーバ、職場のサーバx複数台など、複数のサーバを触っていると、システムのデフォルトシェルを変更すると使いわけが面倒なので、普段はbashを使用しています。
  • ただ、その場合、プロンプトの見た目や使い勝手が微妙なところがあり、bashの設定を簡単に統一したいな、と思っていました。
    • 昔、zshを使用していたときはoh my zshを使っていて、便利だな、と思っていたのがあります。
  • 先日のVSCode + Remote Container でtypescriptの開発環境を試す。にてMicrosofto社のdevcontainerを使用したとき、devcontainer内に「oh my bash」が導入されていることに気づき、家のサーバに導入してみました。

2. Oh My Bashについて

  • サイトは以下のページにあります。
  • 以下のような標榜が掲げられています。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で何も設定していないと以下のような見た目となっています。
    UbuntuDefault.png

3.1. インストール

  • 公式サイトにならい、以下のコマンドを実行することでインストールできます。
tomoten@hogehoge:~$ bash -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. インストール後のデフォルトの見た目

  • 以下のような見た目になります。
    OhMyBashDefault.png

3.3. カスタマイズ

  • デフォルトで設定テーマが用意されているのと、各々の皆さんが作成されたテーマをインポートすることができます。
  • その中でも、すでに用意されたテーマを切り替える場合は、.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して環境変数を設定すれば大体同じ使用感になるので、複数の環境に展開しようと思います。
4
3
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
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?