├── .gitignore ├── LICENSE ├── README.md ├── rofi-files └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | .mypy_cache/ 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Caleb Bassi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rofi-files 2 | 3 | Use [rofi](https://github.com/DaveDavenport/rofi) to search files and directories with [fd](https://github.com/sharkdp/fd) and open them with `xdg-open`. 4 | 5 | Install with: 6 | 7 | ```bash 8 | pip install --user git+https://github.com/cjbassi/rofi-files 9 | ``` 10 | -------------------------------------------------------------------------------- /rofi-files: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import subprocess 4 | 5 | if __name__ == '__main__': 6 | 7 | files = subprocess.run('fd', encoding='utf-8', 8 | capture_output=True).stdout.split('\n') 9 | 10 | title = 'rofi-files' 11 | rofi_command = 'rofi -dmenu -i -p {}'.format(title) 12 | rofi_input = '\n'.join(file for file in files) 13 | cp = subprocess.run(rofi_command.split(), input=rofi_input, 14 | encoding='utf-8', capture_output=True) 15 | 16 | if cp.returncode == 0: 17 | file = cp.stdout.strip() 18 | xdg_command = ['xdg-open', file] 19 | subprocess.run(xdg_command, 20 | encoding='utf-8', capture_output=True) 21 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from setuptools import setup 4 | 5 | setup( 6 | name='rofi-files', 7 | version='0.1.2', 8 | scripts=['rofi-files'], 9 | url='https://github.com/cjbassi/rofi-files', 10 | ) 11 | --------------------------------------------------------------------------------