Improved write_bashrc.py

This commit is contained in:
Sven Heidemann 2021-04-21 10:25:12 +02:00
parent 9d54650839
commit 7db81d0ee0
2 changed files with 14 additions and 5 deletions

View File

@ -17,7 +17,7 @@ install_git
install_lsd
install_ncdu
echo 'echo ""' | sudo tee -a /etc/bash.bashrc > /dev/null
sudo python3.9 write_bashrc.py
sudo python3.9 write_bashrc.py /home/ /root/
install_neofetch
install_trash_cli

View File

@ -10,6 +10,13 @@ Script to comment all alias ls="ls *" to allow global bashrc alias ls="lsd"
:copyright: (c) 2021 sh-edraft.de
:license: MIT, see LICENSE for more details.
At first check for root
Then load all .bashrc files from /home/<user>/
Each folder in /home/ must contain a .bashrc file, if not it won't be created
Usage: sudo python write_bashrc.py <home-dir> <root-dir>
Example: sudo python write_bashrc.py /home/ /root/
"""
__title__ = 'sh_write_bashrc'
@ -18,9 +25,7 @@ __license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 sh-edraft.de'
__version__ = '2021.4'
# At first check for root
# Then load all .bashrc files from /home/<user>/
# Each folder in /home/ must contain a .bashrc file, if not it won't be created
import os
import sys
@ -83,8 +88,12 @@ def _edit_script(file: str):
def main():
if len(sys.argv) < 3:
print('Usage: sudo pyhton write_bashrc.py <home-dir> <root-dir>')
exit()
_check_dependencies()
files = _load_all_scripts('/home/', '/root/')
files = _load_all_scripts(sys.argv[1], sys.argv[2])
for file in files:
_edit_script(file)