Made scripts more readable by moving most logic to functions.
This commit is contained in:
		
							parent
							
								
									86e3a3a79c
								
							
						
					
					
						commit
						5c738fdc77
					
				
					 11 changed files with 234 additions and 133 deletions
				
			
		|  | @ -1,9 +1,6 @@ | |||
| #!/bin/env bash | ||||
| 
 | ||||
| # a script to quickly open up one of my many configs | ||||
| 
 | ||||
| source $HOME/.config/dmenu/config | ||||
| 
 | ||||
| editor="$TERMINAL -e $EDITOR" | ||||
| 
 | ||||
| declare -a configs=( | ||||
|  | @ -29,11 +26,21 @@ declare -a configs=( | |||
|     "xinitrc - $HOME/.config/X11/xinitrc" | ||||
| ) | ||||
| 
 | ||||
| choice=$(printf '%s\n' "${configs[@]}" | $DMENU -l 10 -p 'Edit config:') | ||||
| load_config () { | ||||
|     source $HOME/.config/dmenu/config | ||||
| } | ||||
| 
 | ||||
| [ -z "$choice" ] && exit | ||||
| main () { | ||||
|     load_config | ||||
| 
 | ||||
| [ "$choice" = "Quit" ] && exit | ||||
|     choice=$(printf '%s\n' "${configs[@]}" | $DMENU -l 10 -p 'Edit config:') | ||||
| 
 | ||||
| cfg=$(printf '%s\n' "${choice}" | awk '{print $NF}') | ||||
| $editor "$cfg" | ||||
|     [ -z "$choice" ] && exit | ||||
| 
 | ||||
|     [ "$choice" = "Quit" ] && exit | ||||
| 
 | ||||
|     cfg=$(printf '%s\n' "${choice}" | awk '{print $NF}') | ||||
|     $editor "$cfg" | ||||
| } | ||||
| 
 | ||||
| main $@ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue