Open In App

Shell Scripting – How do we can create a sample ~/.dialogrc file

Last Updated : 02 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The dialog command allows you to display a variety of questions or messages from a shell script using dialog boxes. The ~/.dialogrc file is a run-time configuration file for dialog commands. Basically, it is the default configuration file. Also, the  ~/.dialogrc file allows us to customize various aspects of the dialog command. If you do not have the dialog command installed, run the following commands to install it:

sudo apt-get install dialog

 

Steps for creating a sample ~/.dialogrc file using bash scripting. 

Step 1: Create a bash file with extension .sh using the vim editor. Here other editors such as nano, and gedit can also be used at user convenience.

 

Step 2: Adding script into the bash script file i.e. bash.sh for creating the sample dialogrc file.

Bash Script for creating dialogrc file

#!/bin/bash

dialog --create-rc ~/.dialogrc

Output:

Bash Script for creating dialogrc file

Step 3: Now, after successfully saving the bash script, we need to execute the script using the command given below 

sh bash.sh

Above command will run the bash script in the bash.sh file and as a result a sample ~/.dialogrc file is created.

We can view the content of the sample ~/.dialogrc file using the below command

vi ~/.dialogrc

 

Output : 

The content of our sample ~/.dialogrc file was as given below :

# Run-time configuration file for dialog
#
# Automatically generated by "dialog --create-rc <file>"
#
#
# Types of values:
#
# Number     -  <number>
# String     -  "string"
# Boolean    -  <ON|OFF>
# Attribute  -  (foreground,background,highlight?)
# Set aspect-ration.
aspect = 0

# Set separator (for multiple widgets output).
separate_widget = ""

# Set tab-length (for textbox tab-conversion).
tab_len = 0

# Make tab-traversal for checklist, etc., include the list.
visit_items = OFF

# Shadow dialog boxes? This also turns on color.
use_shadow = ON

# Turn color support ON or OFF
use_colors = ON

# Screen color
screen_color = (CYAN,GREEN,ON)

# Shadow color
shadow_color = (BLACK,BLACK,ON)

# Dialog box color
dialog_color = (BLACK,WHITE,OFF)

# Dialog box title color
title_color = (BLUE,WHITE,ON)

# Dialog box border color
border_color = (WHITE,WHITE,ON)

# Active button color
button_active_color = (WHITE,BLUE,ON)

# Inactive button color
button_inactive_color = (BLACK,WHITE,OFF)

# Active button key color
button_key_active_color = (WHITE,BLUE,ON)

# Inactive button key color
button_key_inactive_color = (RED,WHITE,OFF)

# Active button label color
button_label_active_color = (YELLOW,BLUE,ON)

# Inactive button label color
button_label_inactive_color = (BLACK,WHITE,ON)

# Input box color
inputbox_color = (BLACK,WHITE,OFF)

# Input box border color
inputbox_border_color = (BLACK,WHITE,OFF)

# Search box color
searchbox_color = (BLACK,WHITE,OFF)

# Search box title color
searchbox_title_color = (BLUE,WHITE,ON)

# Search box border color
searchbox_border_color = (WHITE,WHITE,ON)

# File position indicator color
position_indicator_color = (BLUE,WHITE,ON)

# Menu box color
menubox_color = (BLACK,WHITE,OFF)

# Menu box border color
menubox_border_color = (WHITE,WHITE,ON)

# Item color
item_color = (BLACK,WHITE,OFF)

# Selected item color
item_selected_color = (WHITE,BLUE,ON)

# Tag color
tag_color = (BLUE,WHITE,ON)

# Selected tag color
tag_selected_color = (YELLOW,BLUE,ON)

# Tag key color
tag_key_color = (RED,WHITE,OFF)

# Selected tag key color
tag_key_selected_color = (RED,BLUE,ON)

# Check box color
check_color = (BLACK,WHITE,OFF)

# Selected check box color
check_selected_color = (WHITE,BLUE,ON)

# Up arrow color
uarrow_color = (GREEN,WHITE,ON)

# Down arrow color
darrow_color = (GREEN,WHITE,ON)

# Item help-text color
itemhelp_color = (WHITE,BLACK,OFF)

# Active form text color
form_active_text_color = (WHITE,BLUE,ON)

# Form text color
form_text_color = (WHITE,CYAN,ON)

# Readonly form item color
form_item_readonly_color = (CYAN,WHITE,ON)

The screenshots of the sample ~/.dialogrc file created through the execution of bash.sh.

 

 

 

 

 

Conclusion :

Thus, we successfully created a sample ~/.dialogrc file using bash scripting.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads