Ver Fonte

v 2.0.1-rc1

control há 1 ano atrás
pai
commit
e5f301eedc

+ 12 - 0
_ver_2.0.1.md

@@ -0,0 +1,12 @@
+# DOTS
+
+**Current Version** : __2.0.1__
+
+---
+
+# Changelog
+
+## 2025-01-01    v 2.0.1
+
+### New:
+- Standalone, no longer coupled with QConfig

+ 5 - 27
default_aliases → aliases/default_aliases

@@ -2,7 +2,6 @@
 
 host=$(hostname)
 hostname="${host^^}"
-repo_directory="/opt/qconfig"
 
 # Colored Prompts
 alias ls='ls --color=auto'
@@ -56,41 +55,20 @@ function check-env() {
 }
 alias ce="check-env"
 
-function edit-alias() {
-    if [ -f "$repo_directory/user_aliases" ]; then
-        vim "$repo_directory/user_aliases"
-        sp
-    else
-        vim ~/.dots/user_aliases
-        sp
-    fi
-}
+alias edit-alias="vim ~/.dots/user/aliases"
 alias edit-aliases="edit-alias"
 alias ea="edit-alias"
 
-function edit-paths() {
-    if [ -f "$repo_directory/user_paths" ]; then
-        vim "$repo_directory/user_paths"
-        sp
-    else
-        vim ~/.dots/user_paths
-        sp
-    fi
-}
+edit-path="vim ~/.dots/user/paths"
+edit-paths="edit-path"
 alias ep="edit-paths"
 
-if [ -d "/opt/qconfig" ]; then
-    alias uqconfig="cd /opt/qconfig/"
-fi
+alias acknowledge-prompt="rm -rf /tmp/prompt_msg"
+alias ack="acknowledge-prompt"
 
-alias exec-setup="bash ~/dots/setup.sh"
-alias edit-source="vim ~/.bashrc"
-alias es="edit-source"
 alias source-profile="source ~/.bashrc"
 alias source-pro="source-profile"
 alias sp="source-pro"
-alias acknowledge-prompt="rm -rf /tmp/prompt_msg"
-alias ack="acknowledge-prompt"
 
 alias internetSpeedTest="wget -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip"
 alias ufwcmd="echo 'ufw allow proto tcp from 0.0.0.0 port 00 to 0.0.0.0 port 00 comment'"

+ 0 - 0
system_aliases → aliases/system_aliases


+ 0 - 0
inputrc → app_config/inputrc


+ 0 - 0
nvim → app_config/nvim


+ 0 - 0
tmux.conf → app_config/tmux.conf


+ 0 - 0
tmuxp.conf → app_config/tmuxp.conf


+ 0 - 0
vimrc → app_config/vimrc


+ 116 - 0
install

@@ -0,0 +1,116 @@
+#!/usr/bin/python3
+# run as: root/user
+
+import os
+import sys
+import shutil
+
+SPATH = os.path.abspath(__file__)
+SDIR = os.path.dirname(SPATH)
+
+# Bash to loop through dir and source files
+BASHRC_STR = \
+""" # Dots Base Files
+for file in ~/.dots/base/*; do
+    if [ -r \"$file\" ]; then
+        source \"$file\"
+    fi
+done
+
+# Dots User Files
+for file in ~/.dots/user/*; do
+    if [ -r \"$file\" ]; then
+        source \"$file\"
+    fi
+done """
+
+def run(command: str):
+    os.system(command)
+
+def get_prompt() -> str:
+    # Check for argument input
+    if len(sys.argv) < 2:
+        print('::[Dots Installation Script]::')
+        print('Usage: install <prompt to use: (seafly|parrot|powerline)>')
+        sys.exit(1)
+
+    # Ensure user choice is valid
+    prompts = ['seafly', 'parrot', 'powerline']
+    uprompt = sys.argv[1]
+
+    if uprompt not in prompts:
+        print('Please choose a valid prompt file!')
+        print('seafly | parrot | powerline')
+        sys.exit(1)
+
+    return uprompt
+
+def string_in_file(path: str, string: str) -> bool:
+    try:
+        epath = os.path.expandvars(path) # expand Bash Environment Variables
+        with open(epath, 'r') as file:
+            file_contents = file.read()
+
+        if string in file_contents:
+            return True
+        else:
+            return False
+    except Exception as e:
+        print(f'General Exception (string_in_file): {e}')
+
+def add_string(path: str, string: str) -> bool:
+    try:
+        epath = os.path.expandvars(path) # expand Bash Environment Variables
+        with open(epath, 'a') as file:
+            file.write(string + '\n')
+        return True
+    except Exception as e:
+        print(f'General Exception (add_string): {e}')
+        return False
+
+# Create path and children if not exists
+def create_path(path) -> bool:
+    try:
+        epath = os.path.expandvars(path) # expand Bash Environment Variables
+        os.makedirs(epath, exist_ok = True)
+        return True
+    except Exception as e:
+        print(f'General Exception (create_path): {e}')
+        return False
+
+def copy_file(source: str, destination: str) -> bool:
+    try:
+        src = os.path.expandvars(source) # expand Bash Environment Variables
+        dst = os.path.expandvars(destination)
+        shutil.copy2(src, dst)
+        return True
+    except Exception as e:
+        print(f'General Exception (copy_file): {e}')
+        return False
+
+def main():
+    uprompt = get_prompt()
+
+    # NVIM
+    create_path('$HOME/.config/nvim/')
+    copy_file(f'{SDIR}/app_config/nvim', '$HOME/.config/nvim/init.vim')
+
+    # TMUX
+    copy_file(f'{SDIR}/app_config/tmux.conf', '$HOME/.tmux.conf')
+
+    # Create dots working dir
+    run(f'rm -rf $HOME/.dots/base/') # Remove old config
+    create_path('$HOME/.dots/base/')
+    create_path('$HOME/.dots/user/')
+
+    # Set default aliases
+    copy_file(f'{SDIR}/aliases/default_aliases', f'$HOME/.dots/base')
+    copy_file(f'{SDIR}/prompts/{uprompt}-prompt', f'$HOME/.dots/base')
+
+    # Add Bashrc Config
+    if not string_in_file('$HOME/.bashrc', BASHRC_STR):
+        add_string('$HOME/.bashrc', BASHRC_STR)
+
+
+if __name__ == '__main__':
+    main()

