This is for the linux console junkies (like me) who edit their files mostly in a terminal.
As the ui-lovelace.yaml gets bigger and bigger, i wrote a little script that greps the views from the file and starts the editor at the line number with the selected view.
The script (for example, save it in ~/ui_edit.sh and make it executable):
#!/bin/bash
userhome=$(eval echo ~$user)
# Path to ui-lovelace.yaml
lovelace_yaml="$userhome/.homeassistant/ui-lovelace.yaml"
# Command to start the editor and the option to jump to a line number
# For example, nano jumps to line with +linenumber
editor='nano -SE -T2 +'
prompt="Please select a view:"
# Grep the lovelace.yaml for lines starting a view (' - title:')
options=( $(egrep '^ {2}- title:' -n $lovelace_yaml | awk '{print $4}') )
# Make some little menu with the views
PS3="$prompt "
echo '------------------------------------------------------'
select opt in "${options[@]}" "Quit" ; do
if (( REPLY == 1 + ${#options[@]} )) ; then
exit
elif (( REPLY > 0 && REPLY <= ${#options[@]} )) ; then
echo "You picked $opt ($REPLY)"
break
else
echo "Invalid option. Try another one."
fi
done
# Grep the lovelace.yaml once again for the ' title: <option>' and get the line number
lnum=$(egrep "^ {2}- title: ${opt}" -n $lovelace_yaml | awk -F ":" '{print $1}')
# Start the editor an jump to the line number
$editor$lnum $lovelace_yaml
I created an alias in .bashrc:
alias uiedit='~/ui_edit.sh'
Now when i type uiedit:
(ha) homeassi:~$ uiedit
------------------------------------------------------
1) Home 4) Mediaplayer 7) Cameras 10) System
2) Wetter 5) Milights 8) Miscellaneous 11) Quit
3) Baustelle 6) Covers 9) Tests
Please select a view: 9
You picked Tests (9)
The editor starts with the selected view
######################################################
### Tests
######################################################
- title: Tests
id: tests
#theme: PmxMononight
icon: mdi:flask-outline
cards:
- type: entities
...
Have fun!