Python
 Computer >> コンピューター >  >> プログラミング >> Python

Fish – Linux向けのスマートで使いやすいインタラクティブシェル

Fish(Friendly Interactive Shell)は、UNIXおよびUNIX系オペレーティングシステム向けのシェルです。数々の便利な改善が施された、独自性と革新性にあふれるコマンドライン環境を提供します。FishはbashやZshなど他のシェルと共存して動作するよう設計されており、多くのシェルがプロセスリソースを節約するために一部の機能をデフォルトで無効化しているのとは対照的に、Fishはすべての機能を最初から有効にし、その性能を最大限に引き出せるようになっています。

Fishの主な特徴

  • ユーザーフレンドリーなインタラクティブシェル
  • 強力な機能を多数搭載
  • Webブラウザベースの設定画面を内蔵
  • グロリアスVGAカラーおよび256色ターミナルカラーに対応
  • Xクリップボードに対応
  • エラーチェック機能を搭載
  • helpコマンドでFishのドキュメントを閲覧可能
  • 矢印キーで入力候補(サジェスト)を選択可能

Fishのインストール手順

Fishをインストールするには、まずpython-software-propertiesが必要です。以下のコマンドを実行してインストールします。

$ sudo apt-get install python-software-properties

実行すると、以下のような出力が表示されます。

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
    python-pycurl
Suggested packages:
    libcurl4-gnutls-dev python-pycurl-dbg
The following NEW packages will be installed:
python-pycurl python-software-properties
0 upgraded, 2 newly installed, 0 to remove and 7 not upgraded.
Need to get 67.5 kB of archives.
After this operation, 358 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://in.archive.ubuntu.com/ubuntu/ trusty/main python-pycurl amd64 7.19.3-0ubuntu3 [47.9 kB]
Get:2 https://in.archive.ubuntu.com/ubuntu/ trusty-updates/universe python-software-properties all 0.92.37.7 [19.6 kB]
Fetched 67.5 kB in 1s (45.9 kB/s)
Selecting previously unselected package python-pycurl.
(Reading database ... 218616 files and directories currently installed.)
Preparing to unpack .../python-pycurl_7.19.3-0ubuntu3_amd64.deb ...
Unpacking python-pycurl (7.19.3-0ubuntu3) ...
....................................................

次に、以下のようにfishのリポジトリを追加します。

$ sudo add-apt-repository ppa:fish-shell/nightly-master

実行結果は以下の通りです。

This repository contains regular builds of the most recent source of Fish shell, built from the Git master trunk at https://github.com/fish-shell/fish-shell/.

More info: https://launchpad.net/~fish-shell/+archive/ubuntu/nightly-master
Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keyring `/tmp/tmpzn3dsxqj/secring.gpg' created
gpg: keyring `/tmp/tmpzn3dsxqj/pubring.gpg' created
gpg: requesting key 6DC33CA5 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpzn3dsxqj/trustdb.gpg: trustdb created
gpg: key 6DC33CA5: public key "Launchpad PPA for Fish shell maintainers" imported
gpg: Total number processed: 1
gpg:               imported: 1 (RSA: 1)
OK

以下のコマンドでLinuxのパッケージ情報を更新します。

$ sudo apt-get update

続いて、以下のコマンドでfishをインストールします。

$ sudo apt-get install fish

実行すると、以下のような出力が表示されます。

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
    linux-headers-4.2.0-27 linux-headers-4.2.0-27-generic
    linux-image-4.2.0-27-generic linux-image-extra-4.2.0-27-generic
    linux-signed-image-4.2.0-27-generic
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
    xsel
The following NEW packages will be installed:
    fish xsel
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,187 kB of archives.
After this operation, 6,568 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://ppa.launchpad.net/fish-shell/nightly-master/ubuntu/ trusty/main fish amd64 2.2.0-680-ga701264-1~trusty [1,166 kB]
Get:2 https://in.archive.ubuntu.com/ubuntu/ trusty/universe xsel amd64 1.2.0-2 [20.6 kB]
Fetched 1,187 kB in 4s (284 kB/s)
.................................

Fishシェルの使い方

fishシェルのコマンドラインを起動するには、以下のコマンドを使用します。

$ fish

実行すると、以下のようなウェルカムメッセージが表示されます。

Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish

インストールされているfishのバージョンを確認するには、以下のコマンドを実行します。

$ echo $FISH_VERSION

実行結果は以下の通りです。

2.2.0-680-ga701264

自動補完(オートサジェスト)を試すには、たとえば「da」と入力してみてください。以下のように候補が自動的に表示されます。

$ date

実行結果は以下の通りです。

Tue Mar 15 11:29:50 IST 2016

fishに関する詳細な情報を確認したい場合は、以下のコマンドを使用します。

$ help

実行すると、ブラウザ上でドキュメントが開きます。

また、fishは入力内容に応じてリアルタイムで賢い色分けを行います。以下のコマンドでその挙動を確認できます。

$ echo "I am loving tutorialspoint "

実行結果は以下の通りです。

I am loving tutorialspoint

fishをデフォルトシェルに設定する

fishをデフォルトのログインシェルに変更するには、以下のコマンドを使用します。

$ chsh -s /usr/bin/fish

元のシェル(bashなど)に戻したい場合は、以下のコマンドを実行します。

$ chsh -s /bin/bash

おめでとうございます!これで「Fish – Linux向けのスマートで使いやすいインタラクティブシェル」の導入と基本操作をマスターできました。次回のLinux記事では、さらに便利なコマンドについて詳しく解説していきます。ぜひお楽しみに!

  1. Mac・Linuxで使えるおすすめIRCクライアント15選【2024年最新版】

    現代においてインターネットを利用する最大の目的はコミュニケーションです。私たちが今日享受しているあらゆるものを支える決定的な要素と言っても過言ではありません。インターネットがなければ、世界は間違いなく立ち止まってしまうでしょう。地理的な距離やその他の隔たりを埋め、世界を文字通り「グローバルビレッジ」へと変えたのがインターネットです。その背景には、既存のギャップを少しでも縮めようとするアプリケーションの革新と発展がありました。その代表格のひとつが、IRC(Internet Relay Chat)です。 IRCは無数のチャットルームが集まったハブであり、何百万人もの人々が雑談、交流、趣味の共有など

  2. サムスンSmart TVを使いこなすための6つのヒント・コツ・裏ワザ

    気づいているかどうかは別として、私たちは今やテクノロジーに囲まれた環境の中で暮らしています。ガジェット、家電、アプリが生活のあらゆる場所に存在し、その中でもスマートTVはスマートホームを構成する欠かせない存在となっています。一度スマートTVを使い始めると、従来のケーブルテレビの時代にはもう戻れなくなるでしょう。 特にサムスン(Samsung)のSmart TVは、プライベートリスニング、ライブキャスト、専用ゲームモード、スマートエコソリューション、ホスピタリティモードなど、多彩な機能を搭載しており、同カテゴリーの中でも最高クラスのデバイスと言えます。 サムスンSmart TVをすでにお持ちの