Compare commits

...

28 Commits

Author SHA1 Message Date
PorridgePi
ac20b773b4 zshrc: feat: add aliases and misc
- add alias for Tailscale
- add alias for starting ActivityWatch
- add alias for resetting Carbon Copy Cloner v7 trial
- add alias for connecting to hidden Wi-Fi
- add UTF-8 support for Git
- add pipx bin directory to PATH
2025-04-04 15:29:34 +08:00
PorridgePi
5d26e147b1 Merge branch 'master' of PorridgePi/dotfiles 2025-04-04 11:14:15 +08:00
PorridgePi
d94282f6ab zshenv: feat: add Rust 2024-03-01 11:32:33 +08:00
PorridgePi
b80c7cab88 homebrew: feat: Add u alias 2022-10-21 21:58:32 +08:00
PorridgePi
ae3901c6f0 bootstrap: feat: Add apt update script that checks last run time 2022-10-01 18:18:06 +01:00
PorridgePi
a507be1a51 bootstrap: feat: Add priority via filename 2022-09-29 19:10:16 +08:00
PorridgePi
d02ca42759 bootstrap: homebrew: Initial commit 2022-09-29 19:06:11 +08:00
PorridgePi
04ed5c5368 bootstrap: feat: Add example.sh 2022-09-29 18:53:46 +08:00
PorridgePi
37aeee9e40 bootstrap: zsh: feat: Add macOS support 2022-09-29 18:50:08 +08:00
PorridgePi
bd9897b343 bootstrap: gpg: feat: Add macOS support 2022-09-29 18:10:43 +08:00
PorridgePi
f69bbbf6be bootstrap: python3: feat: Add macOS support 2022-09-29 18:08:00 +08:00
PorridgePi
a21ba6a0ca zshenv: fix: Missing h from arch 2022-09-29 17:53:13 +08:00
PorridgePi
46c52068e2 bootstrap: librespeed-cli: refactor: Move aarch64 arm64 section out from Linux 2022-09-29 17:51:00 +08:00
PorridgePi
967e146480 bootstrap: librespeed-cli: feat: Add macOS support 2022-09-29 17:49:03 +08:00
PorridgePi
88176cdd3e zshrc: fix: Use ll for llt 2022-09-29 05:03:40 +01:00
PorridgePi
f68dfd8738 zshrc: feat: Add $HOME/bin/external to $PATH 2022-09-29 05:03:20 +01:00
PorridgePi
6298992676 bootstrap: librespeed-cli: Initial commit 2022-09-29 05:02:22 +01:00
PorridgePi
794f14dfcf scripts: README: feat: Add wireguard-install 2022-09-29 04:42:11 +01:00
PorridgePi
e70c613cea scripts: README: feat: Use external scripts directory 2022-09-29 04:36:32 +01:00
PorridgePi
223ee6c8c9 scripts: feat: Add directory for external scripts 2022-09-29 04:35:44 +01:00
PorridgePi
45233069f2 scripts: README: Add docker-install 2022-09-29 04:28:45 +01:00
PorridgePi
92a74dda2b zshrc: feat: Add ls tree functions 2022-09-29 03:15:16 +01:00
PorridgePi
d36d14ea98 bootstrap: lsd: fix: Set env variables before installation checks 2022-09-29 02:21:13 +01:00
PorridgePi
860092c100 zshrc zshenv: refactor: Move env section from .zshrc to .zshenv 2022-09-29 02:10:58 +01:00
PorridgePi
db52edc6fd zshrc: feat: Use lsd instead of ls 2022-09-28 21:38:39 +08:00
PorridgePi
441bf78df2 bootstrap: lsd: fix: Add L flag to curl to follow redirection 2022-09-28 20:08:15 +08:00
PorridgePi
0bfdfbffb6 bootstrap: lsd: feat: Remove temp deb file after installation 2022-09-28 20:04:51 +08:00
PorridgePi
589114b86b bootstrap: lsd: fix: Use -p flag for mkdir 2022-09-28 20:04:27 +08:00
14 changed files with 380 additions and 80 deletions

6
.brew-aliases/u Executable file
View File

@@ -0,0 +1,6 @@
#! /bin/bash
# alias: brew u
#: * `u` [args...]
#: `brew u` is an alias for `brew cu -af`
brew cu -af $*

View File

