Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/JohanChane/ranger-quit_cd_wd
Ranger plugin.
https://github.com/JohanChane/ranger-quit_cd_wd
Last synced: 2 months ago
JSON representation
Ranger plugin.
- Host: GitHub
- URL: https://github.com/JohanChane/ranger-quit_cd_wd
- Owner: JohanChane
- License: mit
- Created: 2022-08-23T08:40:50.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-06T08:50:55.000Z (8 months ago)
- Last Synced: 2024-08-03T18:21:13.450Z (6 months ago)
- Language: Python
- Homepage:
- Size: 7.81 KB
- Stars: 13
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- ranger-awesome - ranger-quit\_cd\_wd
README
# Quit ranger then cd working directory
## Description
Sometime you need to open a terminal on ranger working directory to do some jobs. Ranger provides `S` shortcut to do this, but I don't like this. And the `quit` command in ranger doesn't keep the working directory in ranger. So I make this plugin. I can also jump to my bookmarks (paths) in ranger quickly.
## Installation
1. Copy `quit_cd_wd.py` to `${XDG_CONFIG_HOME}/ranger/plugins`.
```sh
curl -fLo ${XDG_CONFIG_HOME:-~/.config}/ranger/plugins/quit_cd_wd.py --create-dirs \
https://raw.githubusercontent.com/JohanChane/ranger-quit_cd_wd/main/quit_cd_wd.py
```2. [optional] Add the following mapping to the `rc.conf`
```
# Equivalent to `map X quitall_cd_wd ~/.cache/ranger/quit_cd_wd`
map X quitall_cd_wd
# OR customize the path
map X quitall_cd_wd
```3. Add the following to your shell rcfile (e.g. `.bashrc, .zshrc`)
```sh
function ranger {
local quit_cd_wd_file="$HOME/.cache/ranger/quit_cd_wd" # The path must be the same as in map.
#command ranger "$@" # If you have already added the map to rc.conf
# OR add `map X quitall_cd_wd ...` if you don't want to add the map in rc.conf
command ranger --cmd="map X quitall_cd_wd $quit_cd_wd_file" "$@"
if [ -s "$quit_cd_wd_file" ]; then
cd "$(cat $quit_cd_wd_file)"
true > "$quit_cd_wd_file"
fi
}
```