Added Powershell & git configuration

This commit is contained in:
Edgar P. Burkhart 2022-10-25 18:54:00 +02:00
commit f53e8244ca
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
8 changed files with 105 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
__pycache__

3
config.toml Normal file
View file

@ -0,0 +1,3 @@
[PowerShell]
in="src/PowerShell/profile.ps1"
out="~/Documents/WindowsPowerShell"

7
config.windows.toml Normal file
View file

@ -0,0 +1,7 @@
[PowerShell]
in="src/PowerShell/profile.ps1"
out="~/Documents/WindowsPowerShell"
[Git]
in="src/git/gitconfig"
out="~/.gitconfig"

8
config/__init__.py Normal file
View file

@ -0,0 +1,8 @@
import pathlib
def get_io(conf):
_in = pathlib.Path(conf.get("in")).expanduser()
_out = pathlib.Path(conf.get("out")).expanduser()
if _out.is_dir():
_out = _out.joinpath(_in.name)
return _in, _out

43
config/__main__.py Normal file
View file

@ -0,0 +1,43 @@
import argparse
import logging
import logging.config
import pathlib
import shutil
import sys
import tomllib
from . import get_io
logging.config.fileConfig(pathlib.Path(__file__).parent.joinpath("log.conf"))
log = logging.getLogger("config")
_argp = argparse.ArgumentParser(
prog="Config",
description="Install custom configurations",
)
_argp.add_argument("-c", "--config", default="config.toml", type=pathlib.Path, help="Configuration file location")
args = _argp.parse_args()
log.info("Config installation starting")
log.info(f"Loading configuration file <{args.config}>")
try:
with open(args.config, "rb") as _config_file:
config = tomllib.load(_config_file)
except FileNotFoundError:
log.error(f"Configuration file <{args.config}> does not exist.")
sys.exit(1)
if (_ps := config.get("PowerShell", None)):
_in, _out = get_io(_ps)
log.info(f"Copying PowerShell configuration from <{_in}> to <{_out}>")
shutil.copyfile(_in, _out)
if (_git := config.get("Git", None)):
_in, _out = get_io(_git)
log.info(f"Copying Git configuration from <{_in}> to <{_out}>")
shutil.copyfile(_in, _out)

27
config/log.conf Normal file
View file

@ -0,0 +1,27 @@
[loggers]
keys=root,config
[handlers]
keys=consoleHandler
[formatters]
keys=simpleFormatter
[logger_root]
level=INFO
handlers=consoleHandler
[logger_config]
level=INFO
handlers=consoleHandler
qualName=config
propagate=0
[handler_consoleHandler]
class=StreamHandler
level=INFO
formatter=simpleFormatter
args=(sys.stdout,)
[formatter_simpleFormatter]
format=%(asctime)s - %(name)s#%(levelname)s %(message)s

8
src/Git/gitconfig Normal file
View file

@ -0,0 +1,8 @@
[user]
name = Edgar P. Burkhart
email = git@edgarpierre.fr
signingkey = 9833D3C5A25BD227
[commit]
gpgsign = true
[tag]
gpgsign = true

View file

@ -0,0 +1,8 @@
if ($host.Name -eq 'ConsoleHost')
{
Import-Module PSReadLine
Set-PSReadlineOption -EditMode Emacs
function Wake-Orchomenos {
ssh leopold.burkhart.ovh wakeonlan 70:85:C2:8C:BA:BB
}
}