Sample Header Ad - 728x90

Is there a way to have code templates for "if", "for" (or) for any multiline commands in terminal?

2 votes
0 answers
31 views
Code templates are handy and help in finishing codes without error. I am aware that notepad editors like atom provide code templates for
and
loop for bash. Also aware that
pages provide assistance in understanding the syntax. For e.g.,
$SHELL
helps to understand the
and
commands. But, I was wondering if there is a way to bring code templates into a terminal itself rather than using a code editor? This will help us to be more productive. Let me give a use case scenario. For this post to be solved, I wanted to have a
loop and then a
loop encased in that. So if a template for
loop can be generated by some shortcuts in the terminal such that
for i in **type words here**; do 
  
    **type words here** 
  
done
Then I go inside the for loop template and then click another shortcut for the
`
for i in **type words here**; do 
  
    if [ **type words here**]; then
       **type words here**     
    fi

done
Asked by Praveen Kumar-M (622 rep)
May 13, 2020, 08:35 AM