Add quick config edit script

This commit is contained in:
Riyyi
2019-08-04 00:49:54 +02:00
parent bb000f282e
commit 97dd1e9171
2 changed files with 30 additions and 3 deletions
+26
View File
@@ -0,0 +1,26 @@
#!/bin/sh
# Script that searches config files and scripts
# Define editor to open file in
EDITOR="$EDITOR"
# List of locations to search
LOCATIONS="$HOME/.config $HOME/.scripts"
# Find the files
FILES="$(find -L $LOCATIONS -maxdepth 3 -type f | sort)"
HOME="$(find -L $HOME -maxdepth 1 -type f | sort)"
# If no name provided
if [ -z "$1" ]; then
SELECTED="$(printf "%s\n%s" "$FILES" "$HOME" \
| uniq | rofi -dmenu -p "Select file to edit")"
# Else try to search for that file
else
SELECTED="$(printf "%s\n%s" "$FILES" "$HOME" | grep "$1" | head -n 1)"
fi
# Start editor with selected file (if any)
[ -n "$SELECTED" ] && $EDITOR "$SELECTED"