]> apps.delaporte.us Git - dotfiles.git/blob - invoke/setup-linux/tasks.py
Debian game list helper
[dotfiles.git] / invoke / setup-linux / tasks.py
1 from invoke import task
2
3 from datetime import datetime as dt
4 import os
5
6 HOME = os.path.expanduser('~')
7 TODAY = dt.now().strftime('%Y.%m.%d')
8
9
10 @task()
11 def defaults(c):
12 c.run('update-alternatives --config gnome-www-browser')
13
14 DOTFILES=f'{HOME}/dotfiles'
15
16 @task
17 def setup_vi(c):
18 c.run('sudo apt-get install vim -y')
19 c.run(f'ln -s {DOTFILES}/files/vimrc {HOME}/.vimrc')
20 c.run(f'ls -al {HOME} | grep vimrc')
21 c.run(f'mkdir -p {HOME}/.swp')
22
23 @task
24 def debug(c):
25 pass
26
27 @task
28 def install_librewolf(c):
29 c.run(f'$HOME/dotfiles/install/librewolf.sh')
30
31 @task
32 def install_git(c):
33 c.run('sudo apt-get install git -y')
34
35 @task(install_librewolf, setup_vi, install_git)
36 def bare_minimum(c):
37 pass
38
39 @task
40 def ssh_key(c):
41 # c.run(f'ssh-keygen')
42 c.run(f'librewolf https://codeberg.org/user/settings/keys', asynchronous=True)
43 c.run(f'cat $HOME/.ssh/*.pub')
44
45 @task
46 def screen(c):
47 c.run(f'sudo apt-get install screen -y')
48 c.run(f'$HOME/dotfiles/setup/screen.sh')
49
50 @task
51 def list_ports(c):
52 c.run('sudo netstat -tunlp')
53
54 @task
55 def link_to_home(c, path, add_dot=False):
56 filename = os.path.basename(path)
57 if(add_dot):
58 filename = f'.{filename}'
59
60 if(os.path.exists(f'{HOME}/{filename}')):
61 print(f'WARNING: {HOME}/{filename} exists.')
62 else:
63 c.run(f'ln -s {HOME}/dotfiles/{path} {HOME}/{filename}')
64 c.run(f'ls -la {HOME} | grep {filename}')
65
66
67 @task
68 def link_bashrc(c):
69 c.run(f'mv {HOME}/.bashrc {HOME}/bashrc_bak_{TODAY}')
70 link_to_home(c, 'files/pc/bashrc', add_dot=True)
71
72
73 @task
74 def link_all_for_invoke(c):
75 link_to_home(c, 'files/pc/tasks.py')
76 link_to_home(c, 'files/pc/bashrc', add_dot=True)
77
78 @task
79 def vim_nerdtree(c):
80 add_vim_plugin(c, 'https://github.com/preservim/nerdtree.git', 'nerdtree')
81
82 @task
83 def vim_markdown(c):
84 add_vim_plugin(c, 'https://github.com/preservim/vim-markdown.git', 'markdown')
85
86 @task
87 def vim_airline(c):
88 add_vim_plugin(c, 'https://github.com/vim-airline/vim-airline.git', 'airline')
89
90 @task
91 def vim_ollama(c):
92 add_vim_plugin(c, 'https://github.com/gergap/vim-ollama.git', 'vim-ollama')
93
94 @task
95 def vim_all(c):
96 vim_airline(c)
97 vim_markdown(c)
98 vim_nerdtree(c)
99
100 @task
101 def add_vim_plugin(c, git_path, folder):
102 c.run(f'mkdir -p {HOME}/.vim/pack/')
103 c.run(f'mkdir -p {HOME}/.vim/pack/vendor')
104 c.run(f'mkdir -p {HOME}/.vim/pack/vendor/opt')
105 c.run(f'git clone --depth 1 {git_path} {HOME}/.vim/pack/vendor/opt/{folder}')
106 c.run(f'ls -l {HOME}/.vim/pack/vendor/opt')
107 print(f"Use `packadd {folder}` in .vimrc to enable")
108
109 @task
110 def ensure_env(c, env):
111 envs = f'{HOME}/envs'
112 path = f'{envs}/{env}'
113 if(not os.path.exists(envs)):
114 c.run(f'mkdir -p {envs}')
115
116 if(not os.path.exists(path)):
117 c.run(f'python3 -m venv {path}')
118 reqs = f'{DOTFILES}/reqs/{env}.txt'
119 c.run(f'{path}/bin/pip install -r {reqs}')
120
121 c.run(f'{path}/bin/pip freeze')
122
123 @task
124 def env_borg(c):
125 ensure_env(c, 'borg')
126
127 @task
128 def env_ansible(c):
129 ensure_env(c, 'ansible')
130
131
132 @task
133 def env_jupyter(c):
134 ensure_env(c, 'jupyter')
135
136 @task
137 def clone(c, path):
138 c.run(f'mkdir -p {HOME}/src')
139 c.run(f'cd {HOME}/src; git clone {path}')
140
141 @task
142 def clone_minion(c):
143 clone(c, 'ssh://git@codeberg.org/EdTheDev/minion.git')
144
145 @task
146 def clone_favs(c):
147 clone(c, 'ssh://git@codeberg.org/EdTheDev/down-shift.git')
148 clone(c, 'ssh://git@codeberg.org/EdTheDev/todolist.git')
149 clone(c, 'ssh://git@codeberg.org/EdTheDev/weekend-template.git')
150 clone(c, 'ssh://git@codeberg.org/EdTheDev/invoke-tui.git')
151