packages = ["beautifulsoup4", "requests", "pyodide-http"] terminal = false [splashscreen] enabled = true autoclose = true [[interpreters]] src = "https://cdn.jsdelivr.net/pyodide/v0.21.2/full/pyodide.js" name = "pyodide-0.21.2" lang = "python" import requests import pyodide_http import base64 pyodide_http.patch_all() def get_json_url(url, params=None): resp = requests.get(url=url, verify=False, params=params) if resp.status_code == 200: return resp.json() else: return None def get_file_details(dir_data): data_dict = {} data_dict["dir"] = dir_data.get("path") dict_dir_data = get_json_url(dir_data.get("url")).get("tree") for data_files in dict_dir_data: if ".bashrc" == data_files["path"]: data_dict[".bashrc-url"] = f"https://github.com/V70024/BASHrc-s/blob/master/{dir_data.get('path')}/.bashrc" data_dict[".bashrc-code-url"] = f"https://github.com/V70024/BASHrc-s/raw/master/{dir_data.get('path')}/.bashrc" elif "README.md" == data_files["path"]: readme_url = f"https://github.com/V70024/BASHrc-s/blob/master/{dir_data.get('path')}/README.md" data_dict[".README-url"] = readme_url readme_content = get_json_url(data_files["url"]).get("content") if readme_content: data_dict[".bashrc-preview"] = base64.b64decode(readme_content.encode("utf-8")).decode("utf-8") return data_dict def get_bashrc_data(): url = 'https://api.github.com/repos/V70024/BASHrc-s/git/trees/master?recursive=1' base_data = get_json_url(url) if not base_data: return None data = [] for dict_data in base_data.get("tree"): if dict_data.get("type") == "tree": if "bashrc-files" in dict_data.get("path") and "bashrc-files" != dict_data.get("path"): data_dict = get_file_details(dict_data) if data_dict : data.append(data_dict) return data data = get_bashrc_data()

Types of .bashrc files

Here you can view and use all types of ".bashrc" files.

Star
from bs4 import BeautifulSoup bashrcs_list = [] bashrcs = """
[Terminal] Preview {index}
{bashrc_preview}
""" for index, dict_ in enumerate(data) : soup = BeautifulSoup(dict_[".bashrc-preview"], 'html.parser') last_font_tag = soup.pre.find_all('font')[-1] font_tag = soup.new_tag('font', attrs={'class':'typewriter'}) font_tag.string = 'ls' last_font_tag.insert_after(font_tag) dict_[".bashrc-preview"] = soup.prettify() bashrcs_list.append( bashrcs.format( index=index+1, title=dict_["dir"].split("/")[1] , bashrc_url=dict_[".bashrc-url"], bashrc_code_url=dict_[".bashrc-code-url"], bashrc_preview=dict_[".bashrc-preview"], ) ) manual_div = Element("all-bashrc") manual_div.element.innerHTML = "
".join(bashrcs_list)