+ 0 - 0
parrot-prompt → prompts/parrot-prompt


+ 0 - 0
powerline-prompt → prompts/powerline-prompt


+ 0 - 0
seafly-prompt → prompts/seafly-prompt


+ 0 - 0
life.sh → scripts/life.sh


+ 0 - 68
setup.sh

@@ -1,68 +0,0 @@
-#!/bin/bash
-
-# Location: $HOME/dots
-# User Scope: user
-# Run as: ./setup.sh <arg>
-
-# Script to setup terminal environment
-
-if [ $# -ne 1 ]; then
-    echo "::[Dots Setup Script]::"
-    echo "Usage: setup.sh <prompt to use: seafly|parrot|powerline>"
-    exit 1
-fi
-
-main_user=$USER
-user_prompt="$1"
-
-# Set Permissions
-chmod 660 $(find ./ -type f)
-chmod 660 $(find "$HOME/.bashrc" -type f)
-chmod 770 $(find "$HOME/dots" -type d)
-
-function add_string_to_file() {
-    # Checks if a string is in a file
-    # adds it if it isn't in that file
-    local file="$1"
-    local string="$2"
-
-    if ! grep -q "$string" "$file"; then
-        echo "$string" >> "$file"
-    fi
-}
-
-# Bashrc
-add_string_to_file "$HOME/.bashrc" "source $HOME/dots/default_aliases"
-add_string_to_file "$HOME/.bashrc" "source $HOME/dots/$user_prompt-prompt"
-
-# Bashrc for control
-if [ $main_user == "control" ]; then
-    add_string_to_file "$HOME/.bashrc" "bash $HOME/dots/life.sh 1993-07-21 control"
-fi
-
-# NVIM
-mkdir -p "$HOME/.config/nvim/"
-cp "./nvim" "$HOME/.config/nvim/init.vim"
-
-# TMUX
-cp "./tmux.conf" "$HOME/.tmux.conf"
-
-
-# PATH VARS
-if [ -f "$HOME/.dots/user_paths" ]; then
-    chmod 660 "$HOME/.dots/user_paths"
-    add_string_to_file "$HOME/.bashrc" "source $HOME/.dots/user_paths"
-fi
-
-if [ -f "$HOME/.dots/user_aliases" ]; then
-    chmod 660 "$HOME/.dots/user_aliases"
-    add_string_to_file "$HOME/.bashrc" "source $HOME/.dots/user_aliases"
-fi
-
-# Set System Aliases
-sudo cp -f "$HOME/dots/system_aliases" "/etc/system_aliases"
-sudo chmod 666 "/etc/system_aliases"
-sudo add_string_to_file "/etc/bash.bashrc" "source /etc/system_aliases"
-
-# Source
-source "$HOME/.bashrc"