@@ -0,0 +1,72 @@
source $HOME/.zshenv
if ! command -v zsh &> /dev/null; then
echo 'Installing zsh'
if [[ "$OSNAME" == "Linux" ]]; then
# Linux
if [[ "$DISTRO_TYPE" == "debian" ]]; then
# Debian-based
sudo apt update
sudo apt install zsh -y
elif [[ "$DISTRO_TYPE" == "rpm" ]]; then
# RPM-based
echo 'ERROR: Currently unsupported'
echo 'Exiting...'
exit 1
elif [[ "$DISTRO_TYPE" == "arch" ]]; then
# Arch-based
echo 'ERROR: Currently unsupported'
echo 'Exiting...'
exit 1
else
# Unknown distro
echo 'ERROR: Unknown distro'
echo 'Exiting...'
exit 1
fi
elif [[ "$OSNAME" == "macOS" ]]; then
# macOS
brew install zsh
else
# Unknown
echo 'ERROR: Unknown OS'
echo 'Exiting...'
exit 1
fi
fi
echo 'zsh is installed'
if [[ "$OSNAME" == "Linux" ]]; then
# Linux
if [ ! $(awk -F: -v user="$USER" '$1 == user {print $NF}' /etc/passwd) = $(which zsh) ]; then
echo 'zsh is not default shell'
echo 'Setting zsh as default shell...'
sudo chsh -s $(which zsh) $(whoami)
fi
elif [[ "$OSNAME" == "macOS" ]]; then
# macOS
if [[ "$SHELL" == "/bin/zsh" ]]; then
echo 'Homebrew zsh is not default shell'
if ! brew list zsh > /dev/null ; then
# Homebrew zsh not installed
echo 'Installing zsh from Homebrew'
brew install zsh
fi
echo 'Homebrew zsh installed'
echo 'Setting Homebrew zsh as default shell...'
grep -qxF "$(brew --prefix zsh)/bin/zsh" /etc/shells || sudo bash -c "echo $(brew --prefix zsh)/bin/zsh >> /etc/shells"
sudo chsh -s "$(brew --prefix zsh)/bin/zsh" $(whoami)
fi
else
# Unknown
echo 'ERROR: Unknown OS'
echo 'Exiting...'
exit 1
fi
echo 'zsh is default shell'

View File

@@ -0,0 +1,13 @@
# macOS ONLY
source $HOME/.zshenv
if [[ "$OSNAME" == "macOS" ]]; then
# macOS
if ! command -v brew &> /dev/null; then
echo 'Installing Homebrew'
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
echo 'Homebrew is installed'
fi

View File

@@ -1,7 +1,39 @@
if ! command -v gpg &> /dev/null; then if ! command -v gpg &> /dev/null; then
echo 'Installing gpg' echo 'Installing gpg'
sudo apt update
sudo apt install gpg -y source $HOME/.zshenv
if [[ "$OSNAME" == "Linux" ]]; then
# Linux
if [[ "$DISTRO_TYPE" == "debian" ]]; then
# Debian-based
sudo apt update
sudo apt install gpg -y
elif [[ "$DISTRO_TYPE" == "rpm" ]]; then
# RPM-based
echo 'ERROR: Currently unsupported'
echo 'Exiting...'
exit 1
elif [[ "$DISTRO_TYPE" == "arch" ]]; then
# Arch-based
echo 'ERROR: Currently unsupported'
echo 'Exiting...'
exit 1
else
# Unknown distro
echo 'ERROR: Unknown distro'
echo 'Exiting...'
exit 1
fi
elif [[ "$OSNAME" == "macOS" ]]; then
# macOS
brew install gpg
else
# Unknown
echo 'ERROR: Unknown OS'
echo 'Exiting...'
exit 1
fi
fi fi
echo 'gpg is installed' echo 'gpg is installed'

View File

@@ -0,0 +1,33 @@
if ! command -v librespeed-cli &> /dev/null; then
echo 'Installing librespeed-cli'
source $HOME/.zshenv
if [[ "$ARCH" == "aarch64" ]]; then
ARCH=arm64
fi
if [[ "$OSNAME" == "Linux" ]]; then
# Linux
URL=$(curl -fsSL https://api.github.com/repos/librespeed/speedtest-cli/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep linux | grep $ARCH)
mkdir -p $HOME/.temp/librespeed
curl -fsSL -o $HOME/.temp/librespeed/librespeed.tar.gz "$URL"
tar -xzf $HOME/.temp/librespeed/librespeed.tar.gz -C $HOME/.temp/librespeed/
cp $HOME/.temp/librespeed/librespeed-cli $HOME/bin/external/
rm -r $HOME/.temp/librespeed/
elif [[ "$OSNAME" == "macOS" ]]; then
# macOS
URL=$(curl -fsSL https://api.github.com/repos/librespeed/speedtest-cli/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep darwin | grep $ARCH)
mkdir -p $HOME/.temp/librespeed
curl -fsSL -o $HOME/.temp/librespeed/librespeed.tar.gz "$URL"
tar -xzf $HOME/.temp/librespeed/librespeed.tar.gz -C $HOME/.temp/librespeed/
cp $HOME/.temp/librespeed/librespeed-cli $HOME/bin/external/
rm -r $HOME/.temp/librespeed/
else
# Unknown
echo 'ERROR: Unknown OS'
echo 'Exiting...'
exit 1
fi
fi
echo 'librespeed-cli is installed'

View File

@@ -1,6 +1,8 @@
if ! command -v lsd &> /dev/null; then if ! command -v lsd &> /dev/null; then
echo 'Installing lsd' echo 'Installing lsd'
source $HOME/.zshenv
if [[ "$OSNAME" == "Linux" ]]; then if [[ "$OSNAME" == "Linux" ]]; then
# Linux # Linux
if [[ "$DISTRO_TYPE" == "debian" ]]; then if [[ "$DISTRO_TYPE" == "debian" ]]; then
@@ -9,9 +11,10 @@ if ! command -v lsd &> /dev/null; then
ARCH=arm64 ARCH=arm64
fi fi
URL=$(curl -s https://api.github.com/repos/Peltoche/lsd/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep $ARCH | grep -v musl) URL=$(curl -s https://api.github.com/repos/Peltoche/lsd/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep $ARCH | grep -v musl)
mkdir ~/.temp mkdir -p ~/.temp
curl -o ~/.temp/lsd.deb "$URL" curl -L -o ~/.temp/lsd.deb "$URL"
sudo dpkg -i ~/.temp/lsd.deb sudo dpkg -i ~/.temp/lsd.deb
rm ~/.temp/lsd.deb
else else
# Unknown distro # Unknown distro
echo 'ERROR: Unknown distro' echo 'ERROR: Unknown distro'

View File

@@ -1,15 +1,85 @@
if ! command -v python3 &> /dev/null; then if ! command -v python3 &> /dev/null; then
echo 'Installing python3' echo 'Installing python3'
sudo apt update
sudo apt install python3 -y source $HOME/.zshenv
if [[ "$OSNAME" == "Linux" ]]; then
# Linux
if [[ "$DISTRO_TYPE" == "debian" ]]; then
# Debian-based
sudo apt update
sudo apt install python3 -y
elif [[ "$DISTRO_TYPE" == "rpm" ]]; then
# RPM-based
echo 'ERROR: Currently unsupported'
echo 'Exiting...'
exit 1
elif [[ "$DISTRO_TYPE" == "arch" ]]; then
# Arch-based
echo 'ERROR: Currently unsupported'
echo 'Exiting...'
exit 1
else
# Unknown distro
echo 'ERROR: Unknown distro'
echo 'Exiting...'
exit 1
fi
elif [[ "$OSNAME" == "macOS" ]]; then
# macOS
brew install python3
else
# Unknown
echo 'ERROR: Unknown OS'
echo 'Exiting...'
exit 1
fi
fi fi
echo 'python3 is installed' echo 'python3 is installed'
if ! command -v pip3 &> /dev/null; then if ! command -v pip3 &> /dev/null; then
echo 'Installing pip3' echo 'Installing pip3'
sudo apt update
sudo apt install python3-pip -y source $HOME/.zshenv
if [[ "$OSNAME" == "Linux" ]]; then
# Linux
if [[ "$DISTRO_TYPE" == "debian" ]]; then
# Debian-based
sudo apt update
sudo apt install python3-pip -y
elif [[ "$DISTRO_TYPE" == "rpm" ]]; then
# RPM-based
echo 'ERROR: Currently unsupported'
echo 'Exiting...'
exit 1
elif [[ "$DISTRO_TYPE" == "arch" ]]; then
# Arch-based
echo 'ERROR: Currently unsupported'
echo 'Exiting...'
exit 1
else
# Unknown distro
echo 'ERROR: Unknown distro'
echo 'Exiting...'
exit 1
fi
elif [[ "$OSNAME" == "macOS" ]]; then
# macOS
echo 'ERROR: pip3 is not installed'
echo 'pip3 should have been installed by Homebrew together with python3.'
echo
echo 'Please re-run this script or manually re-install python3 with Homebrew.'
echo 'Exiting...'
exit 1
else
# Unknown
echo 'ERROR: Unknown OS'
echo 'Exiting...'
exit 1
fi
fi fi
echo 'pip3 is installed' echo 'pip3 is installed'

View File

@@ -1,17 +0,0 @@
#!/bin/bash
if ! command -v zsh &> /dev/null; then
echo 'Installing zsh'
sudo apt update
sudo apt install zsh -y
fi
echo 'zsh is installed'
if [ ! $(awk -F: -v user="$USER" '$1 == user {print $NF}' /etc/passwd) = $(which zsh) ]; then
echo 'zsh is not default shell'
echo 'Setting zsh as default shell...'
sudo chsh -s $(which zsh) $(whoami)
fi
echo 'zsh is default shell'

View File

@@ -0,0 +1,10 @@
lastAptUpdateSeconds=$(date +%s -r /var/cache/apt/pkgcache.bin)
currentSeconds=$(date +%s)
diffSeconds=$(($currentSeconds - $lastAptUpdateSeconds))
echo "apt update was last run $diffSeconds second(s) ago"
# Run apt update if it has not been run for more than 30 minutes
if [[ "$diffSeconds" -gt 1800 ]]; then
echo 'Running apt update...'
sudo apt update
fi

View File

@@ -0,0 +1,38 @@
if ! command -v PROGRAM_NAME &> /dev/null; then
echo 'Installing PROGRAM_NAME'
source $HOME/.zshenv
if [[ "$OSNAME" == "Linux" ]]; then
# Linux
if [[ "$DISTRO_TYPE" == "debian" ]]; then
# Debian-based
elif [[ "$DISTRO_TYPE" == "rpm" ]]; then
# RPM-based
echo 'ERROR: Currently unsupported'
echo 'Exiting...'
exit 1
elif [[ "$DISTRO_TYPE" == "arch" ]]; then
# Arch-based
echo 'ERROR: Currently unsupported'
echo 'Exiting...'
exit 1
else
# Unknown distro
echo 'ERROR: Unknown distro'
echo 'Exiting...'
exit 1
fi
elif [[ "$OSNAME" == "macOS" ]]; then
# macOS
else
# Unknown
echo 'ERROR: Unknown OS'
echo 'Exiting...'
exit 1
fi
fi
echo 'PROGRAM_NAME is installed'

51
.zshenv Normal file
View File

@@ -0,0 +1,51 @@
########## Personal - Determine OS and Set Variables ##########################
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux
OSNAME=Linux
if [ -f /etc/os-release ]; then
. /etc/os-release
DISTRO=$NAME
VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
DISTRO=$(lsb_release -si)
VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
. /etc/lsb-release
DISTRO=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
DISTRO=Debian
VER=$(cat /etc/debian_version)
else
# Fall back to uname
DISTRO=$(uname -s)
VER=$(uname -r)
fi
if command -v dpkg &> /dev/null; then
# Debian-based
DISTRO_TYPE=debian
elif command -v yum &> /dev/null; then
# RPM-based
DISTRO_TYPE=rpm
elif command -v pacman &> /dev/null; then
# Arch-based
DISTRO_TYPE=arch
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
OSNAME=macOS
VER=$(sw_vers | grep ProductVersion | cut -c 17-)
else
# Fall back to uname
OSNAME=$(uname -s)
VER=$(uname -r)
fi
ARCH=$(uname -m)
export OSNAME DISTRO DISTRO_TYPE VER ARCH
# Rust
. "$HOME/.cargo/env"

76
.zshrc
View File

@@ -7,56 +7,6 @@ if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]
fi fi
########## Personal - Determine OS and Set Variables ##########################
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux
OSNAME=Linux
if [ -f /etc/os-release ]; then
. /etc/os-release
DISTRO=$NAME
VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
DISTRO=$(lsb_release -si)
VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
. /etc/lsb-release
DISTRO=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
DISTRO=Debian
VER=$(cat /etc/debian_version)
else
# Fall back to uname
DISTRO=$(uname -s)
VER=$(uname -r)
fi
if command -v dpkg &> /dev/null; then
# Debian-based
DISTRO_TYPE=debian
elif command -v yum &> /dev/null; then
# RPM-based
DISTRO_TYPE=rpm
elif command -v pacman &> /dev/null; then
# Arch-based
DISTRO_TYPE=arc
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
OSNAME=macOS
VER=$(sw_vers | grep ProductVersion | cut -c 17-)
else
# Fall back to uname
OSNAME=$(uname -s)
VER=$(uname -r)
fi
ARCH=$(uname -m)
export OSNAME DISTRO DISTRO_TYPE VER ARCH
########## Zinit ############################################################## ########## Zinit ##############################################################
### Added by Zinit's installerW ### Added by Zinit's installerW
if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then
@@ -92,9 +42,19 @@ elif [[ "$OSNAME" == "macOS" ]]; then
### Aliases ### Aliases
# Intel (Rosetta 2) Homebrew # Intel (Rosetta 2) Homebrew
alias ibrew='arch -x86_64 /usr/local/bin/brew' alias ibrew='arch -x86_64 /usr/local/bin/brew'
# Tailscale
alias tailscale=/Applications/Tailscale.app/Contents/MacOS/Tailscale
# Start ActivityWatch
alias startaw="if ! pgrep aw-watcher-window-macos; then; /Applications/ActivityWatch.app/Contents/MacOS/aw-watcher-window --verbose > /dev/null 2>&1 &; fi"
# Reset Carbon Copy Cloner v7 Trial
alias resetccc="defaults delete com.bombich.ccc TrialExpirationV7"
# Connect to pdlp@SSOE2023 hidden Wi-Fi
alias pdlp="networksetup -setairportnetwork en0 'pdlp@SSOE2023' 'mbByF6p@YA#RPgH8LY!k'"
# Homebrew # Homebrew
eval "$(/opt/homebrew/bin/brew shellenv)" eval "$(/opt/homebrew/bin/brew shellenv)"
else else
##### Unknown ##### Unknown
@@ -102,18 +62,23 @@ fi
########## Personal ########################################################### ########## Personal ###########################################################
export PATH="$HOME/bin:$PATH" export PATH="$HOME/bin:$HOME/bin/external:$PATH"
export TERM=xterm-256color export TERM=xterm-256color
eval $(thefuck --alias) eval $(thefuck --alias)
# Git UTF-8
export LESSCHARSET=utf-8
### Aliases ### Aliases
# Python # Python
alias python='python3' alias python='python3'
alias pip='pip3' alias pip='pip3'
# ls # ls
alias ls='ls --color=auto' alias ls='lsd --color auto'
alias la='ls --color=auto -A' alias la='lsd --color auto -A'
alias ll='ls --color=auto -laF' alias ll='lsd --color auto -laF'
function lst { ls --tree --depth ${1:-2} }
function lat { la --tree --depth ${1:-2} }
function llt { ll --tree --depth ${1:-2} }
# Docker Compose # Docker Compose
alias dc='docker-compose' alias dc='docker-compose'
@@ -141,12 +106,13 @@ export HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE=true
export PNPM_HOME="/Users/porridge/Library/pnpm" export PNPM_HOME="/Users/porridge/Library/pnpm"
export PATH="$PNPM_HOME:$PATH" export PATH="$PNPM_HOME:$PATH"
########## pipx ###############################################################
export PATH="$PATH:/Users/porridge/.local/bin"
########## Powerlevel10k ###################################################### ########## Powerlevel10k ######################################################
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
########## SDKMAN! ############################################################ ########## SDKMAN! ############################################################
# THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!! # THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$HOME/.sdkman" export SDKMAN_DIR="$HOME/.sdkman"

17
bin/README.md Normal file
View File

@@ -0,0 +1,17 @@
# Scripts
## External scripts
### [docker-install](https://github.com/docker/docker-install)
```sh
curl -fsSL https://get.docker.com -o $HOME/bin/external/get-docker.sh
sh get-docker.sh
```
### [wireguard-install](https://github.com/Nyr/wireguard-install)
```sh
curl -fsSL https://git.io/wireguard -o $HOME/bin/external/wireguard-install.sh
bash $HOME/bin/external/wireguard-install.sh
```

6
bin/external/.gitignore vendored Normal file
View File

@@ -0,0 +1,6 @@
# Ignore everything in this directory
*
# except for
!.gitignore
!README.md