]> apps.delaporte.us Git - dotfiles.git/blob - invoke/setup-linux/tasks.py
Improved vim plugin setup for vim 8+
[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 add_vim_plugin(c, git_path, folder):
92 c.run(f'mkdir -p {HOME}/.vim/pack/')
93 c.run(f'mkdir -p {HOME}/.vim/pack/vendor')
94 c.run(f'mkdir -p {HOME}/.vim/pack/vendor/opt')
95 c.run(f'git clone --depth 1 {git_path} {HOME}/.vim/pack/vendor/opt/{folder}')
96 c.run(f'ls -l {HOME}/.vim/pack/vendor/opt')
97 print(f"Use `packadd {folder}` in .vimrc to enable")
98