From 68cfd9747b0035e395a95b7a4ed38cd274960204 Mon Sep 17 00:00:00 2001 From: dhvcc Date: Tue, 2 Jul 2024 00:31:01 +0300 Subject: [PATCH] Testing dockerfile for brew, add import history script --- .cfg/Dockerfile.test.brew | 41 ++++++++++++++++++++++ .cfg/scripts/import-bash-history-to-zsh.py | 25 +++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 .cfg/Dockerfile.test.brew create mode 100755 .cfg/scripts/import-bash-history-to-zsh.py diff --git a/.cfg/Dockerfile.test.brew b/.cfg/Dockerfile.test.brew new file mode 100644 index 0000000..73cbd5d --- /dev/null +++ b/.cfg/Dockerfile.test.brew @@ -0,0 +1,41 @@ +FROM ubuntu:22.04 + +WORKDIR /root + +# ubuntu only +RUN apt update +RUN apt install -y curl git build-essential + + +# Install brew +RUN curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | env NONINTERACTIVE=1 bash + +RUN echo 'export PATH="$PATH:/home/linuxbrew/.linuxbrew/bin"' >> "$HOME/.bashrc" +ENV PATH="$PATH:/home/linuxbrew/.linuxbrew/bin" + +RUN brew doctor + +# Xclip ubuntu only +RUN brew install unzip xclip vim neovim + +RUN brew install starship neofetch fzf btop wget \ + pyenv nvm \ + lsd fd ripgrep bat `# rust utils` + +# INSTALL VIM THINGS +RUN curl -fLo '~/.vim/autoload/plug.vim' --create-dirs \ + 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + +RUN rm -rf .bashrc .zshrc && curl -Lks https://raw.githubusercontent.com/dhvcc/configs/master/.cfg/install.sh | /bin/sh + +# Install manually or in script +#ENV NVM_DIR="$HOME/.nvm" +#RUN test -s "/home/linuxbrew/.linuxbrew/opt/nvm/nvm.sh" && . "/home/linuxbrew/.linuxbrew/opt/nvm/nvm.sh"; nvm install 16 + +# ubuntu only +RUN apt install -y zsh +# +RUN "$HOME/.cfg/scripts/install-omb.sh" +RUN "$HOME/.cfg/scripts/install-omz.sh" + +CMD bash diff --git a/.cfg/scripts/import-bash-history-to-zsh.py b/.cfg/scripts/import-bash-history-to-zsh.py new file mode 100755 index 0000000..be91cda --- /dev/null +++ b/.cfg/scripts/import-bash-history-to-zsh.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import time + + +def main(): + timestamp = None + with open("~/.bash_history", "rt") as bash_history: + with open("~/.zsh_history", "wt") as zsh_history: + for line in bash_history.readlines(): + line = line.rstrip('\n') + if line.startswith('#') and timestamp is None: + t = line[1:] + if t.isdigit(): + timestamp = t + continue + else: + zsh_history.write(': %s:0;%s\n' % (timestamp or time.time(), line)) + timestamp = None + + +if __name__ == '__main__': + main() +