mirror of
https://github.com/elenapan/dotfiles.git
synced 2025-12-26 15:14:58 +08:00
Add new script rofi_edit for quickly editing dotfiles
This commit is contained in:
parent
4534055094
commit
f811e6116c
1 changed files with 35 additions and 0 deletions
35
bin/rofi_edit
Executable file
35
bin/rofi_edit
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
# Rofi menu for quickly editing a file in some directory
|
||||
# Requires ripgrep
|
||||
# I use it for editing dotfiles in my ~/.config directory
|
||||
|
||||
# Directory to search in
|
||||
dir="$HOME/.config"
|
||||
# Ignore files or directories relative to the directory you want to search
|
||||
ignore="
|
||||
chromium
|
||||
enchant
|
||||
mpv/watch_later
|
||||
ncmpcpp/lyrics
|
||||
transmission/torrents
|
||||
transmission/resume
|
||||
Ganache"
|
||||
|
||||
ignore_file="/tmp/rofi_edit_ignore_file"
|
||||
# Write ignore file in tmpfs
|
||||
echo "$ignore" > "$ignore_file"
|
||||
|
||||
# Rofi prompt
|
||||
rofi_prompt="Edit dotfile"
|
||||
|
||||
# Change directory so that the paths are shorter in rofi
|
||||
cd "$dir" || exit
|
||||
choice="$(rg --files --color=never --ignore-file "$ignore_file" | rofi -no-disable-history -sort -i -p "$rofi_prompt" -dmenu -fuzzy)"
|
||||
|
||||
# If the search is cancelled by the user (e.g. Escape button)
|
||||
if [[ -z "${choice// }" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Edit the selected file
|
||||
kitty -1 -e nvim "$choice"
|
||||
Loading…
Add table
Add a link
Reference in a new issue