Home
Packages
Forums
Wiki
GitLab
Security
AUR
Download
コンテンツにスキップ
メインメニュー
メインメニュー
サイドバーに移動
非表示
案内
メインページ
目次
コミュニティに貢献
最近の出来事
おまかせ表示
特別ページ
交流
ヘルプ
貢献
最近の更新
最近の議論
新しいページ
統計
リクエスト
ArchWiki
検索
検索
表示
アカウント作成
ログイン
個人用ツール
アカウント作成
ログイン
Rangerのソースを表示
ページ
議論
日本語
閲覧
ソースを閲覧
履歴を表示
ツール
ツール
サイドバーに移動
非表示
操作
閲覧
ソースを閲覧
履歴を表示
全般
リンク元
関連ページの更新状況
ページ情報
表示
サイドバーに移動
非表示
←
Ranger
あなたには「このページの編集」を行う権限がありません。理由は以下の通りです:
この操作は、次のグループに属する利用者のみが実行できます:
登録利用者
。
このページのソースの閲覧やコピーができます。
{{DISPLAYTITLE:ranger}} [[Category:ファイルマネージャ]] [[ar:Ranger]] [[en:Ranger]] [[fr:ranger]] [[zh-CN:Ranger]] {{Related articles start}} {{Related|Midnight Commander}} {{Related|vifm}} {{Related articles end}} '''ranger''' は Python で書かれているテキストベースのファイルマネージャです。ディレクトリは3つのカラムに分けて表示されます。キーストロークやブックマーク、マウスやコマンド履歴を使ってディレクトリを移動することができます。選択したファイルは自動的にプレビューが表示されディレクトリは中身が表示されます。 ranger の特徴: vi スタイルのキーバインド、ブックマーク、選択、タグ、タブ、コマンド履歴、シンボリックリンクを作成可能、複数あるコンソールモード、タスク表示。''ranger'' のコマンドやキーバインドはカスタマイズすることができ、外部スクリプトを呼び出すこともできます。よく似たファイルマネージャに [[Vifm]] があり、2つのペインと vi スタイルのキーバインドを使用しますが、機能の数はやや劣ります。 == インストール == {{Pkg|ranger}} は[[公式リポジトリ]]から[[インストール]]できます。開発版を使いたい場合は [[AUR]] から {{AUR|ranger-git}} をインストールしてください。{{ic|scope.sh}} によるファイルプレビューの使用など、任意の依存パッケージは ranger-git の [https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=ranger-git PKGBUILD] に説明があります。 == 使用方法 == ranger を起動するには、まず[[アプリケーション一覧#ターミナルエミュレータ|ターミナル]]を起動して、そこから {{ic|ranger}} を実行してください。 {| class="wikitable" |+ ! キー !! コマンド |- | {{ic|?}} || マニュアルを開く |- | {{ic|1?}} || キーバインドを表示 |- | {{ic|2?}} || コマンドを表示 |- | {{ic|3?}} || 設定を表示 |- | {{ic|l}}, {{ic|Enter}} || ファイルを起動 |} == 設定 == 起動後、''ranger'' は {{ic|~/.config/ranger}} ディレクトリを作成します。デフォルト設定をこのディレクトリにコピーしたいときは次のコマンドを実行してください: ranger --copy-config=all * {{ic|rc.conf}} - スタートアップコマンドとキーバインド * {{ic|commands.py}} - {{ic|:}} で起動するコマンド * {{ic|rifle.conf}} - 特定のファイルを起動した時に使われるアプリケーション デフォルトファイルもロードされるので {{ic|rc.conf}} にはデフォルトファイルとの差異部分だけを記述します。{{ic|commands.py}} には、ファイル全体をインクルードしない場合、一番最初に以下の行を記述します: from ranger.api.commands import * 作成したディレクトリ {{ic|~/.Trash/}} に {{ic|DD}} でファイルを移動するキーバインドを追加するには、{{ic|~/.config/ranger/rc.conf}} に以下を追記します: map DD shell mv -t /home/${USER}/.Trash %s 設定に関する詳細は [http://ranger.nongnu.org/ranger.1.html man ranger] を見て下さい。 === コマンドの定義 === Continuing the above example, add the following entry to {{ic|~/.config/ranger/commands.py}} to empty the trash directory {{ic|~/.Trash}}. {{bc|<nowiki> class empty(Command): """:empty Empties the trash directory ~/.Trash """ def execute(self): self.fm.run("rm -rf /home/myname/.Trash/{*,.[^.]*}") </nowiki>}} To use it, type {{ic|:empty}} and {{ic|Enter}} with tab completion as desired. {{Warning|{{ic|[^.]}} is an essential part of the above command. Without it, all files and directories of the form {{ic|..*}} will be deleted, wiping out everything in your home directory.}} === カラースキーム === {{ic|~/.config/ranger}} に {{ic|colorschemes}} サブフォルダを作成してください: $ mkdir ~/.config/ranger/colorschemes それから新しい {{ic|''newscheme''.py}} を上記のフォルダにコピーします。{{ic|~/.config/ranger/rc.conf}} ファイルからデフォルトカラースキームを変更してください: set colorscheme ''newscheme'' === ファイルの関連付け === {{ic|~/.config/ranger/rifle.conf}} を編集してください。先の行が早く実行されるので、ファイルの先頭に追記するようにしてください。例えば、tex ファイルを {{Pkg|kile}} で開くには以下のエントリを記述します: ext tex = kile "$@" {{Pkg|xdg-utils}} で全てのファイルを開くようにするには: has xdg-open, flag f = xdg-open "$1" == Tips and tricks == === 圧縮ファイル === These commands use {{Pkg|atool}} to perform archive operations. ==== アーカイブの解凍 ==== The following command implements archive extraction by copying (yy) one or more archive files and then executing {{ic|:extracthere}} on the desired directory. {{bc|<nowiki> import os from ranger.core.loader import CommandLoader class extracthere(Command): def execute(self): """ Extract copied files to current directory """ copied_files = tuple(self.fm.copy_buffer) if not copied_files: return def refresh(_): cwd = self.fm.get_directory(original_path) cwd.load_content() one_file = copied_files[0] cwd = self.fm.thisdir original_path = cwd.path au_flags = ['-X', cwd.path] au_flags += self.line.split()[1:] au_flags += ['-e'] self.fm.copy_buffer.clear() self.fm.cut_buffer = False if len(copied_files) == 1: descr = "extracting: " + os.path.basename(one_file.path) else: descr = "extracting files from: " + os.path.basename(one_file.dirname) obj = CommandLoader(args=['aunpack'] + au_flags \ + [f.path for f in copied_files], descr=descr) obj.signal_bind('after', refresh) self.fm.loader.add(obj) </nowiki>}} ==== 圧縮 ==== The following command allows the user to compress several files on the current directory by marking them and then calling {{ic|:compress ''package name''}}. It supports name suggestions by getting the basename of the current directory and appending several possibilities for the extension. You need to have {{pkg|atool}} installed. Otherwise you will see an error message when you create the archive. {{bc|<nowiki> import os from ranger.core.loader import CommandLoader class compress(Command): def execute(self): """ Compress marked files to current directory """ cwd = self.fm.thisdir marked_files = cwd.get_selection() if not marked_files: return def refresh(_): cwd = self.fm.get_directory(original_path) cwd.load_content() original_path = cwd.path parts = self.line.split() au_flags = parts[1:] descr = "compressing files in: " + os.path.basename(parts[1]) obj = CommandLoader(args=['apack'] + au_flags + \ [os.path.relpath(f.path, cwd.path) for f in marked_files], descr=descr) obj.signal_bind('after', refresh) self.fm.loader.add(obj) def tab(self): """ Complete with current folder name """ extension = ['.zip', '.tar.gz', '.rar', '.7z'] return ['compress ' + os.path.basename(self.fm.thisdir.path) + ext for ext in extension] </nowiki>}} === 外付けドライブ === 外付けドライブは [[udev]] や [[udisks]] で自動的にマウントさせることができます。{{ic|gm}} (go, media) を押すことで {{ic|/media}} にマウントされたドライブに簡単にアクセスできます。 === イメージのマウント === 以下のコマンドではイメージのマウントに [[CDemu]] を使用し、仮想ドライブを特定の場所 (この例では '/media/virtualrom') にマウントするために [[autofs]] などのシステムを利用します。マウントパスはあなたの設定に合わせて変更するようにしてください。 ranger から cdemud 仮想ドライブにイメージをマウントするには、イメージファイルを選択してコンソールに ':mount' と入力します。実際のマウントには設定によって多少時間がかかるので、カスタムローダーを使ってマウントディレクトリがマウントされるまで待機してからタブ 9 で裏で開くようにします。 {{bc|<nowiki> import os, time from ranger.core.loader import Loadable from ranger.ext.signals import SignalDispatcher from ranger.ext.shell_escape import * class MountLoader(Loadable, SignalDispatcher): """ Wait until a directory is mounted """ def __init__(self, path): SignalDispatcher.__init__(self) descr = "Waiting for dir '" + path + "' to be mounted" Loadable.__init__(self, self.generate(), descr) self.path = path def generate(self): available = False while not available: try: if os.path.ismount(self.path): available = True except: pass yield time.sleep(0.03) self.signal_emit('after') class mount(Command): def execute(self): selected_files = self.fm.thisdir.get_selection() if not selected_files: return space = ' ' self.fm.execute_command("cdemu -b system unload 0") self.fm.execute_command("cdemu -b system load 0 " + \ space.join([shell_escape(f.path) for f in selected_files])) mountpath = "/media/virtualrom/" def mount_finished(path): currenttab = self.fm.current_tab self.fm.tab_open(9, mountpath) self.fm.tab_open(currenttab) obj = MountLoader(mountpath) obj.signal_bind('after', mount_finished) self.fm.loader.add(obj) </nowiki>}} === 現在のフォルダを新しいタブで開く === You may have noticed there are two shortcuts for opening a new tab in home ({{ic|g}}{{ic|n}} and {{ic|Ctrl+n}}). Let us rebind {{ic|Ctrl+n}}: {{hc|rc.conf|<nowiki> map <c-n> eval fm.tab_new('%d') </nowiki>}} === シェルの小技 === ==== パスの同期 ==== ''ranger'' はシェル[[Bash/Functions|関数]] {{ic|/usr/share/doc/ranger/examples/bash_automatic_cd.sh}} を提供しています。{{ic|ranger}} ではなく {{ic|ranger-cd}} を実行すると、最後に閲覧したフォルダに自動的に ''cd'' されます。 グラフィカルランチャーから ranger を起動した場合 ({{ic|$TERMCMD -e ranger}} など、TERMCMD は X ターミナル)、{{ic|ranger-cd}} は使えません。実行可能属性を付与したスクリプトを作成して: {{hc|ranger-launcher.sh|<nowiki> #!/bin/sh export RANGERCD=true $TERMCMD </nowiki>}} シェルの設定の''できるだけ最後''に以下を追加してください: {{hc|.''shell''rc|<nowiki> $RANGERCD && unset RANGERCD && ranger-cd </nowiki>}} This will launch {{ic|ranger-cd}} only if the {{ic|RANGERCD}} variable is set. It is important to unset this variable again, otherwise launching a subshell from this terminal will automatically relaunch {{ic|ranger}}. ==== ranger からシェルを起動 ==== With the previous method you can switch to a shell in last browsed path simply by leaving ranger. However you may not want to quit ranger for several reasons (numerous opened tabs, copy in progress, etc.). You can start a shell from ranger ({{ic|S}} by default) without losing your ranger session. Unfortunately, the shell will not switch to the current folder automatically. Again, this can be solved with an executable script: {{hc|shellcd|<nowiki> #!/bin/sh export AUTOCD="$(realpath "$1")" $SHELL </nowiki>}} and - as before - add this to at the very end of your shell configuration: {{hc|shellrc|<nowiki> cd "$AUTOCD" </nowiki>}} Now you can change your shell binding for ranger: {{hc|rc.conf| map S shell shellcd %d }} Alternatively, you can make use of your shell history file if it has any. For instance, you could do this for [[zsh#ディレクトリスタック|zsh]]: {{hc|shellcd|<nowiki> ## Prepend argument to zsh dirstack. BUF="$(realpath "$1") $(grep -v "$(realpath "$1")" "$ZDIRS")" echo "$BUF" > "$ZDIRS" zsh </nowiki>}} Change ZDIRS for your dirstack. ==== ranger が現在のシェルで動いていない場合にのみ ranger の新しいインスタンスを起動 ==== [[自動起動#シェル|シェルのスタートアップファイル]]に以下を記述してください: rg() { if [ -z "$RANGER_LEVEL" ] then ranger else exit fi } Execute {{ic|rg}} to start or restore ranger. == トラブルシューティング == === 画像のプレビューでブロックノイズ === カラムのボーダーをなくすと画像プレビューでストライプが見えることがあります [https://bbs.linuxdistrocommunity.com/showthread.php?tid=1051]。{{ic|~/.config/ranger/rc.conf}} に以下を設定: set draw_borders true == 参照 == * [https://bbs.archlinux.org/viewtopic.php?id=93025 BBS thread] * [http://dotshare.it/category/fms/ranger/ DotShare.it configurations] * [http://github.com/hut/ranger GitHub] * [https://www.digitalocean.com/community/tutorials/installing-and-using-ranger-a-terminal-file-manager-on-a-ubuntu-vps Installing and using ranger] * [https://lists.nongnu.org/mailman/listinfo/ranger-users メーリングリスト] * [http://nongnu.org/ranger 公式ウェブサイト] * [http://bloerg.net/2012/10/17/ranger-file-manager.html Ranger チュートリアル]
このページで使用されているテンプレート:
テンプレート:AUR
(
ソースを閲覧
)
テンプレート:Bc
(
ソースを閲覧
)
テンプレート:Hc
(
ソースを閲覧
)
テンプレート:Ic
(
ソースを閲覧
)
テンプレート:META Related articles start
(
ソースを閲覧
)
テンプレート:Pkg
(
ソースを閲覧
)
テンプレート:Related
(
ソースを閲覧
)
テンプレート:Related articles end
(
ソースを閲覧
)
テンプレート:Related articles start
(
ソースを閲覧
)
テンプレート:Warning
(
ソースを閲覧
)
Ranger
に戻る。
検索
検索
Rangerのソースを表示
話題を追加