Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
public:vimbashfactory [2010/08/23 23:12] Nicopublic:vimbashfactory [2022/08/04 15:31] (current) – fix indent Nico
Line 1: Line 1:
-====== How to quickly create fully fonctionnal shell scripts using VIM ====== +====== How to quickly create fully functional shell scripts using VIM ======
  
   * Download the [[http://www.vim.org/scripts/script.php?script_id=1172|VIM template script]]   * Download the [[http://www.vim.org/scripts/script.php?script_id=1172|VIM template script]]
   * Install it (:source path_to_vim_script)   * Install it (:source path_to_vim_script)
   * Create the following script in .vim/templates/sh:   * Create the following script in .vim/templates/sh:
-<code> + 
-#!/bin/bash+<code bash
 +#!/bin/sh
  
 VERSION="$0 v1.0" VERSION="$0 v1.0"
Line 28: Line 28:
  
 #echo $# #echo $#
-if [ $# == 0 ] ; then echo "Please type $0 --help for help" >&2 ; exit 1 ; fi+if [ $# -lt 1 ] ; then echo "Please type $0 --help for help" >&2 ; exit 1 ; fi
  
 eval set -- "$TEMP" eval set -- "$TEMP"
Line 59: Line 59:
 exit 0 exit 0
 </code> </code>
 +
   * Add the following line in .vimrc:   * Add the following line in .vimrc:
-<code>+ 
 +<code vim>
   au BufWritePost * if getline(1) =~ "^#!" | if getline(1) =~ "/bin/" | silent !chmod a+x <afile> | endif | endif   au BufWritePost * if getline(1) =~ "^#!" | if getline(1) =~ "/bin/" | silent !chmod a+x <afile> | endif | endif
 </code> </code>
  
   * That's it! next time you will edit a new .sh file, it will load the template and automagicaly made it executable :)   * That's it! next time you will edit a new .sh file, it will load the template and automagicaly made it executable :)
 +