Last active
April 14, 2021 06:00
-
-
Save batako/51202dbc57a66b8034c3f4a03baf523b to your computer and use it in GitHub Desktop.
Raspberry Pi / Ubuntu / zsh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------ | |
# 定数定義 | |
# ------------------------------ | |
# Zsh | |
export ZSH_THEME="robbyrussell" | |
export RPROMPT="%m" | |
# Oh My Zsh | |
export ZSH=~/.oh-my-zsh | |
# tfenv | |
# git clone https://github.com/tfutils/tfenv.git ~/.local/tfenv | |
export PATH="$PATH:$HOME/.local/tfenv/bin" | |
export TFENV_ARCH=arm | |
# ------------------------------ | |
# 設定 | |
# ------------------------------ | |
# 補完機能有効化 | |
autoload -Uz compinit && compinit | |
# Oh My Zsh | |
plugins=( | |
git | |
terraform | |
# curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip" && unzip awscliv2.zip && sudo ./aws/install && rm -fr ./aws && rm awscliv2.zip | |
aws | |
# git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions | |
zsh-autosuggestions | |
# git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search | |
zsh-history-substring-search | |
# git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting | |
zsh-syntax-highlighting | |
# git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-completions | |
zsh-completions | |
) | |
source ~/.oh-my-zsh/oh-my-zsh.sh | |
# enhancd | |
# git clone https://github.com/b4b4r07/enhancd.git ~/.local/enhancd | |
# sudo apt install -y fzy | |
source ~/.local/enhancd/init.sh | |
# fzf 有効化 | |
# git clone https://github.com/junegunn/fzf.git ~/.local/fzf | |
# ~/.local/fzf/install | |
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh | |
# ------------------------------ | |
# エリアス | |
# ------------------------------ | |
# git | |
alias ggpulls='git submodule update --init --recursive' | |
# aws | |
alias awsts='aws sts get-caller-identity | jq' | |
# Terraform | |
alias tf='terraform' | |
alias tfi='terraform init' | |
alias tfp='terraform plan' | |
alias tfa='terraform apply' | |
alias tfd='terraform destroy' | |
alias tfc='terraform console' | |
# ------------------------------ | |
# zsh セットアップ用の関数 | |
# ------------------------------ | |
# sudo apt install -y zsh && chsh -s /bin/zsh | |
setup-zsh() { | |
sudo apt update | |
sudo apt dist-upgrade -y | |
sudo apt autoremove -y | |
sudo apt install -y \ | |
build-essential \ | |
chromium-browser \ | |
curl \ | |
fonts-firacode \ | |
git \ | |
vim \ | |
; | |
LANG=C xdg-user-dirs-gtk-update | |
# マルチディスプレイ対応 | |
sudo tee /boot/firmware/usercfg.txt << EOF > /dev/null | |
dtoverlay=vc4-fkms-v3d | |
disable_overscan=1 | |
EOF | |
# ZSH | |
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" | |
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions | |
git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search | |
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting | |
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-completions | |
# enhancd | |
git clone https://github.com/b4b4r07/enhancd.git ~/.local/enhancd | |
sudo apt install -y fzy | |
git clone https://github.com/junegunn/fzf.git ~/.local/fzf | |
~/.local/fzf/install | |
# AWS CLI | |
curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip" | |
unzip awscliv2.zip | |
sudo ./aws/install | |
rm -fr ./aws | |
rm awscliv2.zip | |
# tfenv | |
git clone https://github.com/tfutils/tfenv.git ~/.local/tfenv | |
# Joplin | |
sudo ln -s /usr/bin/python3 /usr/bin/python | |
sudo apt install -y \ | |
# TODO: sort | |
jq \ | |
libsecret-1-dev \ | |
nodejs \ | |
npm \ | |
; | |
#curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash | |
git clone https://github.com/JanKruska/joplin-arm64.git ~/.local/joplin | |
cd ~/.local/joplin | |
./build.sh | |
cat > ~/.local/share/applications/joplin.desktop << EOF | |
[Desktop Entry] | |
Name=Joplin | |
Comment=Joplin - a note taking and to-do application with synchronization capabilities for Windows, macOS, Linux, Android and iOS. | |
Exec=/home/batako/.local/joplin/dist/joplin-1.7.11/joplin/Joplin-1.7.11-arm64.AppImage | |
Icon=/home/batako/.local/joplin/distjoplin-1.7.11/joplin/128x128.png | |
Terminal=false | |
Type=Application | |
Categories=Application;Office; | |
EOF | |
# VSCode | |
# DL: https://code.visualstudio.com/download | |
# sudo apt install -y libxss1 | |
# sudo dpkg -i code_*_arm64.deb | |
} | |
# ------------------------------ | |
# AWS の関数 | |
# ------------------------------ | |
awsl() { | |
export AWS_PROFILE=${1:-"automan"} | |
} | |
# ------------------------------ | |
# fzf の関数 | |
# ------------------------------ | |
# fbr - checkout git branch (including remote branches) | |
fbr() { | |
local branches branch | |
branches=$(git branch --all | grep -v HEAD) && | |
branch=$(echo "$branches" | | |
fzf-tmux -d $(( 2 + $(wc -l <<< "$branches") )) +m) && | |
git checkout $(echo "$branch" | sed "s/.* //" | sed "s#remotes/[^/]*/##") | |
} | |
# fshow - git commit browser | |
fshow() { | |
git log --graph --color=always \ | |
--format="%C(auto)%h%d %s %C(black)%C(bold)%cr" "$@" | | |
fzf --ansi --no-sort --reverse --tiebreak=index --bind=ctrl-s:toggle-sort \ | |
--bind "ctrl-m:execute: | |
(grep -o '[a-f0-9]\{7\}' | head -1 | | |
xargs -I % sh -c 'git show --color=always % | less -R') << 'FZF-EOF' | |
{} | |
FZF-EOF" | |
} | |
# fd - cd to selected directory | |
fd() { | |
local dir | |
dir=$(find ${1:-.} -path '*/\.*' -prune \ | |
-o -type d -print 2> /dev/null | fzf +m) && | |
cd "$dir" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment