Skip to content

Instantly share code, notes, and snippets.

@yulijia
Last active August 29, 2015 14:04
Show Gist options
  • Save yulijia/cbfde71da612e58ceb29 to your computer and use it in GitHub Desktop.
Save yulijia/cbfde71da612e58ceb29 to your computer and use it in GitHub Desktop.
A easy way to generate a new souce code file and open it with editor (vim , gedit)
alias count='ll -h ./ |grep "^-" |wc -l'
alias win7='cd /run/media/root'
alias vi='vim'
__pl() { /root/bin/codefile.sh $1 "pl"; };
alias pl='__pl'
__md() { codefile.sh $1 "md"; };
alias md='__md'
__r() { codefile.sh $1 "r"; };
alias r='__r'
au BufRead,BufNewFile *.md set filetype=markdown
#!/bin/bash
time=`date`
authorname=`whoami`
if [[ -z $1 ]] ; then
echo $"couldn't find filename, please give a filename"
elif [[ "$2" == "pl" ]] ; then
touch $1.$2
echo "#!/usr/bin/perl -w" >> $1.$2
echo " " >> $1.$2
echo "# CODE_NAME: $1" >> $1.$2
echo "# DATE: $time" >> $1.$2
echo "# AUTHOR: $authorname" >> $1.$2
echo "# DESCRPTION: " >> $1.$2
echo "# " >> $1.$2
echo "# " >> $1.$2
# gedit $1.$2
vi $1.$2
:
elif [[ "$2" == "md" ]] ; then
touch $1.$2
echo "<!--" >> $1.$2
echo "# CODE_NAME: $1" >> $1.$2
echo "# DATE: $time" >> $1.$2
echo "# AUTHOR: $authorname" >> $1.$2
echo "# DESCRPTION: " >> $1.$2
echo "# " >> $1.$2
echo "# " >> $1.$2
echo "-->" >> $1.$2
gedit $1.$2
:
elif [[ "$2" == "r" ]] ; then
touch $1.R
echo "# CODE_NAME: $1" >> $1.R
echo "# DATE: $time" >> $1.R
echo "# AUTHOR: $authorijia" >> $1.R
echo "# DESCRPTION: " >> $1.R
echo "# " >> $1.R
echo "# " >> $1.R
# gedit $1.R
vi $1.R
:
#elif [[ "$2" == "py" ]] ; then
# touch $1.$2
# echo "<!--" >> $1.$2
# echo "# CODE_NAME: $1" >> $1.$2
# echo "# DATE: $time" >> $1.$2
# echo "# AUTHOR: $authorijia" >> $1.$2
# echo "# DESCRPTION: " >> $1.$2
# echo "# " >> $1.$2
# echo "# " >> $1.$2
codefile.sh
@yulijia
Copy link
Author

yulijia commented Jul 23, 2014

[root@localhost ~]# pl filename 
[root@localhost ~]# md filename 
[root@localhost ~]# r filename 

it works on Fedora.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment