diff --git a/README.md b/README.md index 131f751..efbe6ef 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@ 1. `Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux` 2. `Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform` 3. Execute `program-setup/auxiliary-files/wsl_update_x64.msi` -4. Install Ubuntu 20.04 LTS from the Windows Store +4. Install Ubuntu 20.04 from the Windows Store ### Basic setup 1. Clone this repository to `~/` (HTTPS) -2. `sh ~/wsl-setup/init.sh` -4. `sh program-setup/ssh-setup.sh SEED GITHUB-EMAIL GITHUB-NAME` +2. `bash ~/wsl-setup/init.sh` +4. `bash program-setup/ssh-setup.sh SEED GITHUB-EMAIL GITHUB-NAME` 3. Vim `:PlugStats` and `:PlugInstall` diff --git a/auxiliary-files/afowler-custom.zsh-theme b/auxiliary-files/afowler-custom.zsh-theme index f926255..4de478c 100644 --- a/auxiliary-files/afowler-custom.zsh-theme +++ b/auxiliary-files/afowler-custom.zsh-theme @@ -2,7 +2,7 @@ if [ $UID -eq 0 ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" -PROMPT='\$ %{$reset_color%}%{${fg[green]}%}%~ $(git_prompt_info)%{${fg_bold[$CARETCOLOR]}%}»%{${reset_color}%} ' +PROMPT='\$ %{$reset_color%}%{${fg[green]}%}%3~ $(git_prompt_info)%{${fg_bold[$CARETCOLOR]}%}»%{${reset_color}%} ' RPS1="${return_code}" diff --git a/auxiliary-files/maketex/std-cmd.tex b/auxiliary-files/maketex/std-cmd.tex index e910608..f13fedc 100755 --- a/auxiliary-files/maketex/std-cmd.tex +++ b/auxiliary-files/maketex/std-cmd.tex @@ -1,12 +1,13 @@ \documentclass{article} +\usepackage{siunitx, amsmath, amssymb, adjustbox, graphicx, float, hyperref} \usepackage[utf8]{inputenc} \usepackage[letterpaper, portrait, margin=1in]{geometry} -\usepackage{adjustbox} \usepackage[shortlabels]{enumitem} -\usepackage{siunitx, amsmath, amssymb} % symbols and operators \setlength{\parindent}{0pt} \setlength{\parskip}{0.5em} +\setlength{\tabcolsep}{0.5em} +\renewcommand{\arraystretch}{1.5} % Symbols \newcommand{\N}{\mathbb{N}} @@ -27,7 +28,7 @@ \newcommand{\Angle}[1]{\left<#1\right>} \newcommand{\bra}[1]{\langle#1} \newcommand{\ket}[1]{|#1\rangle} -\newcommand{\Si}[1]{\,\si{#1}\,} +\newcommand{\Si}[1]{\,\si{#1}} \renewcommand{\vec}[1]{\mathbf{#1}} \newcommand{\dv}[3][]{\frac{\dd ^{#1} #2}{\dd #3 ^{#1}}} diff --git a/configs/.vim/.netrwhist b/configs/.vim/.netrwhist deleted file mode 100644 index 6e5656e..0000000 --- a/configs/.vim/.netrwhist +++ /dev/null @@ -1,12 +0,0 @@ -let g:netrw_dirhistmax =10 -let g:netrw_dirhistcnt =4 -let g:netrw_dirhist_4='/home/yeva/wsl-setup' -let g:netrw_dirhist_3='/home/yeva' -let g:netrw_dirhist_2='/mnt/c/Users/yevge/Data/repos/resume-engine-own' -let g:netrw_dirhist_1='/home/yeva/rmai/stampy/api' -let g:netrw_dirhist_0='/home/yeva/.vim/ftplugin/tex' -let g:netrw_dirhist_9='/mnt/c/Users/yevge/OneDrive - rit.edu/Documents/2205 Spring/MECE-117/Homework/HW6/figures' -let g:netrw_dirhist_8='/mnt/c/Users/yevge/OneDrive - rit.edu/Documents/2205 Spring/MECE-117/Studio' -let g:netrw_dirhist_7='/mnt/c/Users/yevge/OneDrive - rit.edu/Documents/2205 Spring/MECE-117/Homework/HW4/figures' -let g:netrw_dirhist_6='/home/yeva/.vim/autoload' -let g:netrw_dirhist_5='/home/yeva/launch/2020-SPICA-Flight-Computer/lib/MPL3115A2' diff --git a/configs/.vim/UltiSnips/tex.snippets b/configs/.vim/UltiSnips/tex.snippets index 85abf47..40057cf 100644 --- a/configs/.vim/UltiSnips/tex.snippets +++ b/configs/.vim/UltiSnips/tex.snippets @@ -10,86 +10,103 @@ def env(name): return x != '0' and x != '0' endglobal -# [[[ TEXT FORMATTING +# [[[ ENVIRONMENTS -snippet '\\begin{(\w+)}' "begin/end" r +snippet '\\begin{(\w+\*?)}' "begin/end" r \begin{`!p snip.rv = match.group(1)`} $0 \end{`!p snip.rv = match.group(1)`} endsnippet -snippet 'ENUM(\d+)?' "enumerate" r -\begin{enumerate}[$1] - `!p snip.rv = (int(match.group(1)) if match.group(1) else 1) * '\item '` -\end{enumerate}$0 +snippet FIG "figure" +\begin{figure} + \centering + ${3:body} + \caption{$1} + \label{fig:$2} +\end{figure} +$0 endsnippet -snippet 'TAB(\d+)?' "tabular" r -\begin{tabular}{|`!p snip.rv = (int(match.group(1)) if match.group(1) else 1) * 'c|'`} +snippet SUB "subfigure" +\begin{subfigure}{${1:0.45\textwidth}} + % requires \usepackage{subcaption} + \includegraphics[${2:dimension}]{${3:path}} + \caption{$4} + \label{fig:$5} +\end{subfigure} +$0 +endsnippet + +snippet TAB "table" +\begin{table} + \centering + ${3:body} + \caption{$1} + \label{tbl:$2} +\end{table}$0 +endsnippet + +snippet ULAR "tabular" +\begin{tabular}{${1:colspec}} + \hline $2 \\\\ \hline - `!p snip.rv = (int(match.group(1)) - 1 if match.group(1) else 1) * '& '` \\\\ -\end{tabular} +\end{tabular}$0 endsnippet # [[[ MATH FORMATTING + +# captures single chars or commands into a hat +context "math()" +priority 2 +snippet '(\\\w+|\w)(dot|vec|hat)' "suffixes basic" wr +`!p snip.rv = f"\\{match.group(2)}{{{match.group(1)}}}"`$0 +endsnippet + +# captures commands with arguments (other hats) into a hat context "math()" -snippet '^(.*)(dot|ddot|vec|hat)' "suffixes advanced" wr +priority 1 +snippet '^(.+)(dot|vec|hat)$' "suffixes advanced" wr `!p depth = 0 -seek = len(match.group(1)) - 1 -arg = 0 -line = match.group(1) - -ischar = lambda c: re.match('[a-zA-Z]', c) -isopen = lambda c: c in '([{' -isclos = lambda c: c in ')]}' - -if isclos(line[seek]): - depth -= 1 - while depth and seek: - seek -= 1 - if isopen(line[seek]): - depth += 1 - elif isclos(line[seek]): - depth -= 1 -save = -1 -while seek: - seek -= 1 - if ischar(line[seek]): - if not save: - save = seek - else: - if line[seek] == '\\': - save = seek +first = match.group(1) +i = len(first) - 1 +while i: # match delimeter groups + if first[i] in "}])": + depth += 1 + elif first[i] in "{[(": + depth -= 1 + if depth <= 0: break - -snip.rv = line[:save] + '\\' + match.group(2) + '{' + line[save:] + '}' - -` + i -= 1 +# i now is at the position of the matched open delimeter closest to the end +arg_re = re.compile(r"^(.*?)(\\\w+)") # match "(stuff)\(command)" +sm = arg_re.match(first[:i]) +if not sm: # the string doesn't exactly match "\command{arguments}", do nothing. + snip.rv = match.string # do nothing, just to be safe +else: + snip.rv = f"{sm.group(1)}\\{match.group(2)}{{{sm.group(2)}{first[i:]}}}" +`$0 endsnippet +# automatic super or subscript context "math()" snippet '(\^|_)(\\?[\-a-zA-Z0-9])' "Script" wirA `!p snip.rv = match.group(1)`{`!p snip.rv = match.group(2)`$1}$0 endsnippet - +# uses \9 because it's slightly faster and less accident-prone due to A snippet \9 "Inline equation" iA \($1\)$0 endsnippet -snippet '\\\[ ' "Aligned unlabeled equation" rA +snippet \[ "Aligned unlabeled equation" i \[$1\]$0 endsnippet -snippet eqn "equation" A -\begin{equation}\label{$1} - $2 -\end{equation} -endsnippet - # [[[ OPERATIONS +# automatically creates fraction numerator, obeys delim groups context "math()" snippet '(^.*)//' "Fraction" wrA `!p @@ -101,29 +118,33 @@ while i: depth += 1 elif argument[i] in "{[(": depth -= 1 - if depth < 0 or (depth == 0 and argument[i] in ' +-='): + if depth < 0 or (depth == 0 and argument[i] in ' =\t'): break i -= 1 -snip.rv = argument[:i+1] + '\\frac{%s}{' % argument[i+1:]`$1}$0 +snip.rv = argument[:i+1] + '\\frac{' + argument[i+1:]`$1}{$2}$0 endsnippet +# shortcut for integral context "math()" snippet int "Integral" i \int_{$1}$2\dd{$3}$0 endsnippet +# shortcut for differentor operators context "math()" -snippet '\\(p?dt)' "solo diff" ir +snippet '\\(p?dt)' "diff operator" ir \\`!p snip.rv = match.group(1)`{$1}$0 endsnippet +# shortcut for derivatives context "math()" -snippet '\\(p?dv)' "diff in numerator" ir +snippet '\\(p?dv)' "derivative" ir \\`!p snip.rv = match.group(1)`{$1}{$2}$0 endsnippet +# shortcut for second partial derivatives context "math()" -snippet \pddv "second diff" i +snippet \pddv "second derivative" i \pddv{$1}{$2}{$3}$0 endsnippet diff --git a/configs/.vim/after/syntax/c.vim b/configs/.vim/after/syntax/c.vim new file mode 100644 index 0000000..a7ec08b --- /dev/null +++ b/configs/.vim/after/syntax/c.vim @@ -0,0 +1,63 @@ +" We define our own handling for if, while and for, so remove them from +" the simple keyword matching used by default +syn clear cConditional +syn clear cRepeat + +syn keyword cConditional switch else +syn keyword cRepeat do + +" Matches for types in function parameters +syn match cJCParamVoid "\" contained +syn match cJCParamType "\<\(\(const\|restrict\|volatile\|signed\|unsigned\|struct\|enum\)[ \t*]\+\)*\I\i*[ \t*]\+\I"he=e-1 contained containedin=cJCFor + +" Matchs for types in variables and function declarations +syn match cJCTypeInDecl "^\s*\(\(inline\|const\|restrict\|extern\|GLOBAL\|static\|register\|auto\|volatile\|virtual\|signed\|unsigned\|struct\)[ \t*]\+\)*\I\i*\([ \t*]\+\(const\|restrict\|volatile\)\)*[ \t*]*" contained +syn match cJCDecl "^\s*\(inline\s\+\)\=\(\I\i*[ \t*]\+\)\+\s*\I" contains=cJCTypeInDecl + +" Matches function declarations and definitions +syn region cJCFunc start="^\(\(inline\|const\|extern\|GLOBAL\|static\|register\|auto\|volatile\|virtual\|signed\|unsigned\|struct\)[ \t*]\+\)*\I\i*\s\+\**\s*\I[[:ident:]:]*\s*(" end=")" contains=CJCParamVoid,cJCParamType,cJCTypeInDecl,cComment +syn region cJCFunc start="^\I\i*\s*(" end=")" contains=CJCParamVoid,cJCParamType + +" Matches type casts +syn match cJCTypeCast "(\@<=\s*\(\(const\|restrict\|volatile\|signed\|unsigned\|struct\|enum\)[ \t*]\+\)*\I\i*\s*\**\s*\(restrict\)\?\s*)\s*[^) \t;,{]"me=e-2 +"syn match cJCTypeCast "[[:space:],(]*(\I\i*\s*\**\s*)\s*"me=e-1,ms=s+1 + + +" Matchs function calls and if/else/while, so they are not +" accidentally matched by things above. +syn match cJCFctCall "\i\s*(\s*\(\(const\|restrict\|volatile\|signed\|unsigned\|struct\|enum\)[ \t*]\+\)*\I\i*\s*\**\s*)" +syn region cJCIfParent matchgroup=cStatement start="(" end=")" contained contains=ALLBUT,@cParenGroup,cJCTypeInDecl +syn region cJCIf matchgroup=cConditional start="\(\s*\(\."me=e-1 +syn match cStatement "^\s*goto\s\+\I"me=e-1 +syn match cConditional "^\s*case\>."me=e-1 +syn match cConditional ":\s*$" + + +" Delete the keyword-based cType matching, it just gets in the way +syn clear cType + +" And finally the thing we wanted to do: highlight all the types using cType +" highlight, not just the ones matching C keywords. +hi link cJCType cType +hi link cJCParamType cType +hi link cJCTypeInDecl cType +hi link cJCTypeCast cType + +" Uncomment these for debug mode: very visible highlight of what we match +"hi cJCTypeCast guibg=#ff0000 +"hi cJCDecl guibg=#d08080 +"hi cJCType guibg=#FFFF00 +"hi cJCTypeInDecl guibg=#FF00FF +"hi cJCFunc guibg=#00FF00 +"hi cJCParamType guibg=#0000FF +"hi cJCIf guibg=#00FFFF +"hi cJCFor guibg=#00FF80 diff --git a/configs/.vim/after/syntax/cpp.vim b/configs/.vim/after/syntax/cpp.vim new file mode 100644 index 0000000..15cbd97 --- /dev/null +++ b/configs/.vim/after/syntax/cpp.vim @@ -0,0 +1,50 @@ +" Delete the keyword-based cType matching, it just gets in the way +syn clear cppType + +" Redefine cppStatement so that "new" is not a keyword, so the below can match +" it +syn clear cppStatement + +syn keyword cJCNewStatement new contained +hi def link cJCNewStatement cppStatement + +syn keyword cppStatement delete this friend using +if !exists("cpp_no_cpp20") + syn keyword cppStatement co_await co_return co_yield requires +endif + +" Detect type in "new" expressions +syn match cJCNew "new \I[[:ident:]:]*" contains=cJCNewStatement + +" Match various well known things from the STL that are known to contain types +" in their template arguments +syn match cJCCppCast "\(static_cast\|dynamic_cast\|reinterpret_cast\|const_cast\|time_point_cast\|make_unique\|make_shared\|make_optional\)<\zs\I[[:ident:]:&*]*>"me=e-1 + +" Redefine several things from the C syntax to handle templates and references +" in addition to the other things +syn clear cJCTypeInDecl +syn clear cJCDecl +syn clear cJCFunc +syn clear cJCParamType + +syn match cJCTypeInDecl "^\s*\(\(inline\|const\|restrict\|extern\|GLOBAL\|static\|register\|auto\|volatile\|virtual\|signed\|unsigned\|struct\)[ \t*]\+\)*\I[[:ident:]:<>]*&\?\([ \t*]\+\(const\|restrict\|volatile\)\)*[ \t*]*" contained +syn match cJCDecl "^\s*\(inline\s\+\)\=\(\I[[:ident:]:<>]*&\?[ \t*]\+\)\+\s*\I" contains=cJCTypeInDecl + +syn region cJCFunc start="^\t*\(\(inline\|const\|extern\|GLOBAL\|static\|register\|auto\|volatile\|virtual\|signed\|unsigned\|struct\)[ \t*]\+\)*\I[[:ident:]:<>]*\s\+\**\s*\I[[:ident:]:]*\s*(" end=")" contains=CJCParamVoid,cJCParamType,cJCTypeInDecl,cComment + +" This matches constructors, but only if they are in the first column for now +" (no identation). Otherwise it also matches all function calls, and that +" breaks a lot of things. +syn region cJCFunc start="^\I[[:ident:]:<>]*\s*(" end=")" contains=CJCParamVoid,cJCParamType + +syn match cJCParamType "\<\(\(const\|restrict\|volatile\|signed\|unsigned\|struct\|enum\)[ \t*]\+\)*\I[[:ident:]:<>]*&\?[ \t*]\+\I"he=e-1 contained containedin=cJCFor + +hi link cJCNew cType + +hi link cJCCppCast cType +hi link cJCTypeInDecl cType +hi link cJCParamType cType + +" Uncomment these for debug mode: very visible highlight of what we match +"hi cJCCppCast guibg=#00FF80 +"hi cJCFunc guibg=#00FF00 diff --git a/configs/.vimrc b/configs/.vimrc index 93b5495..fae9fbf 100644 --- a/configs/.vimrc +++ b/configs/.vimrc @@ -5,7 +5,8 @@ highlight LineNr ctermfg=grey set tabstop=4 set shiftwidth=4 set regexpengine=1 - +set textwidth=80 +set tags=~/repos/NIGEL-Flight-Computer/tags let g:tex_flavor = "latex" call plug#begin('~/.vim/plugged') diff --git a/configs/.zsh_aliases b/configs/.zsh_aliases index d95de09..9f569cf 100644 --- a/configs/.zsh_aliases +++ b/configs/.zsh_aliases @@ -1,8 +1,8 @@ WINDOWS="/mnt/c" WINUSER="$WINDOWS/Users/yevge" # change user as appropriate REPOS="$WINUSER/Data/repos" -DOCS="\"$WINUSER/OneDrive - rit.edu/Documents\"" # needs to be run using eval cd -LAUNCH=~/launch/2020-SPICA-Flight-Computer +DOCS="\"$WINUSER/OneDrive - rit.edu/Documents\"" +# cd $DOCS needs to be eval for some reason alias python="python3" alias pip="pip3" @@ -10,8 +10,31 @@ alias config="vim ~/.zshrc" alias aliases="vim ~/.zsh_aliases" alias update=". ~/.zshrc" -# creates a tex project named $1 -function maketex { +alias mkae="sl" # funny +alias maek="sl" # also funny +alias dor="sl" # also also funny + +function cyntax { # syntax-check c file + gcc -fsyntax-only $1 +} + +function clean-sub { # make clean for immediate subdirectories + for dir in */; do + make -C $dir clean + done +} + +function plotcrop { # crop in-place with no margin + pdfcrop -margin 0 $1 $1 +} + +function plotcrop-all { # plotcrop all .pdf in cwd + for file in *.pdf; do + plotcrop $file + done +} + +function maketex { # create tex project named $1 cp ~/wsl-setup/auxiliary-files/maketex/* . mv texfile.tex $1'.tex' sed 's/{texfile}/'$1'\.tex/g' makefile -i @@ -22,7 +45,20 @@ function theme { sed 's/ZSH_THEME=\"[a-z]*\"/ZSH_THEME=\"'$1'\"/g' ~/.zshrc -i } -# testing toggl API +touch ~/.projects + +# set current projects +# using ! as sed delimiter to not conflict with "/" in paths +function project-set { + sed -i "${1}s!.*!$(pwd)!" ~/.projects +} + +# cd to project +function project { + eval cd \"$(sed -n "$1{p;q}" ~/.projects)\" +} + +# testing toggl API (deprecated) # GET request function toggl-get { curl -S -u $(cat ~/.toggl_token)':api_token' 'https:/api.track.toggl.com/api/v8/'$1 | python -m json.tool diff --git a/init.sh b/init.sh index b601960..37d0039 100644 --- a/init.sh +++ b/init.sh @@ -2,22 +2,18 @@ sudo apt clean sudo apt update sudo apt upgrade -y -sudo apt-get install tree -y -sudo apt-get install python3 -y -sudo apt-get install python3-pip -y -sudo apt-get install texlive-base -y -sudo apt-get install texlive-science -y -sudo apt-get install texlive-latex-extra -y -sudo apt-get install latexmk -y -sudo apt-get install zsh -y + +packages="tree python3 python3-pop texlive-base texlive-science +texlive-extra-utils texlive-latex-extra latexmk sl gdb zsh" +sudo apt-get install $(packages) -y #oh-my-zsh yes | sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" chsh -s /bin/zsh sed 's/ZSH_THEME=\"[a-z]*\"/ZSH_THEME=\"afowler-custom\"/g' ~/.zshrc -i # set ZSH theme -cp ~/wsl-setup/auxiliary-files/afowler-custom.zsh-theme ~/.oh-my-zsh/themes/ # update with my custom theme +cp ~/wsl-setup/auxiliary-files/afowler-custom.zsh-theme ~/.oh-my-zsh/themes/ -# set up home dir +# copy configuration files cp ~/wsl-setup/configs/. ~/ -r # add aliases @@ -25,7 +21,3 @@ echo '. ~/.zsh_aliases' >> ~/.zshrc # VimPlug curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim - -# touch ~/.toggl_token -# touch ~/.toggl_wid -# echo "REMEMBER TO UPDATE ~/.toggl_token" diff --git a/rc-pull.sh b/rc-pull.sh index 540eff1..dc9fae5 100755 --- a/rc-pull.sh +++ b/rc-pull.sh @@ -2,8 +2,5 @@ read -p "Copy configuration files from repo to system [y/n]: " -n 1 REPLY echo if [[ $REPLY =~ ^[Yy]$ ]]; then - cp ~/wsl-setup/auxiliary-files/.zsh_aliases ~/ - cp ~/wsl-setup/auxiliary-files/UltiSnips ~/vim/ -r - cp ~/wsl-setup/auxiliary-files/ftplugin ~/.vim/ -r - cp ~/wsl-setup/auxiliary-files/.vimrc ~/ + cp ~/wsl-setup/configs/. ~/ -r fi diff --git a/rc-push.sh b/rc-push.sh index 577fac2..99c4b55 100755 --- a/rc-push.sh +++ b/rc-push.sh @@ -1,9 +1,12 @@ #!/bin/bash read -p "Copy configuration files from system to repo? [y/n]: " -n 1 REPLY echo -if [[ $REPLY =~ '^[Yy]$' ]]; then - cp ~/.vim/ftplugin ~/wsl-setup/auxiliary-files/ -r - cp ~/.vim/UltiSnips ~/wsl-setup/auxiliary-files/ -r - cp ~/.zsh_aliases ~/wsl-setup/auxiliary-files - cp ~/.vimrc ~/wsl-setup/auxiliary-files +if [[ $REPLY =~ ^[Yy]$ ]]; then + echo "Copying ~/.zsh_aliases" + cp ~/.zsh_aliases ~/wsl-setup/configs/ + echo "Copying ~/.vimrc" + cp ~/.vimrc ~/wsl-setup/configs/ + echo "Copying select ./vim subdirs" + cp ~/.vim/UltiSnips ~/wsl-setup/configs/.vim -r + cp ~/.vim/ftplugin ~/wsl-setup/configs/.vim -r fi