aboutsummaryrefslogtreecommitdiffstats
path: root/baseline
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2021-05-14 18:14:50 +0000
committerterminaldweller <thabogre@gmail.com>2021-05-14 18:14:50 +0000
commit6e528248414e330c9e25e81596ab47b8b8a5b701 (patch)
treee1aa41a7f3198eeac187e6177ec7d4a33db229d3 /baseline
downloadscripts-6e528248414e330c9e25e81596ab47b8b8a5b701.tar.gz
scripts-6e528248414e330c9e25e81596ab47b8b8a5b701.zip
first commitmaster
Diffstat (limited to '')
-rw-r--r--baseline/.minttyrc29
-rw-r--r--baseline/.tmux.conf62
-rw-r--r--baseline/.vimrc309
-rw-r--r--baseline/.zshrc62
-rwxr-xr-xbaseline/startup.sh46
-rwxr-xr-xbaseline/ufw-allow-mosh31
6 files changed, 539 insertions, 0 deletions
diff --git a/baseline/.minttyrc b/baseline/.minttyrc
new file mode 100644
index 0000000..6d1af02
--- /dev/null
+++ b/baseline/.minttyrc
@@ -0,0 +1,29 @@
+BoldAsFont=no
+Columns=150
+Rows=55
+Font=DejaVuSansMono NF
+FontWeight=700
+FontHeight=10
+Transparency=low
+
+ForegroundColour=#A0A0A0
+BackgroundColour=#1B1D1E
+CursorColour=#A0A0A0
+
+Black=#1B1D1E
+Red=#FF0000
+Green=#82B414
+Yellow=#FD971F
+Blue=#268BD2
+Magenta=#8C54FE
+Cyan=#56C2D6
+White=#CCCCC6
+
+BoldBlack=#1B1D1E
+BoldRed=#FF0000
+BoldGreen=#82B414
+BoldYellow=#FD971F
+BoldBlue=#268BD2
+BoldMagenta=#8C54FE
+BoldCyan=#56C2D6
+BoldWhite=#CCCCC6
diff --git a/baseline/.tmux.conf b/baseline/.tmux.conf
new file mode 100644
index 0000000..2c4ab08
--- /dev/null
+++ b/baseline/.tmux.conf
@@ -0,0 +1,62 @@
+set -g default-terminal "tmux-256color"
+set-option -g prefix C-a
+
+#key bindings
+bind | split-window -h
+bind - split-window -v
+bind -r k select-pane -U
+bind -r j select-pane -D
+bind -r h select-pane -L
+bind -r l select-pane -R
+bind -n C-k next-window
+bind -n C-j previous-window
+bind -n M-k select-pane -U
+bind -n M-j select-pane -D
+bind -n M-h select-pane -L
+bind -n M-l select-pane -R
+setw -g mode-keys vi
+bind [ copy-mode
+bind -T copy-mode-vi 'v' send -X begin-selection
+bind -T copy-mode-vi 'y' send -X copy-selection-and-cancel
+#bind -T copy-mode-vi 'V' rectangle-toggle
+bind ] paste-buffer
+bind Space choose-buffer
+
+#move windows
+bind-key -n C-S-Left swap-window -t -1
+bind-key -n C-S-Right swap-window -t +1
+set-option -g history-limit 10000
+
+#unbindings
+unbind Up
+unbind Down
+unbind Left
+unbind Right
+
+#color stuff
+set -g status-bg colour25
+set -g status-position bottom
+set -g status-justify left
+set -g status-fg colour137
+set -g status-attr dim
+set -g status-left ""
+set -g status-right "#[fg=colour233,bg=colour2,bold] %d/%m #[fg=colour233,bg=colour107,bold] %H:%M:%S "
+set -g status-right-length 70
+set -g status-left-length 70
+setw -g window-status-current-fg colour0
+setw -g window-status-current-bg colour22
+setw -g window-status-current-attr bold
+setw -g window-status-current-format "#[fg=colour249] #I#[fg=colour255]:#[fg=colour16]#W#[fg=colour249]#F "
+setw -g window-status-fg colour0
+setw -g window-status-bg colour23
+setw -g window-status-attr none
+setw -g window-status-format "#[fg=colour237] #I#[fg=colour250]:#[fg=colour16]#W#[fg=colour244]#F "
+setw -g window-status-bell-attr bold
+setw -g window-status-bell-fg colour255
+setw -g window-status-bell-bg colour64
+# messages
+set -g message-attr bold
+set -g message-fg colour232
+set -g message-bg colour16
+
+set -g message-style bg='#44475a',fg='#8be9fd'
diff --git a/baseline/.vimrc b/baseline/.vimrc
new file mode 100644
index 0000000..3cbbdb1
--- /dev/null
+++ b/baseline/.vimrc
@@ -0,0 +1,309 @@
+set encoding=UTF-8
+let mapleader = " "
+set nocompatible
+set completeopt-=preview
+filetype off
+set rtp+=~/.vim/bundle/Vundle.vim
+call vundle#begin()
+Plugin 'tpope/vim-surround'
+Plugin 'easymotion/vim-easymotion'
+Plugin 'sheerun/vim-polyglot'
+Plugin 'ctrlpvim/ctrlp.vim'
+Plugin 'chrisbra/Recover.vim'
+Plugin 'nanotech/jellybeans.vim'
+Plugin 'unblevable/quick-scope'
+Plugin 'tpope/vim-repeat'
+Plugin 'adelarsq/vim-matchit'
+Plugin 'majutsushi/tagbar'
+Plugin 'ludovicchabant/vim-gutentags'
+Plugin 'mbbill/undotree'
+Plugin 'tpope/vim-commentary'
+call vundle#end()
+filetype plugin indent on
+
+" jellybeans
+colo jellybeans
+set background=dark
+let g:gruvbox_italics = 1
+let g:jellybeans_overrides = {
+\ 'Todo': { 'guifg': '000000', 'guibg': '00cc00',
+\ 'ctermfg': 'Black', 'ctermbg': 'Blue',
+\ 'attr': 'bold' },
+\ 'Comment': { 'guifg': '339966' },
+\ 'background': { "guibg": "000000", "ctermbg":"none"},
+\ 'StorageClass': {"guifg": '9966ff' },
+\ 'Exception': {"guifg": "99cc00"},
+\ "Ignore": {"guifg": "336699"},
+\ "SpecialComment": {"guifg": "009900"},
+\ "Macro": {"guifg": "0099cc"}
+\}
+let g:jellybeans_use_term_italics = 1
+
+"set exrc
+set encoding=UTF-8
+set linebreak
+set breakindent
+set wrap
+set tagbsearch
+set secure
+set list
+set showmatch
+set number
+set relativenumber
+set noerrorbells
+set hidden
+set novisualbell
+set expandtab
+set smarttab
+set autoindent
+set shell=ksh
+set autoread
+set ignorecase
+set smartcase
+set hlsearch
+set incsearch
+set magic
+set lazyredraw
+set ttyfast
+set scrolloff=0
+set tagbsearch
+set wildmenu
+set diffopt=internal,algorithm:patience
+set tags=./tags,tags;$HOME
+syntax on
+set directory^=$HOME/.vim/tmp//
+nmap <Backspace> <Nop>
+nmap <Delete> <Nop>
+nmap <Left> <Nop>
+nmap <Down> <Nop>
+nmap <Up> <Nop>
+nmap <Right> <Nop>
+nmap <PageUp> <Nop>
+nmap <PageDown> <Nop>
+imap <PageUp> <Nop>
+imap <PageDown> <Nop>
+map <F3> :bp<CR>
+map <F4> :bn<CR>
+nnoremap <F7> :Vexplore<CR>
+map <F8> :TagbarToggle<CR>
+nnoremap <F12> :UndotreeToggle<cr>
+map <C-e> :q<cr>
+set timeoutlen=1000 ttimeoutlen=100
+set <F13>=^[[21;2~
+map <F13> <S-F10>
+map! <F13> <S-F10>
+nnoremap <F10> :vsp<cr>
+nnoremap <S-F10> :sp<cr>
+set pastetoggle=<F11>
+nnoremap <leader>cd :cd %:p:h<cr>
+nmap ]c :cn<CR>
+nmap [c :cp<CR>
+
+function! GetBufferList()
+ redir =>buflist
+ silent! ls!
+ redir END
+ return buflist
+endfunction
+
+function! ToggleList(bufname, pfx)
+ let buflist = GetBufferList()
+ for bufnum in map(filter(split(buflist, '\n'), 'v:val =~ "'.a:bufname.'"'), 'str2nr(matchstr(v:val, "\\d\\+"))')
+ if bufwinnr(bufnum) != -1
+ exec(a:pfx.'close')
+ return
+ endif
+ endfor
+ if a:pfx == 'l' && len(getloclist(0)) == 0
+ echohl ErrorMsg
+ echo "Location List is Empty."
+ return
+ endif
+ let winnr = winnr()
+ exec(a:pfx.'open')
+ if winnr() != winnr
+ wincmd p
+ endif
+endfunction
+nmap <silent> <leader>l :call ToggleList("Location List", 'l')<CR>
+nmap <silent> <leader>q :call ToggleList("Quickfix List", 'c')<CR>
+
+set laststatus=2
+function! InsertStatuslineColor(mode)
+ if a:mode == 'i'
+ hi statusline ctermfg=22 ctermbg=15 guibg=#005f00 guifg=#ffffff
+ elseif a:mode == 'r'
+ hi statusline ctermfg=52 ctermbg=15 guibg=#5f0000 guifg=#ffffff
+ else
+ hi statusline ctermfg=25 ctermbg=63 guibg=#005faf guifg=#5f5fff
+ endif
+endfunction
+
+au InsertEnter * call InsertStatuslineColor(v:insertmode)
+au InsertLeave * hi statusline ctermfg=24 ctermbg=15 guibg=#005f87 guifg=#ffffff
+hi statusline ctermfg=24 ctermbg=15 guibg=#005f87 guifg=#ffffff
+hi statuslineNC ctermfg=0 ctermbg=24 term=bold guifg=#000000 guibg=#005f87
+set statusline=[%f] "file name
+set statusline+=[%{strlen(&fenc)?&fenc:'none'}, "file encoding
+set statusline+=%{&ff}] "file format
+set statusline+=%y "filetype
+set statusline+=%h "help file flag
+set statusline+=%m "modified flag
+set statusline+=\ %= " align left
+set statusline+=Line:%l/%L[%p%%] " line X of Y [percent of file]
+set statusline+=\ Col:%c " current column
+set statusline+=\ Buf:%n " Buffer number
+set statusline+=\ [%b][0x%B]\ " ASCII and byte code under cursor
+
+set fillchars+=vert:\ " whitespace signifacant
+hi VertSplit ctermbg=0 ctermfg=0 guibg=#000000 guifg=#000000
+
+" highlight groups
+hi def InterestingWord1 ctermfg=16 ctermbg=214 guifg=#000000 guibg=#ffaf00
+hi def InterestingWord2 ctermfg=16 ctermbg=154 guifg=#000000 guibg=#afff00
+hi def InterestingWord3 ctermfg=16 ctermbg=121 guifg=#000000 guibg=#87ffaf
+hi def InterestingWord4 ctermfg=16 ctermbg=137 guifg=#000000 guibg=#af875f
+hi def InterestingWord5 ctermfg=16 ctermbg=211 guifg=#000000 guibg=#ff87af
+hi def InterestingWord6 ctermfg=16 ctermbg=195 guifg=#000000 guibg=#d7ffff
+hi def InterestingWord7 ctermfg=16 ctermbg=99 guifg=#000000 guibg=#875fff
+hi def InterestingWord8 ctermfg=16 ctermbg=35 guifg=#000000 guibg=#00af5f
+hi def InterestingWord9 ctermfg=16 ctermbg=57 guifg=#000000 guibg=#5f00ff
+hi def InterestingWord0 ctermfg=16 ctermbg=39 guifg=#000000 guibg=#00afff
+
+" Steve Losh's highlight function
+function HighInterestingWord(n)
+ normal! mz
+ normal! "zyiw
+ let mid = 88888 + a:n
+ silent! call matchdelete(mid)
+ let pat = '\V\<' . escape(@z, '\') . '\>'
+ call matchadd("InterestingWord".a:n, pat, 1, mid)
+ normal! `z
+endfunction
+
+" multiple highlights
+nnoremap <silent> <leader>1 :call HighInterestingWord(1)<cr>
+nnoremap <silent> <leader>2 :call HighInterestingWord(2)<cr>
+nnoremap <silent> <leader>3 :call HighInterestingWord(3)<cr>
+nnoremap <silent> <leader>4 :call HighInterestingWord(4)<cr>
+nnoremap <silent> <leader>5 :call HighInterestingWord(5)<cr>
+nnoremap <silent> <leader>6 :call HighInterestingWord(6)<cr>
+nnoremap <silent> <leader>7 :call HighInterestingWord(7)<cr>
+nnoremap <silent> <leader>8 :call HighInterestingWord(8)<cr>
+nnoremap <silent> <leader>9 :call HighInterestingWord(9)<cr>
+nnoremap <silent> <leader>0 :call HighInterestingWord(0)<cr>
+
+au BufNewFile,BufEnter *.s set ft=nasm
+
+"copy and paste between different Vim sessions
+nmap _Y :!echo ""> ~/.vi_tmp<CR><CR>:w! ~/.vi_tmp<CR>
+vmap _Y :w! ~/.vi_tmp<CR>
+nmap _P :r ~/.vi_tmp<CR>
+
+inoremap <c-a> <esc>I
+inoremap <c-e> <esc>A
+
+iab pritn print
+iab retrun return
+iab fucntion function
+iab funciton function
+
+nnoremap <S-Delete> :bd<CR>
+map <F6> <nop>
+nnoremap <leader>c :call clearmatches()<CR>
+map <leader>w :w<CR>
+nnoremap <leader>t :bel term<CR>
+nnoremap <leader>r :!%:p<CR>
+
+let g:qs_highlight_on_keys = ["f", "F", "t", "T"]
+
+" undotree
+if has("persistent_undo")
+ set undodir=~/.undodir/
+ set undofile
+endif
+let g:undotree_WindowLayout = 4
+
+"highlight search
+highlight Search ctermfg=White ctermbg=DarkGreen cterm=Bold
+highlight IncSearch ctermfg=White ctermbg=DarkBlue cterm=Bold
+highlight WildMenu ctermfg=DarkBlue ctermbg=DarkGreen cterm=Bold
+
+"netrw
+let g:netrw_sort_by = 'date'
+let g:netrw_sort_direction = 'reverse'
+let g:netrw_banner = 0
+let g:netrw_liststyle = 3
+let g:netrw_browse_split = 1
+let g:netrw_winsize = 15
+let g:netrw_fastbrowse = 1
+let g:netrw_sort_by = 'name'
+let g:netrw_sort_direction = 'normal'
+
+"tagbar
+let g:tagbar_compact = 1
+let g:tagbar_show_linenumbers = 2
+let g:tagbar_width = 50
+highlight TagbarSignature ctermfg=DarkBlue
+
+"view the python docs for the word under cursor in a split window
+function! s:pythondoc()
+ let l:vword = expand("<cword>")
+ botright vnew
+ setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
+ execute ".!pydoc3 " . l:vword
+ setlocal nomodifiable
+ set syntax=man
+ 1
+endfunction
+command! -complete=shellcmd -nargs=0 PythonDoc call s:pythondoc()
+nnoremap <leader>h :<C-U>PythonDoc<cr>
+
+"camel and snake case motion
+let g:camelchar = "A-Z0-9.,;:{([`'\"_"
+nnoremap <silent><C-h> :<C-u>call search('\C\<\<Bar>\%(^\<Bar>[^'.g:camelchar.']\@<=\)['.g:camelchar.']\<Bar>['.g:camelchar.']\ze\%([^'.g:camelchar.']\&\>\@!\)\<Bar>\%^','bW')<CR>
+nnoremap <silent><C-l> :<C-u>call search('\C\<\<Bar>\%(^\<Bar>[^'.g:camelchar.']\@<=\)['.g:camelchar.']\<Bar>['.g:camelchar.']\ze\%([^'.g:camelchar.']\&\>\@!\)\<Bar>\%$','W')<CR>
+inoremap <silent><C-h> <C-o>:call search('\C\<\<Bar>\%(^\<Bar>[^'.g:camelchar.']\@<=\)['.g:camelchar.']\<Bar>['.g:camelchar.']\ze\%([^'.g:camelchar.']\&\>\@!\)\<Bar>\%^','bW')<CR>
+inoremap <silent><C-l> <C-o>:call search('\C\<\<Bar>\%(^\<Bar>[^'.g:camelchar.']\@<=\)['.g:camelchar.']\<Bar>['.g:camelchar.']\ze\%([^'.g:camelchar.']\&\>\@!\)\<Bar>\%$','W')<CR>
+vnoremap <silent><C-h> :<C-U>call search('\C\<\<Bar>\%(^\<Bar>[^'.g:camelchar.']\@<=\)['.g:camelchar.']\<Bar>['.g:camelchar.']\ze\%([^'.g:camelchar.']\&\>\@!\)\<Bar>\%^','bW')<CR>v`>o
+vnoremap <silent><C-l> <Esc>`>:<C-U>call search('\C\<\<Bar>\%(^\<Bar>[^'.g:camelchar.']\@<=\)['.g:camelchar.']\<Bar>['.g:camelchar.']\ze\%([^'.g:camelchar.']\&\>\@!\)\<Bar>\%$','W')<CR>v`<o
+
+inoremap " ""<left>
+inoremap ' ''<left>
+inoremap ( ()<left>
+inoremap [ []<left>
+inoremap { {}<left>
+inoremap {<CR> {<CR>}<ESC>O
+
+"window resizing
+if bufwinnr(1)
+ nnoremap <right> <c-w>>
+ nnoremap <left> <c-w><
+ nnoremap <up> <c-w>-
+ nnoremap <down> <c-w>+
+endif
+
+if has('cscope')
+ set cscopetag cscopeverbose
+
+ if has('quickfix')
+ set cscopequickfix=s-,c-,d-,i-,t-,e-
+ endif
+
+ cnoreabbrev <expr> csa ((getcmdtype() == ':' && getcmdpos() <= 4)? 'cs add' : 'csa')
+ cnoreabbrev <expr> csf ((getcmdtype() == ':' && getcmdpos() <= 4)? 'cs find' : 'csf')
+ cnoreabbrev <expr> csk ((getcmdtype() == ':' && getcmdpos() <= 4)? 'cs kill' : 'csk')
+ cnoreabbrev <expr> csr ((getcmdtype() == ':' && getcmdpos() <= 4)? 'cs reset' : 'csr')
+ cnoreabbrev <expr> css ((getcmdtype() == ':' && getcmdpos() <= 4)? 'cs show' : 'css')
+ cnoreabbrev <expr> csh ((getcmdtype() == ':' && getcmdpos() <= 4)? 'cs help' : 'csh')
+
+ command -nargs=0 Cscope cs add $VIMSRC/src/cscope.out $VIMSRC/src
+endif
+
+if has("gui")
+ set guifont=DejaVu_Sans_Mono_for_Powerline:h10
+ set guioptions-=m
+ set guioptions-=T
+ set guioptions-=L
+ set guioptions-=r
+endif
diff --git a/baseline/.zshrc b/baseline/.zshrc
new file mode 100644
index 0000000..f921cd7
--- /dev/null
+++ b/baseline/.zshrc
@@ -0,0 +1,62 @@
+export ZSH=~/.oh-my-zsh
+ZSH_THEME="robbyrussell"
+COMPLETION_WAITING_DOTS="true"
+plugins=(
+ git
+ zsh-syntax-highlighting
+ autojump
+)
+source $ZSH/oh-my-zsh.sh
+function dig {
+ globalholecounter=0
+ if test "$(ls -A "~/abbatoir")"; then
+ while [ 1 ]; do
+ if [ -d "~/abbatoir/hole$globalholecounter" ]; then
+ if test "$(ls -A "~/abbatoir/hole$globalholecounter")"; then
+ :
+ else
+ cd ~/abbatoir/hole$globalholecounter
+ break
+ fi
+ else
+ mkdir ~/abbatoir/hole$globalholecounter
+ cd ~/abbatoir/hole$globalholecounter
+ echo $globalholecounter
+ break
+ fi
+ ((globalholecounter++))
+ done
+ else
+ mkdir ~/abbatoir
+ mkdir ~/abbatoir/hole$globalholecounter
+ cd ~/abbatoir/hole$globalholecounter
+ fi
+}
+if [[ -n $SSH_CONNECTION ]]; then
+ export EDITOR='vim'
+else
+ export EDITOR='mvim'
+fi
+alias quit="exit"
+alias clean="clear"
+alias la="ls -A"
+alias digg="dig && clear"
+alias lss="ls -s"
+function clearhalf {
+ size=$(stty size|gawk '{print$1}')
+ size=$(($size/2))
+ tput cup $size 0 && tput ed
+}
+alias cleanhalf="clearhalf"
+alias halfclear="clearhalf"
+alias halfclean="clearhalf"
+alias mv="mv -i"
+alias cp="cp -i"
+alias contest="ping 4.2.2.4 -c 7"
+function math {
+ echo $(($1))
+}
+
+#nvm
+export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
+[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
diff --git a/baseline/startup.sh b/baseline/startup.sh
new file mode 100755
index 0000000..13a4caa
--- /dev/null
+++ b/baseline/startup.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+DISTRO=$(sudo cat /etc/*-release | grep "\<NAME")
+if [ $DISTRO = *"Fedora"* ]; then
+ PCKMG="dnf install -y"
+elif [ $DISTRO = *"Cent"* ]; then
+ PCKMG="yum install -y"
+elif [ $DISTRO = *"Ubuntu"* ]; then
+ PCKMG="apt install -y"
+elif [ $DISTRO = *"Debian"* ]; then
+ PCKMG="apt install -y"
+elif [ $DISTRO = *"Alpine"* ]; then
+ PCKMG="apk add"
+fi
+PCKMG="apt install -y"
+
+#get some bare essentials
+sudo $PCKMG make cmake gcc gdb python3 vim lynx tmux zsh curl wget ksh ctags
+
+#copy dot files
+cp .tmux.conf ~/
+cp .vimrc ~/
+
+#setup hole diggin'
+if [ ! -d "$HOME/abbatoir" ]; then
+ mkdir $HOME/abbatoir
+fi
+
+#vundle
+git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
+
+#nvm
+curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
+
+#oh-my-zsh
+sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
+cp .zshrc ~/
+#autojump
+(cd ~; git clone https://github.com/wting/autojump)
+(cd ~/autojump; ./install.py)
+echo "#autojump" >> ~/.zshrc
+(cd ~; echo "[[ -s $(pwd)/.autojump/etc/profile.d/autojump.sh ]] && source $(pwd)/.autojump/etc/profile.d/autojump.sh" >> ~/.zshrc)
+echo "autoload -U compinit && compinit -u" >> ~/.zshrc
+
+#zsh-syntax-highlighting
+(cd ~/.oh-my-zsh/plugins; git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/plugins/zsh-syntax-highlighting)
diff --git a/baseline/ufw-allow-mosh b/baseline/ufw-allow-mosh
new file mode 100755
index 0000000..3f696ca
--- /dev/null
+++ b/baseline/ufw-allow-mosh
@@ -0,0 +1,31 @@
+#!/bin/bash
+# ripped off from here:https://stephenreescarter.net/mosh-and-ufw-without-1000-open-ports/
+# add entry in sudoers: my-awesome-user ALL:(ALL:ALL) NOPASSWD: /usr/local/bin/ufw-allow-mosh
+# then add this in zshrc: sudo /usr/local/bin/ufw-allow-mosh
+
+# Load active ports
+PORTS=`lsof -i | grep mosh-serv | cut -f2 -d":"`
+STATUS=`sudo ufw status`
+
+# Add Rules for new ports
+for PORT in $PORTS; do
+
+ echo $STATUS | grep "$PORT/udp" > /dev/null
+ if [ $? -gt 0 ]; then
+ echo "Allowing new port $PORT"
+ sudo ufw allow $PORT/udp > /dev/null
+ fi
+done
+
+# Remove closed ports
+PORTS=`sudo ufw status | grep "^60.../udp" | cut -f1 -d"/" | sort | uniq`
+OPEN=`lsof -i | grep mosh-serv`
+
+for PORT in $PORTS; do
+
+ echo $OPEN | grep $PORT > /dev/null
+ if [ $? -gt 0 ]; then
+ echo "Removing closed port $PORT."
+ sudo ufw delete allow $PORT/udp > /dev/null
+ fi
+done