LoginSignup
67
52

More than 5 years have passed since last update.

rmコマンドでゴミ箱へ移動するようにする

Last updated at Posted at 2017-01-29

rmコマンドを使うと、ゴミ箱を経由せずに直接削除されますが、間違えて削除してしまうと大変なことになります。
そこで、trash-cliというコマンドを導入し、rmコマンドを使用した際にファイルをゴミ箱へ移動するようにしてみたいと思います。

インストール

  1. sudo apt install gitコマンドを実行し、gitをインストールします。
  2. git clone https://github.com/andreafrancia/trash-cliコマンドを実行し、trash-cliをダウンロードします。
  3. cd trash-cliコマンドを実行し、ダウンロードしたディレクトリに移動します。
  4. sudo python setup.py installコマンドを実行し、trash-cliをインストールします。

rmコマンド置換

  1. ~/.bashrcの末尾に以下を追記します。

    if type trash-put &> /dev/null
    then
        alias rm=trash-put
    fi
    
  2. source ~/.bashrcコマンドを実行し、.bashrcへの変更を反映します。

trash-cliの使い方

ゴミ箱にあるファイルの一覧表示

$ trash-list

ゴミ箱にあるファイルを元に戻す

$ trash-restore

ゴミ箱を空にする

$ trash-empty

ゴミ箱の中のファイルを完全に削除する

$ trash-rm {ファイル名}

参考文献

67
52
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
67
52