Enhance your terminal experience with these .bashrc functions.
Add file select for cd with cds
, cd
in terminal to the ranger
current working directory on quit with rcd
, open file explorer in the ranger current working directory on quit with re
, and search with google in new tab in default browser with g
.
Copy the text in bash-config.txt and paste into your .bashrc. Update your bash config with $. ~/.bashrc
to get started
- Install
ranger
sudo apt install ranger
- Adding Functions to .bashrc
To use these functions, you'll need to add them to your .bashrc config file.
The .bashrc file is usually found in ~/.bashrc
(/home/{user}/.bashrc
)
Copy and paste the functions provided into the file.
- Reload .bashrc
Run
bash
$ source ~/.bashrc
-
cds
: CD with File SelectorPurpose: Navigate through directories or open files directly from the command line, with optional support for hidden files. Uses home row first key bindings for index selection. Usage: To use the file selector, simply type cds in your terminal. For including hidden files in the list, use cds -a.
-
rcd
: Open CWD from Ranger in TerminalPurpose: Launch the Ranger file explorer from the current working directory (CWD) and return to the terminal in the selected directory upon exiting Ranger. Usage: Type rcd to open Ranger. Navigate to your desired directory, then quit Ranger (:q) to change your terminal's current directory to the selected one.
-
re
: Open CWD from Ranger in Windows File ExplorerPurpose: Similar to rcd, but opens the selected directory in Windows File Explorer, useful for WSL users. Usage: Type re to launch Ranger. Navigate and select your directory, then quit Ranger to open it in Windows File Explorer.
-
g
: Google SearchPurpose: Perform a Google search directly from your terminal. Usage: Type g followed by your search query. Example: g openai documentation.
Customization: Feel free to adjust the key bindings or modify the commands to fit your workflow. Compatibility: These functions are designed for use in Bash on Linux or WSL. Ensure compatibility with your system before use.