From d8054026033e1ff492dee7bf92b35627e62b9979 Mon Sep 17 00:00:00 2001 From: We-unite <3205135446@qq.com> Date: Sat, 6 Jan 2024 18:28:24 +0800 Subject: Update vim scripts in use and my shell scripts. --- README.md | 3 ++ mypath/compare.sh | 14 ++++++ mypath/count.sh | 30 ++++++++++++ mypath/dif.sh | 10 ++++ mypath/exe.sh | 24 ++++++++++ mypath/g.sh | 22 +++++++++ mypath/gitadd.sh | 45 ++++++++++++++++++ mypath/gitk.sh | 2 + mypath/md2html.sh | 29 ++++++++++++ mypath/runjv.c | 39 ++++++++++++++++ mypath/runjv.sh | 17 +++++++ vim/vimrc | 12 ++--- vim/vimrcs/autocmd.vim | 81 -------------------------------- vim/vimrcs/codecmd.vim | 116 ++++++++++++++++++++++++++++++++++++++++++++++ vim/vimrcs/fuck.vim | 69 --------------------------- vim/vimrcs/match.vim | 9 ++-- vim/vimrcs/myset.vim | 57 ++++++----------------- vim/vimrcs/plugs.vim | 52 +++++++++++---------- vim/vimrcs/statusline.vim | 69 +++++++++++++++++++++++++++ 19 files changed, 475 insertions(+), 225 deletions(-) create mode 100644 README.md create mode 100755 mypath/compare.sh create mode 100755 mypath/count.sh create mode 100755 mypath/dif.sh create mode 100755 mypath/exe.sh create mode 100755 mypath/g.sh create mode 100755 mypath/gitadd.sh create mode 100755 mypath/gitk.sh create mode 100755 mypath/md2html.sh create mode 100644 mypath/runjv.c create mode 100755 mypath/runjv.sh delete mode 100644 vim/vimrcs/autocmd.vim create mode 100644 vim/vimrcs/codecmd.vim delete mode 100644 vim/vimrcs/fuck.vim create mode 100644 vim/vimrcs/statusline.vim diff --git a/README.md b/README.md new file mode 100644 index 0000000..3fd6798 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +[Pardon?] + +这里是我自己用的一些代码的暂存。 diff --git a/mypath/compare.sh b/mypath/compare.sh new file mode 100755 index 0000000..2643b42 --- /dev/null +++ b/mypath/compare.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +file1="file1.txt" +file2="file2.txt" + +diff_output=$(diff "$file1" "$file2") + +if [ -z "$diff_output" ]; then + echo "两个文件完全一致" +else + echo "两个文件不完全一致" + echo "$diff_output" +fi + diff --git a/mypath/count.sh b/mypath/count.sh new file mode 100755 index 0000000..5105b42 --- /dev/null +++ b/mypath/count.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +count_lines() { + local filename=$1 + local sum=0 + local buf + + while IFS= read -r buf; do + ((sum++)) + done < "$filename" + + echo "$sum" +} + +extensions=("c" "tex" "cpp" "py" "h") +sum=0 + +for extension in "${extensions[@]}"; do + files=$(find . -type f -name "*.$extension") + for file in $files; do + tmp=$(count_lines "$file") + ((sum+=tmp)) + echo "文件路径: $file" + echo "行数: $tmp" + echo + done +done + +echo "总行数: $sum" + diff --git a/mypath/dif.sh b/mypath/dif.sh new file mode 100755 index 0000000..138522e --- /dev/null +++ b/mypath/dif.sh @@ -0,0 +1,10 @@ +#!/bin/bash +diff_output=$(diff "$1" "$2") + +if [ -z "$diff_output" ];then + echo "The two files are totally the same!" +else + echo "There's something different: " + echo "$diff_output" +fi +exit 0 diff --git a/mypath/exe.sh b/mypath/exe.sh new file mode 100755 index 0000000..0588058 --- /dev/null +++ b/mypath/exe.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# 检查参数个数 +if [ $# -ne 1 ]; then + echo "参数个数错误!" + exit 1 +fi + +if [ $1 == "run" ]; then + for file in *.sh; do + filename="${file%.*}" + ln -s "$file" "$filename" + done + echo "软链接创建完成!" +elif [ $1 == "del" ];then + for file in *.sh; do + filename="${file%.*}" + rm -f "$filename" + done + echo "软链接删除成功!" +else + echo "参数错误!" + exit 1 +fi diff --git a/mypath/g.sh b/mypath/g.sh new file mode 100755 index 0000000..27a1bc0 --- /dev/null +++ b/mypath/g.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# 检查参数数量,小于一报错 +# if [ $# -e 0 ]; then +# echo "请提供一个文件名作为参数" +# exit 1 +# fi + +filename=$1 +extension="${filename##*.}" # 获取文件名的扩展名部分 + +# 检查文件后缀并执行相应的编译命令 +if [ "$extension" = "c" ]; then + gcc -g -o "${filename%.*}" -g "$filename" $2 +elif [ "$extension" = "cpp" ]; then + g++ -g -o "${filename%.*}" -g "$filename" $2 +else + echo "不支持的文件类型" + exit 1 +fi + +exit 0 diff --git a/mypath/gitadd.sh b/mypath/gitadd.sh new file mode 100755 index 0000000..79e750f --- /dev/null +++ b/mypath/gitadd.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +read -p "Local repo name: " local_name +read -p "Remote repo name: " remote_name + +# 远程仓库创建 +tmp="ssh aliyun-git git init --bare $remote_name.git" +eval "$tmp" + +# 本地仓库创建 +mkdir "$local_name" +cd "$local_name" +git init + +# 本地仓库初始化 +# 编写.gitignore +cat > .gitignore << EOF +*.sh +*.bat +*.exe +*.[oa] +*.pyc +__pycache__ +*.vscode +*.swp +EOF + +# 编写push.sh +cat > push.sh << EOF +git add . +git commit +git push +EOF +chmod +x push.sh + +# 提交初始化commit +git add . +git commit -m "Initial commit" +tmp="git remote add origin aliyun-git:$remote_name.git" +eval "$tmp" +git push --set-upstream origin master +git push + +echo "Success!" + diff --git a/mypath/gitk.sh b/mypath/gitk.sh new file mode 100755 index 0000000..aa6e515 --- /dev/null +++ b/mypath/gitk.sh @@ -0,0 +1,2 @@ +#!/bin/bash +git log --oneline --all --graph diff --git a/mypath/md2html.sh b/mypath/md2html.sh new file mode 100755 index 0000000..bb316f1 --- /dev/null +++ b/mypath/md2html.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +########################################################################## +# File Name : md2html.sh +# Encoding : utf-8 +# Author : We-unite +# Email : weunite1848@gmail.com +# Created Time : 2023-12-15 +########################################################################## + +# origin是输入的第一个参数,指源文件名 +# src是原文件名前边加一个.,是源文件的复制 +# dst是原文件名的md后缀改成html +origin=$1 +src="."$origin +dst=${origin%.*}".html" +title="$2" + +cp $origin $src +# src中所有的“```...”替换成“```”,其中...指换行前的所有内容 +sed -i 's/```.*$/```/g' $src +pandoc -s $src -o $dst --metadata title="$title" +rm $src + +sed -i '/