X-Git-Url: https://apps.delaporte.us/gitweb/dotfiles.git/blobdiff_plain/27aa66e9b912605eca68b3fa6eac82a746432683..1b86361660701a91480ed1931ae85c6f37266de4:/invoke/setup-linux/tasks.py?ds=sidebyside diff --git a/invoke/setup-linux/tasks.py b/invoke/setup-linux/tasks.py index 520b607..7303939 100644 --- a/invoke/setup-linux/tasks.py +++ b/invoke/setup-linux/tasks.py @@ -1,8 +1,11 @@ from invoke import task +from datetime import datetime as dt import os HOME = os.path.expanduser('~') +TODAY = dt.now().strftime('%Y.%m.%d') + @task() def defaults(c): @@ -12,6 +15,7 @@ DOTFILES=f'{HOME}/dotfiles' @task def setup_vi(c): + c.run('sudo apt-get install vim -y') c.run(f'ln -s {DOTFILES}/files/vimrc {HOME}/.vimrc') c.run(f'ls -al {HOME} | grep vimrc') c.run(f'mkdir -p {HOME}/.swp') @@ -24,7 +28,11 @@ def debug(c): def install_librewolf(c): c.run(f'$HOME/dotfiles/install/librewolf.sh') -@task(install_librewolf, setup_vi) +@task +def install_git(c): + c.run('sudo apt-get install git -y') + +@task(install_librewolf, setup_vi, install_git) def bare_minimum(c): pass @@ -38,6 +46,106 @@ def ssh_key(c): def screen(c): c.run(f'sudo apt-get install screen -y') c.run(f'$HOME/dotfiles/setup/screen.sh') - - +@task +def list_ports(c): + c.run('sudo netstat -tunlp') + +@task +def link_to_home(c, path, add_dot=False): + filename = os.path.basename(path) + if(add_dot): + filename = f'.{filename}' + + if(os.path.exists(f'{HOME}/{filename}')): + print(f'WARNING: {HOME}/{filename} exists.') + else: + c.run(f'ln -s {HOME}/dotfiles/{path} {HOME}/{filename}') + c.run(f'ls -la {HOME} | grep {filename}') + + +@task +def link_bashrc(c): + c.run(f'mv {HOME}/.bashrc {HOME}/bashrc_bak_{TODAY}') + link_to_home(c, 'files/pc/bashrc', add_dot=True) + + +@task +def link_all_for_invoke(c): + link_to_home(c, 'files/pc/tasks.py') + link_to_home(c, 'files/pc/bashrc', add_dot=True) + +@task +def vim_nerdtree(c): + add_vim_plugin(c, 'https://github.com/preservim/nerdtree.git', 'nerdtree') + +@task +def vim_markdown(c): + add_vim_plugin(c, 'https://github.com/preservim/vim-markdown.git', 'markdown') + +@task +def vim_airline(c): + add_vim_plugin(c, 'https://github.com/vim-airline/vim-airline.git', 'airline') + +@task +def vim_ollama(c): + add_vim_plugin(c, 'https://github.com/gergap/vim-ollama.git', 'vim-ollama') + +@task +def vim_all(c): + vim_airline(c) + vim_markdown(c) + vim_nerdtree(c) + +@task +def add_vim_plugin(c, git_path, folder): + c.run(f'mkdir -p {HOME}/.vim/pack/') + c.run(f'mkdir -p {HOME}/.vim/pack/vendor') + c.run(f'mkdir -p {HOME}/.vim/pack/vendor/opt') + c.run(f'git clone --depth 1 {git_path} {HOME}/.vim/pack/vendor/opt/{folder}') + c.run(f'ls -l {HOME}/.vim/pack/vendor/opt') + print(f"Use `packadd {folder}` in .vimrc to enable") + +@task +def ensure_env(c, env): + envs = f'{HOME}/envs' + path = f'{envs}/{env}' + if(not os.path.exists(envs)): + c.run(f'mkdir -p {envs}') + + if(not os.path.exists(path)): + c.run(f'python3 -m venv {path}') + reqs = f'{DOTFILES}/reqs/{env}.txt' + c.run(f'{path}/bin/pip install -r {reqs}') + + c.run(f'{path}/bin/pip freeze') + +@task +def env_borg(c): + ensure_env(c, 'borg') + +@task +def env_ansible(c): + ensure_env(c, 'ansible') + + +@task +def env_jupyter(c): + ensure_env(c, 'jupyter') + +@task +def clone(c, path): + c.run(f'mkdir -p {HOME}/src') + c.run(f'cd {HOME}/src; git clone {path}') + +@task +def clone_minion(c): + clone(c, 'ssh://git@codeberg.org/EdTheDev/minion.git') + +@task +def clone_favs(c): + clone(c, 'ssh://git@codeberg.org/EdTheDev/down-shift.git') + clone(c, 'ssh://git@codeberg.org/EdTheDev/todolist.git') + clone(c, 'ssh://git@codeberg.org/EdTheDev/weekend-template.git') + clone(c, 'ssh://git@codeberg.org/EdTheDev/invoke-tui.git') +