new stuff
This commit is contained in:
@@ -58,3 +58,4 @@ _complete_ssh_hosts ()
|
||||
|
||||
complete -F _complete_ssh_hosts ssh
|
||||
complete -F _complete_ssh_hosts scp
|
||||
. "$HOME/.cargo/env"
|
||||
|
||||
+116
-27
@@ -2,21 +2,39 @@
|
||||
# This file is for shell functions common between shells: zsh, bash
|
||||
###################################################################
|
||||
|
||||
function local_pi() {
|
||||
LOCAL_PI_IP=$(en4ip)
|
||||
ssh -b $LOCAL_PI_IP pi@169.254.100.100
|
||||
# Uses OSC52 to attempt to copy to client's clipboard through the terminal
|
||||
function osc52() {
|
||||
CB_DATA="$@"
|
||||
echo -en "\033]52;c;$(echo $CB_DATA | base64)\a"
|
||||
}
|
||||
|
||||
function osc52_file() {
|
||||
echo -en "\033]52;c;$(base64 $1)\a"
|
||||
}
|
||||
|
||||
function pubkey() {
|
||||
if [ -f ~/.ssh/id_rsa.pub ]; then
|
||||
PUBKEY_PATH="$HOME/.ssh/id_rsa.pub"
|
||||
SUCCESS=0
|
||||
if [ -f "$PUBKEY_PATH" ]; then
|
||||
if which pbcopy &> /dev/null; then
|
||||
cat ~/.ssh/id_rsa.pub | pbcopy
|
||||
echo "Copied public key using pbcopy"
|
||||
else
|
||||
cat $PUBKEY_PATH | pbcopy
|
||||
SUCCESS=1
|
||||
echo "Copied public key [$PUBKEY_PATH] using pbcopy"
|
||||
fi
|
||||
|
||||
if [ "$SUCCESS" = "0" ]; then
|
||||
osc52_file $PUBKEY_PATH
|
||||
echo "Copied public key [$PUBKEY_PATH] using osc52"
|
||||
SUCCESS=1
|
||||
fi
|
||||
|
||||
if [ "$SUCCESS" = "0" ]; then
|
||||
echo "pbcopy not available - printing public key"
|
||||
echo
|
||||
cat ~/.ssh/id_rsa.pub
|
||||
cat $PUBKEY_PATH
|
||||
fi
|
||||
else
|
||||
echo "$PUBKEY_PATH does not exist"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -58,25 +76,6 @@ function decrypt() {
|
||||
fi
|
||||
}
|
||||
|
||||
function init_flask() {
|
||||
mkdir -p templates
|
||||
touch templates/index.html
|
||||
curl "https://raw.githubusercontent.com/lewagon/bootstrap-boilerplate/gh-pages/index.html" > templates/index.html
|
||||
FLASK_TEMPLATE="from flask import Flask, render_template, request
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.debug = True
|
||||
app.run()
|
||||
"
|
||||
echo "$FLASK_TEMPLATE" > app.py
|
||||
}
|
||||
|
||||
function weather() {
|
||||
LOCATION=milwaukee
|
||||
|
||||
@@ -101,3 +100,93 @@ function flocate() {
|
||||
zgrep $1 /tmp/flocate.db --color=auto
|
||||
}
|
||||
|
||||
function install_pyenv() {
|
||||
if [ ! -d "$HOME/.pyenv" ]; then
|
||||
curl https://pyenv.run | bash
|
||||
else
|
||||
echo "pyenv is already installed"
|
||||
echo "remove ~/.pyenv to reinstall"
|
||||
fi
|
||||
|
||||
echo "Installing python 3.9"
|
||||
pyenv install 3.9 -s
|
||||
|
||||
echo "Creating sandbox virtualenv"
|
||||
pyenv virtualenv sandbox
|
||||
}
|
||||
|
||||
function install_nvm() {
|
||||
if [ ! -f "$HOME/.nvm/nvm.sh" ]; then
|
||||
PROFILE=/dev/null curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
|
||||
else
|
||||
echo "nvm is already installed"
|
||||
fi
|
||||
nvm install --lts
|
||||
}
|
||||
|
||||
function install_rust() {
|
||||
if [ ! -d "$HOME/.rustup" ]; then
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||
else
|
||||
echo "rustup is already installed. remove ~/.rustup to reinstall"
|
||||
fi
|
||||
}
|
||||
|
||||
function init_apt() {
|
||||
sudo apt-get install -y \
|
||||
libssl-dev \
|
||||
libncurses-dev \
|
||||
libbz2-dev \
|
||||
libffi-dev \
|
||||
libreadline-dev \
|
||||
libsqlite3-dev \
|
||||
liblzma-dev \
|
||||
python-is-python3 \
|
||||
python3-venv \
|
||||
build-essential \
|
||||
vim \
|
||||
tmux \
|
||||
net-tools \
|
||||
ripgrep \
|
||||
}
|
||||
|
||||
function init_debian() {
|
||||
init_apt
|
||||
install_pyenv
|
||||
install_nvm
|
||||
install_rust
|
||||
}
|
||||
|
||||
function autosetup() {
|
||||
if [ "$(uname)" = "Linux" ]; then
|
||||
IS_LINUX="1"
|
||||
else
|
||||
IS_LINUX="0"
|
||||
fi
|
||||
|
||||
if [ "$IS_LINUX" = "1" ]; then
|
||||
which lsb_release > /dev/null 2>&1
|
||||
if [ "$?" = "0" ]; then
|
||||
DETECTED_DISTRO=$(lsb_release -a 2>/dev/null | grep Distributor | awk '{print $3}')
|
||||
else
|
||||
echo "Could not detect distribution"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$IS_LINUX" = "1" ]; then
|
||||
echo "Setting up Linux: $DETECTED_DISTRO"
|
||||
|
||||
case $DETECTED_DISTRO in
|
||||
Ubuntu*)
|
||||
init_debian
|
||||
;;
|
||||
Debian*)
|
||||
init_debian
|
||||
;;
|
||||
*)
|
||||
echo "Unknown distribution $DETECTED_DISTRO"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
unset IS_LINUX DETECTED_DISTRO
|
||||
}
|
||||
|
||||
@@ -7,6 +7,24 @@ set nu
|
||||
set ignorecase
|
||||
filetype plugin indent on
|
||||
|
||||
"Space as leader
|
||||
nmap <Tab> <Nop>
|
||||
nnoremap <Space> <Nop>
|
||||
let mapleader="\<Space>"
|
||||
let g:mapleader="\<Space>"
|
||||
|
||||
"Buffer navigation
|
||||
nnoremap [b :bp<CR>
|
||||
nnoremap ]b :bn<CR>
|
||||
nnoremap <leader>c :bd<CR>
|
||||
nnoremap <leader>C :bd!<CR>
|
||||
nnoremap <leader>f :echo expand('%:p')<CR>
|
||||
|
||||
" Window navigation
|
||||
nnoremap <C-h> <C-w>h
|
||||
nnoremap <C-j> <C-w>j
|
||||
nnoremap <C-k> <C-w>k
|
||||
nnoremap <C-l> <C-w>l
|
||||
|
||||
" Tab settings
|
||||
set expandtab
|
||||
@@ -23,18 +41,13 @@ autocmd FileType typescriptreact setlocal shiftwidth=2 tabstop=2 softtabstop=2 e
|
||||
autocmd FileType html setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab
|
||||
autocmd FileType python setlocal shiftwidth=4 tabstop=4 softtabstop=4 expandtab
|
||||
|
||||
|
||||
"Space as leader
|
||||
nmap <Tab> <Nop>
|
||||
nnoremap <Space> <Nop>
|
||||
let mapleader="\<Space>"
|
||||
let g:mapleader="\<Space>"
|
||||
|
||||
" Window navigation
|
||||
nnoremap <C-h> <C-w>h
|
||||
nnoremap <C-j> <C-w>j
|
||||
nnoremap <C-k> <C-w>k
|
||||
nnoremap <C-l> <C-w>l
|
||||
" Trim whitespace before write
|
||||
fun! TrimWhitespace()
|
||||
let l:save = winsaveview()
|
||||
keeppatterns %s/\s\+$//e
|
||||
call winrestview(l:save)
|
||||
endfun
|
||||
autocmd BufWritePre * call TrimWhitespace()
|
||||
|
||||
|
||||
set cmdheight=2
|
||||
@@ -68,58 +81,48 @@ Plug 'peitalin/vim-jsx-typescript'
|
||||
Plug 'ojroques/vim-oscyank', {'branch': 'main'}
|
||||
call plug#end()
|
||||
|
||||
|
||||
"Colorscheme
|
||||
colorscheme gruvbox-material
|
||||
|
||||
"Coc Config
|
||||
function! ShowDocumentation()
|
||||
if CocAction('hasProvider', 'hover')
|
||||
call CocActionAsync('doHover')
|
||||
else
|
||||
call feedkeys('K', 'in')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"Coc Keybinds
|
||||
nmap <leader>d <Plug>(coc-definition)
|
||||
nmap <leader>rn <Plug>(coc-rename)
|
||||
nmap <slient> gd <Plug>(coc-definition)
|
||||
nmap <silent> gd <Plug>(coc-definition)
|
||||
nmap <silent> gy <Plug>(coc-type-definition)
|
||||
nmap <silent> gi <Plug>(coc-implementation)
|
||||
nmap <silent> gr <Plug>(coc-references)
|
||||
imap <C-x> <Plug>(coc-snippets-expand)
|
||||
imap <silent> <C-x> <Plug>(coc-snippets-expand)
|
||||
inoremap <silent><expr> <C-f> coc#refresh()
|
||||
inoremap <silent><expr> <C-e> coc#pum#visible() ? coc#pum#confirm() : <Nop>
|
||||
nnoremap <silent> K :call ShowDocumentation()<CR>
|
||||
|
||||
let g:coc_disable_transparent_cursor=1
|
||||
|
||||
"Use tab for snippet completion and jumping
|
||||
inoremap <silent><expr> <TAB>
|
||||
\ pumvisible() ? coc#_select_confirm() :
|
||||
\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
|
||||
\ <SID>check_back_space() ? "\<TAB>" :
|
||||
\ coc#refresh()
|
||||
|
||||
function! s:check_back_space() abort
|
||||
let col = col('.') - 1
|
||||
return !col || getline('.')[col - 1] =~# '\s'
|
||||
endfunction
|
||||
|
||||
let g:coc_snippet_next = '<tab>'
|
||||
|
||||
|
||||
"SimpylFold Config
|
||||
let g:SimpylFold_docstring_preview=1
|
||||
|
||||
|
||||
"NERDTree keybinds
|
||||
nmap <leader>g :NERDTreeFind<CR>
|
||||
nmap <leader>tt :NERDTreeFocus<CR>
|
||||
let NERDTreeIgnore = ['__pycache__', '\.pyc$', '\.egg-info$', 'node_modules']
|
||||
|
||||
|
||||
"CtrlP config
|
||||
nmap <C-E> :CtrlPBuffer<CR>
|
||||
let g:ctrlp_working_path_mode= 0
|
||||
let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git\|\.egg-info|\.pyc'
|
||||
|
||||
|
||||
"fzf keybinds
|
||||
let $FZF_DEFAULT_COMMAND = 'ag -g "" --ignore="(dist|*.svg)"'
|
||||
let $FZF_DEFAULT_COMMAND = 'rg --files -g "!node_modules/"'
|
||||
nmap <C-F> :FZF<CR>
|
||||
nmap <C-G> :Ag<CR>
|
||||
|
||||
nmap <C-G> :Rg<CR>
|
||||
|
||||
"Wildignore
|
||||
set wildignore+=*/node_modules/*,*/__pycache__/*,*.pyc,*.egg-info
|
||||
|
||||
@@ -81,3 +81,22 @@ fi
|
||||
if [ -f ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]; then
|
||||
. ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh
|
||||
fi
|
||||
|
||||
#pyenv
|
||||
if [ -f "$HOME/.pyenv/bin/pyenv" ]; then
|
||||
export PYENV_ROOT="$HOME/.pyenv"
|
||||
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
|
||||
eval "$(pyenv init -)"
|
||||
fi
|
||||
|
||||
#nvm
|
||||
if [ -f "$HOME/.nvm/nvm.sh" ]; then
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
||||
fi
|
||||
|
||||
#rust
|
||||
if [ -f "$HOME/.cargo/env" ]; then
|
||||
source "$HOME/.cargo/env"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user