diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..53c37a16608c014b2cf0bd2d5dfcafe953cdd857 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dist \ No newline at end of file diff --git a/.profile b/.profile new file mode 100644 index 0000000000000000000000000000000000000000..69926803f042f6720e35f44228a3345c1c7eab29 --- /dev/null +++ b/.profile @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# include .secret if it exists +# .secret file includes secret enviroment variables +if [ -f "$HOME/.secret" ]; then +. "$HOME/.secret" +fi + +# add bins to path +AVAILABLE_PATH=( + "$HOME/.bin" + # python packages + "$HOME/.local/bin" + # node packages + "$HOME/.npm-global/bin" +) + +for i in "${AVAILABLE_PATH[@]}" +do + if [ -f "$i" ]; then + PATH="$i:$PATH" + fi +done + +# import `~/.profile-bundle` +PROFILE_BUNDLE="$HOME/.profile-bundle" +if [ -f "$PROFILE_BUNDLE" ]; then +. "$PROFILE_BUNDLE" +fi + +# update home +function gtr::update-home { + bash -c "$(wget -qO- https://flint.geektr.co/home/init.sh)" +} diff --git a/.profiles/chromium-aliases.sh b/.profiles/chromium-aliases.sh new file mode 100644 index 0000000000000000000000000000000000000000..4926d140d6fe5ec8c98e61c99086b7cf9f5bfce7 --- /dev/null +++ b/.profiles/chromium-aliases.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +ex-chrome() { + chromium-browser --user-data-dir=/home/geektr/.config/ex-chrome --proxy-server=http://proxy.local.geektr.co:3128 +} diff --git a/.profiles/project-level-zshrc.sh b/.profiles/project-level-zshrc.sh new file mode 100644 index 0000000000000000000000000000000000000000..d720a089814d43b81c5594f8795771aae14e7b2b --- /dev/null +++ b/.profiles/project-level-zshrc.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +# if current directory contains ".vscode/.zshrc", ask if source it +gtr::read_char() { + stty -icanon -echo + eval "$1=\$(dd bs=1 count=1 2>/dev/null)" + stty icanon echo +} + +if [ -f "$PWD/.vscode/.zshrc" ]; then + tee <<EOT +Current Directory Contains '.vscode/.zshrc' + - press 'y' to source it + - press 'v' to view it using 'less' + - press anything else to skip this +EOT + + while gtr::read_char user_answer; do + case "$user_answer" in + y) source "$PWD/.vscode/.zshrc"; break ;; + v) less "$PWD/.vscode/.zshrc" ;; + *) break ;; + esac + done +fi diff --git a/.profiles/quick-ssh.sh b/.profiles/quick-ssh.sh new file mode 100644 index 0000000000000000000000000000000000000000..78213ccc62ba416a526febb2a9823c174f7a6bb9 --- /dev/null +++ b/.profiles/quick-ssh.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +ssh--kami() { + ssh -i "$HOME/.ssh/keys/geektr.co/kami" "kami@$1" +} + +ssh--geektr() { + ssh -i "$HOME/.ssh/keys/geektr.co/geektr" "geektr@$1" +} + +ssh--yumemi() { + ssh -i "$HOME/.ssh/keys/geektr.co/yumemi" "yumemi@$1" +} diff --git a/.zshrc b/.zshrc new file mode 100644 index 0000000000000000000000000000000000000000..1c98f814326d7b5160bd65cb647500b76649c42e --- /dev/null +++ b/.zshrc @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +export ZSH=$HOME/.oh-my-zsh +ZSH_THEME="" +DISABLE_UPDATE_PROMPT=true +DISABLE_AUTO_UPDATE=true +plugins=(git docker python tmux npm yarn) + +if [ -f "$HOME/.profile" ]; then + source "$HOME/.profile" +fi + +if [ -f "$ZSH/oh-my-zsh.sh" ]; then + source "$ZSH/oh-my-zsh.sh" +fi + +if [ -f "$HOME/.acme.sh/acme.sh.env" ]; then + . "$HOME/.acme.sh/acme.sh.env" +fi + +function upgrade-pure { + RES_PREFIX=https://raw.githubusercontent.com/sindresorhus/pure/master + DIST_PREFIX=/usr/local/share/zsh/site-functions/ + sudo wget -q -O "$DIST_PREFIX/prompt_pure_setup" "$RES_PREFIX/pure.zsh" + sudo wget -q -O "$DIST_PREFIX/async" "$RES_PREFIX/async.zsh" +} + +autoload -U promptinit; promptinit +prompt pure diff --git a/README.md b/README.md index 4f950b54f60033bc51c0480eac959ee86cc79f3f..f2240b898dae304c2cfca2db8c3631e679882ece 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ # Home -Home directory for my linux PC \ No newline at end of file +Home directory for my linux PC + +## Usage + +```bash +bash -c "$(wget -qO- https://flint.geektr.co/home/init.sh)" +``` diff --git a/build.sh b/build.sh new file mode 100755 index 0000000000000000000000000000000000000000..790a6fff7564c96522fb7a13541f08e8cf6048f3 --- /dev/null +++ b/build.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +oss_upload() { + ossutil cp -r "$1" oss://co-geektr-flint/home/"$2" --acl public-read -f +} + +# build +bundle=dist/.profile-bundle +find ".profiles" -type f -exec cat "{}" > "$bundle" \; + +# copy to home path +cp $bundle "$HOME/.profile-bundle" +cp .zshrc "$HOME/.zshrc" +cp .profile "$HOME/.profile" + +# upload +oss_upload init.sh +oss_upload .profile +oss_upload .zshrc +oss_upload $bundle diff --git a/init.sh b/init.sh new file mode 100644 index 0000000000000000000000000000000000000000..259b06d00cbcbb2df6d5d87e39a065fe16e1de87 --- /dev/null +++ b/init.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +FINT_PREFIX=https://flint.geektr.co/home + +flint_download() { + wget -q -O "$HOME/$1" "$FINT_PREFIX/$1" +} + +flint_download .profile-bundle +flint_download .profile +flint_download .zshrc