5 Commit-ok 65afaeea0e ... 4d668fe3aa

Szerző SHA1 Üzenet Dátum
  Czobor 4d668fe3aa Formatting messages joining lists into strings 3 éve
  Czobor 4265678d39 Adding .gitingore with __pycache__ 3 éve
  Czobor ff843587fe Adding zsh.sh for zsh stuff 3 éve
  Czobor 52e0b1bb59 Configuration file (zsh stuff working) 3 éve
  Czobor deee25c97b Python script run.py install stuffs 3 éve
4 módosított fájl, 107 hozzáadás és 0 törlés
  1. 2 0
      .gitignore
  2. 12 0
      config.py
  3. 85 0
      run.py
  4. 8 0
      zsh.sh

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+__pycache__
+

+ 12 - 0
config.py

@@ -0,0 +1,12 @@
+stuffs = {
+        # stuff -> (install_command, (depend0, depend1, ...))
+        'dotfiles': (None, ('zsh', 'tmux', 'neovim')),
+        'zsh': ('sh zsh.sh', ('zsh',)),
+        'i3wm': (None, None),
+        'st': (None, None),
+        'tmux': (None, None),
+        'plover': (None, None),
+        'qt': (None, None),
+        'flutter': (None, None),
+}
+

+ 85 - 0
run.py

@@ -0,0 +1,85 @@
+#!/usr/bin/python
+
+import config
+import subprocess
+
+DECORATION_WIDTH = 50
+
+
+def interactive_stuff_selection(stuffs):
+    stuffs_accepted = {}
+    print('[ 0 ] all')
+    for index, stuff in enumerate(stuffs):
+        number = index + 1
+        if index == len(stuffs.keys()) - 1:
+            endline = '\n'
+        else:
+            endline = '\t' if number % 3 else '\n'
+        print(f'[ {number} ] {stuff}', end=endline)
+    answer_list = input('--> ') \
+            .strip() \
+            .replace(',', ' ') \
+            .split()
+    for number in answer_list:
+        number = int(number)
+        if number == 0:
+            stuffs_accepted = stuffs.copy()
+            return stuffs_accepted
+        elif 0 < number <= len(stuffs.keys()):
+            stuff_name = list(stuffs.keys())[number - 1]
+            stuffs_accepted[stuff_name] = stuffs[stuff_name]
+        else:
+            print(f'Warning: Number {number} is too high or too low. Ignoring')
+            answer_list.remove(str(number))
+    return stuffs_accepted
+
+
+def install_packages(command, packages_list):
+    global DECORATION_WIDTH
+    print(f' Dependencies: {", ".join(packages_list)} '.center(DECORATION_WIDTH, '-'))
+    return subprocess.call(command.split() + packages_list)
+
+
+def install_stuff(install_command, stuff_name):
+    global DECORATION_WIDTH
+    print(f' Stuff script: {stuff_name} '.center(DECORATION_WIDTH, '-'))
+    return subprocess.call(install_command.split())
+
+
+def ask(message, function=lambda string: string.lower() in ['yes', 'y','']):
+    return function(input(message))
+
+
+def only_unresolved_dependencies(dependecies, resolved_dependencies):
+    unresolved_dependecies = []
+    for dependency in dependecies:
+        if not dependency in resolved_dependencies:
+            unresolved_dependecies.append(dependency)
+    return unresolved_dependecies
+
+
+os_install_command = None
+resolved_depends = []
+install_error_depends = []
+
+stuffs_to_install = interactive_stuff_selection(config.stuffs)
+for stuff, value in stuffs_to_install.items():
+    script, depends = value
+    dependecies_to_install = only_unresolved_dependencies(depends, resolved_depends)
+    print(f' Stuff: {stuff} '.center(DECORATION_WIDTH, '='))
+    if not script and not depends:
+        print('Nothing to do')
+    is_to_install_depends = ask(f'Do you wanna install [{", ".join(dependecies_to_install)}]? ') if dependecies_to_install else False
+    if is_to_install_depends:
+        if not os_install_command:
+            os_install_command = input('system\'s install command: ')
+        if install_packages(os_install_command, dependecies_to_install) == 0:
+            resolved_depends.extend(dependecies_to_install)
+        else:
+            input(f'!!! Install [{", ".join(dependecies_to_install)}] fail. Press ENTER to continue')
+            install_error_depends.extend(dependecies_to_install)
+    if script:
+        install_stuff(script, stuff)
+if len(install_error_depends):
+    print(f'Failed to install packages {install_error_depends}')
+

+ 8 - 0
zsh.sh

@@ -0,0 +1,8 @@
+echo "Getting ohmyzsh https://github.com/ohmyzsh/ohmyzsh"
+sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
+
+echo "Getting powerlevel10k"
+git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
+
+echo "Getting zsh-syntax-highlighting"
+git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting