Skip to content

Instantly share code, notes, and snippets.

@kotsutsumi
Last active November 22, 2023 09:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kotsutsumi/1581fe04f1c7e8af9382c63c30c2775f to your computer and use it in GitHub Desktop.
Save kotsutsumi/1581fe04f1c7e8af9382c63c30c2775f to your computer and use it in GitHub Desktop.
#!/usr/bin/bash
# ------------------------------------------------------------------------------
# [INFO]
# If you are not registered as sudoers, you will be asked for your password.
# ------------------------------------------------------------------------------
echo "🚀 A setup scripts for Ubuntu Desktop 22.04 LTS."
# ------------------------------------------------------------------------------
# 1. Set Vim to default editor
# ------------------------------------------------------------------------------
cd ~/
sudo apt install vim -y
sudo update-alternatives --set editor /usr/bin/vim.basic
# ------------------------------------------------------------------------------
# 2. Add current user to sudoers
# ------------------------------------------------------------------------------
echo "${USER} ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/${USER}
# ------------------------------------------------------------------------------
# 3. Update & Upgrade packages
# ------------------------------------------------------------------------------
sudo apt update && sudo apt full-upgrade -y && sudo apt autoremove -y
# ------------------------------------------------------------------------------
# 4. Change directory name to english
# ------------------------------------------------------------------------------
rm -Rf ~/テンプレート
rm -Rf ~/ダウンロード
rm -Rf ~/デスクトップ
rm -Rf ~/ドキュメント
rm -Rf ~/ビデオ
rm -Rf ~/ピクチャ
rm -Rf ~/ミュージック
rm -Rf ~/公開
LANG=C xdg-user-dirs-update --force
cat <<EOF > ~/.config/user-dirs.dirs
# This file is written by xdg-user-dirs-update
# If you want to change or add directories, just edit the line you're
# interested in. All local changes will be retained on the next run.
# Format is XDG_xxx_DIR="\$HOME/yyy", where yyy is a shell-escaped
# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
# absolute path. No other format is supported.
#
XDG_DESKTOP_DIR="\$HOME/Desktop"
XDG_DOWNLOAD_DIR="\$HOME/Downloads"
XDG_TEMPLATES_DIR="\$HOME/Templates"
XDG_PUBLICSHARE_DIR="\$HOME/Public"
XDG_DOCUMENTS_DIR="\$HOME/Documents"
XDG_MUSIC_DIR="\$HOME/Music"
XDG_PICTURES_DIR="\$HOME/Pictures"
XDG_VIDEOS_DIR="\$HOME/Videos"
EOF
rm -Rf ~/.config/user-dirs.locale
# ------------------------------------------------------------------------------
# 5. Install packages
# ------------------------------------------------------------------------------
sudo add-apt-repository -y ppa:agornostal/ulauncher
sudo add-apt-repository universe -y
sudo apt update
sudo apt install -y \
build-essential \
curl \
file \
git \
gnome-shell-extension-manager \
gnome-tweaks \
libayatana-appindicator3-dev \
libgtk-3-dev \
librsvg2-dev \
libssl-dev \
libwebkit2gtk-4.0-dev \
python3 \
python3-pip \
ulauncher \
wget \
wmctrl \
xbindkeys \
ffmpeg \
totem \
slack \
flameshot \
libfuse2 \
xsel
source ~/.bashrc
sudo pip install gnome-extensions-cli
sudo apt autoremove -y
# ------------------------------------------------------------------------------
# 6. Gnome settings
# ------------------------------------------------------------------------------
# blank screen
gsettings set org.gnome.desktop.session idle-delay 0
# accent color
gsettings set org.gnome.desktop.interface gtk-theme "Yaru-blue-dark"
# prefer dark
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
# auto maximize
gsettings set org.gnome.mutter auto-maximize false
# dock icon action
gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize'
# show trash
gsettings set org.gnome.shell.extensions.ding show-trash true
# dock extend height
gsettings set org.gnome.shell.extensions.dash-to-dock extend-height true
# dock app at top
gsettings set org.gnome.shell.extensions.dash-to-dock show-apps-at-top true
# show battery percentage
gsettings set org.gnome.desktop.interface show-battery-percentage true
# show seconds at taskbar
gsettings set org.gnome.desktop.interface clock-show-seconds "true"
# show weekday at taskbar
gsettings set org.gnome.desktop.interface clock-show-weekday "true"
# set task font
gsettings set org.gnome.desktop.interface font-name 'Noto Sans CJK JP 11'
# hot corners
gsettings set org.gnome.desktop.interface enable-hot-corners true
# ------------------------------------------------------------------------------
# 7. Install gnome extensions
# ------------------------------------------------------------------------------
gnome-extensions-cli -F install desktop-cube@schneegans.github.com
gnome-extensions-cli -F install user-theme@gnome-shell-extensions.gcampax.github.com
gnome-extensions-cli -F install blur-my-shell@aunetx
gnome-extensions-cli -F install Vitals@CoreCoding.com
gnome-extensions-cli -F install search-light@icedman.github.com
# ------------------------------------------------------------------------------
# 8. papirus-icon-theme
# ------------------------------------------------------------------------------
sudo add-apt-repository -y ppa:papirus/papirus
sudo apt-get update
sudo apt-get install -y papirus-icon-theme
gsettings set org.gnome.desktop.interface icon-theme "Papirus-Dark"
# ------------------------------------------------------------------------------
# 9. keyboard settings
# ------------------------------------------------------------------------------
# ウィンドウを閉じる
gsettings set org.gnome.desktop.wm.keybindings close "['<Primary>q']"
# デフォルトブラウザ <ctrl> + <alt> + 'b'
gsettings set org.gnome.settings-daemon.plugins.media-keys www "['<Primary><Alt>b']"
# ホームディレクトリ <ctrl> + <alt> + 'h'
gsettings set org.gnome.settings-daemon.plugins.media-keys home "['<Primary><Alt>h']"
# メールクライアント <ctrl> + <alt> + 'm'
gsettings set org.gnome.settings-daemon.plugins.media-keys email "['<Primary><Alt>m']"
# 端末を起動 <ctrl> + <alt> + 't'
gsettings set org.gnome.settings-daemon.plugins.media-keys terminal "['<Primary><Alt>t']"
# 設定 <ctrl> + <alt> + 's'
gsettings set org.gnome.settings-daemon.plugins.media-keys control-center "['<Primary><Alt>s']"
# 電卓 <ctrl> + <alt> + 'c'
gsettings set org.gnome.settings-daemon.plugins.media-keys calculator "['<Primary><Alt>c']"
# ひとつのアプリケーションのウィンドウを切り替える
gsettings set org.gnome.desktop.wm.keybindings switch-group "['<Super>Tab']"
gsettings set org.gnome.desktop.wm.keybindings switch-windows-backward "['<Primary><Shift>Tab']"
# アプリケーションを切り替える
gsettings set org.gnome.desktop.wm.keybindings switch-applications "['<Primary>Tab']"
gsettings set org.gnome.desktop.wm.keybindings switch-applications-backward "['<Primary><Shift>Tab']"
# ボリュームを上げる
gsettings set org.gnome.settings-daemon.plugins.media-keys volume-up "['AudioRaiseVolume']"
# ボリュームを下げる
gsettings set org.gnome.settings-daemon.plugins.media-keys volume-down "['AudioLowerVolume']"
# ミュート切り替え
gsettings set org.gnome.settings-daemon.plugins.media-keys volume-mute "['AudioMute']"
# 左Ctrlキーと左Altキーを入れ替える
gsettings set org.gnome.desktop.input-sources xkb-options "['ctrl:swap_lalt_lctl', 'ctrl:nocaps']"
# CapsLockキーを左Ctrlキーにする
gsettings set org.gnome.desktop.input-sources xkb-options "['ctrl:nocaps', 'ctrl:swap_lalt_lctl']"
# 独自のショートカット
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3/']"
# Flameshot <Ctrl> + <Alt> + <PrintScreen> | 独自のショートカット
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ name 'Flameshot'
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ command "flameshot gui"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ binding "<Primary><Alt>Execute"
# DeepL Clip <Ctrl> + <Shift> + e | 独自のショートカット
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ name "DeepL Clip"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ command "/usr/local/bin/deepl-clip.sh"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ binding "<Primary><Shift>e"
# Ulauncher <Ctrl> + <Space> | 独自のショートカット
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/ name "Ulauncher"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/ command "ulauncher-toggle"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/ binding "<Primary>space"
# GitKraken
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3/ name "GitKraken"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3/ command "/usr/bin/gitkraken"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3/ binding "<Primary><Alt>g"
# Ulauncher settings
mkdir -p ~/.config/ulauncher
cat <<EOS >~/.config/ulauncher/settings.json
{
"blacklisted-desktop-dirs": "/usr/share/locale:/usr/share/app-install:/usr/share/kservices5:/usr/share/fk5:/usr/share/kservicetypes5:/usr/share/applications/screensavers:/usr/share/kde4:/usr/share/mimelnk",
"clear-previous-query": true,
"disable-desktop-filters": false,
"grab-mouse-pointer": false,
"hotkey-show-app": "<Primary>space",
"render-on-screen": "mouse-pointer-monitor",
"show-indicator-icon": true,
"show-recent-apps": "0",
"terminal-command": "",
"theme-name": "dark"
}
EOS
# Launch at Login | Ulauncher
mkdir -p ~/.config/autostart/
cat <<EOS >~/.config/autostart/ulauncher.desktop
[Desktop Entry]
Name=Ulauncher
Comment=Application launcher for Linux
GenericName=Launcher
Categories=GNOME;GTK;Utility;
TryExec=/usr/bin/ulauncher
Exec=env GDK_BACKEND=x11 /usr/bin/ulauncher --hide-window --hide-window --hide-window --hide-window
Icon=ulauncher
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true
EOS
cat <<EOF >${HOME}/.xbindkeysrc
"echo -n | xsel -n -i; pkill xbindkeys; xdotool click 2; xbindkeys"
b:2 + Release
EOF
xbindkeys -p
# -----------------------------------------------------------------------------
# 10. Install UDEV Gothic
# -----------------------------------------------------------------------------
wget https://github.com/yuru7/udev-gothic/releases/download/v1.3.0/UDEVGothic_v1.3.0.zip
/usr/bin/unzip UDEVGothic_v1.3.0.zip
sudo rm -Rf /usr/share/fonts/UDEVGothic_v1.3.0
sudo mv UDEVGothic_v1.3.0 /usr/share/fonts
rm UDEVGothic_v1.3.0.zip
# -----------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# 11. Setup Linuxbrew
# ------------------------------------------------------------------------------
cd ~/
yes | sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
# ------------------------------------------------------------------------------
# 11.1. Install gcc
# ------------------------------------------------------------------------------
brew install gcc
# ------------------------------------------------------------------------------
# 11.2. Install NeoVim
# ------------------------------------------------------------------------------
brew install nvim
# ------------------------------------------------------------------------------
# 11.3. Install Crystal
# ------------------------------------------------------------------------------
brew install crystal
# ------------------------------------------------------------------------------
# 11.4. Install Swift
# ------------------------------------------------------------------------------
brew install swift
# ------------------------------------------------------------------------------
# 11.5. Install Nim
# ------------------------------------------------------------------------------
brew install nim
# ------------------------------------------------------------------------------
# 11.6. Install Zig
# ------------------------------------------------------------------------------
brew install zig
# ------------------------------------------------------------------------------
# 11.7. Install Sheldon
# ------------------------------------------------------------------------------
brew install sheldon
# ------------------------------------------------------------------------------
# 11.8. Install fzf
# ------------------------------------------------------------------------------
brew install fzf
# ------------------------------------------------------------------------------
# 11.9. Install zsh-completions
# ------------------------------------------------------------------------------
brew install zsh-completions
# ------------------------------------------------------------------------------
# 12. Install Rust
# ------------------------------------------------------------------------------
curl https://sh.rustup.rs -sSf | sh -s -- -y
# ------------------------------------------------------------------------------
# 12.1 Install lsd
# ------------------------------------------------------------------------------
cargo install lsd
# ------------------------------------------------------------------------------
# 12.2 Install bat
# ------------------------------------------------------------------------------
cargo install bat
# ------------------------------------------------------------------------------
# 12.3 Install git-delta
# ------------------------------------------------------------------------------
brew install git-delta
# ------------------------------------------------------------------------------
# 13. Install Volta and node and yarn
# ------------------------------------------------------------------------------
curl https://get.volta.sh | bash
volta install node
volta install yarn
# ------------------------------------------------------------------------------
# 14. Install Bun
# ------------------------------------------------------------------------------
curl https://bun.sh/install | bash
# ------------------------------------------------------------------------------
# 15. Install Deno
# ------------------------------------------------------------------------------
curl -fsSL https://deno.land/x/install/install.sh | sh
# ------------------------------------------------------------------------------
# 16. Install Go
# ------------------------------------------------------------------------------
sudo apt install -y golang-go
# ------------------------------------------------------------------------------
# 17. Install docker, docker compose, docker desktop
# ------------------------------------------------------------------------------
if [ -f /etc/apt/sources.list.d/docker.list ]; then
echo "SKIP: Already installed docker."
else
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
sudo apt update
sudo apt-get install -y docker-ce
sudo usermod -aG docker ${USER}
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.20.0/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
docker compose version
fi
cd ~/Downloads
wget https://desktop.docker.com/linux/main/amd64/docker-desktop-4.21.1-amd64.deb
sudo apt install -y ./docker-desktop-4.21.1-amd64.deb
rm -f ./docker-desktop-4.21.1-amd64.deb
cd ~/
# -----------------------------------------------------------------------------
# 18. Install DeepL clip
# -----------------------------------------------------------------------------
sudo apt install -y xclip nkf
curl -OL https://github.com/masan4444/deepl-clip/releases/latest/download/deepl-clip.sh
chmod u+x deepl-clip.sh
sudo mv deepl-clip.sh /usr/local/bin/
# -----------------------------------------------------------------------------
# 19. Install Gitkraken
# -----------------------------------------------------------------------------
wget https://release.gitkraken.com/linux/gitkraken-amd64.deb
sudo dpkg -i gitkraken-amd64.deb
rm -f ./gitkraken-amd64.deb
# ------------------------------------------------------------------------------
# 20. Install Chrome and Chromium
# ------------------------------------------------------------------------------
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install -y ./google-chrome-stable_current_amd64.deb
sudo apt-get install -y chromium-browser
rm -f google-chrome-stable_current_amd64.deb
# ------------------------------------------------------------------------------
# 21. Install KeePassX
# ------------------------------------------------------------------------------
sudo add-apt-repository -y ppa:phoerious/keepassxc
sudo apt update
sudo apt-get install -y keepassxc
# -----------------------------------------------------------------------------
# 22. Install Wezterm
# -----------------------------------------------------------------------------
cd ~/
wget https://github.com/wez/wezterm/releases/download/20230712-072601-f4abf8fd/wezterm-20230712-072601-f4abf8fd.Ubuntu22.04.deb
sudo apt-get install -y ./wezterm-20230712-072601-f4abf8fd.Ubuntu22.04.deb
rm -f ./wezterm-20230712-072601-f4abf8fd.Ubuntu22.04.deb
# default terminal
gsettings set org.gnome.desktop.default-applications.terminal exec "/usr/bin/wezterm start"
cat <<EOF >${HOME}/.wezterm.lua
local wezterm = require 'wezterm';
return {
color_scheme = "iceberg-dark",
font = wezterm.font("UDEV Gothic"),
font_size = 22,
line_height = 1.0,
use_ime = true,
initial_cols = 250,
initial_rows = 100,
hide_tab_bar_if_only_one_tab = true,
keys = {
{key="t", mods="CTRL", action=wezterm.action{SpawnTab="CurrentPaneDomain"}},
{key="{", mods="CTRL|SHIFT", action=wezterm.action{ActivateTabRelative=-1}},
{key="}", mods="CTRL|SHIFT", action=wezterm.action{ActivateTabRelative=1}},
{key="w", mods="CTRL|SHIFT", action=wezterm.action{CloseCurrentTab={confirm=true}}},
{key = "_", mods="CTRL", action="DisableDefaultAssignment" },
{
key = "=",
mods = 'CTRL|SHIFT|ALT',
action = wezterm.action.SplitVertical {
domain = 'CurrentPaneDomain'
},
},
{
key = "|",
mods = 'CTRL|SHIFT|ALT',
action = wezterm.action.SplitHorizontal {
domain = 'CurrentPaneDomain'
},
},
{
key = 'Z',
mods = 'CTRL|SHIFT|ALT',
action = wezterm.action.TogglePaneZoomState,
},
{
key = '~',
mods = 'CTRL|SHIFT|ALT',
action = wezterm.action.TogglePaneZoomState,
},
},
hyperlink_rules = {
-- Linkify things that look like URLs
-- This is actually the default if you don't specify any hyperlink_rules
{
regex = "\\\\b\\\\w+://(?:[\\\\w.-]+)\\\\.[a-z]{2,15}\\\\S*\\\\b",
format = "/setup.sh",
},
-- linkify email addresses
{
regex = "\\\\b\\\\w+@[\\\\w-]+(\\\\.[\\\\w-]+)+\\\\b",
format = "mailto:/setup.sh",
},
-- file:// URI
{
regex = "\\\\bfile://\\\\S*\\\\b",
format = "/setup.sh",
},
-- Make task numbers clickable
--[[
{
regex = "\\\\b[tT](\\\\d+)\\\\b"
format = "https://example.com/tasks/?t="
}
]]
}
}
EOF
# ------------------------------------------------------------------------------
# 23. Figma for Linux
# ------------------------------------------------------------------------------
sudo snap install figma-linux
# ------------------------------------------------------------------------------
# 24. Skype for Linux
# ------------------------------------------------------------------------------
cd ~/Downloads
wget https://go.skype.com/skypeforlinux-64.deb
sudo apt install -y ./skypeforlinux-64.deb
rm -f ./skypeforlinux-64.deb
cd ~/
# ------------------------------------------------------------------------------
# 25. Zoom for Linux
# ------------------------------------------------------------------------------
cd ~/Downloads
wget https://zoom.us/client/5.15.3.4839/zoom_amd64.deb
sudo apt install -y ./zoom_amd64.deb
rm -f ./zoom_amd64.deb
cd ~/
# ------------------------------------------------------------------------------
# 26. KVM
# ------------------------------------------------------------------------------
sudo apt install -y qemu qemu-kvm libvirt-daemon libvirt-clients bridge-utils virt-manager libvirt-daemon-system virtinst libosinfo-bin
# ------------------------------------------------------------------------------
# 27. Install Zsh
# ------------------------------------------------------------------------------
sudo apt install zsh -y
touch ~/.zshrc
sudo chsh -s $(which zsh) $(whoami)
# ------------------------------------------------------------------------------
# 28. Set /etc/passwd for Account
# ------------------------------------------------------------------------------
sudo usermod -s /usr/bin/zsh ${USER}
# ------------------------------------------------------------------------------
# 29. Setup Zsh for next boot
# ------------------------------------------------------------------------------
mkdir -p ~/.config/autostart
cat <<EOS >~/.config/autostart/setup.desktop
[Desktop Entry]
Name=MyScript
GenericName=A descriptive name
Comment=Some description about your script
Exec=${HOME}/setup.sh
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true
EOS
cat <<EOS >~/setup.sh
# ------------------------------------------------------------------------------
# delete setup script
# ------------------------------------------------------------------------------
rm -rf ~/.config/autostart/setup.desktop
rm -rf ~/.zshrc
rm -rf ~/.oh-my-zsh
# ------------------------------------------------------------------------------
# Install Oh My Zsh
# ------------------------------------------------------------------------------
curl -Lk https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
# Change theme to "avit"
sed -i -e "s/robbyrussell/avit/g" ~/.zshrc
# Make ~/.local/bin directory
mkdir -p \${HOME}/.local/bin
# ------------------------------------------------------------------------------
# Setup for sheldon
# ------------------------------------------------------------------------------
mkdir -p ~/.config/sheldon
cat <<EOF >~/.config/sheldon/plugins.toml
shell = "zsh"
[plugins]
[plugins.zsh-autosuggestions]
github = 'zsh-users/zsh-autosuggestions'
[plugins.zsh-z]
github = 'agkozak/zsh-z'
[plugins.zsh-bd]
github = 'Tarrasch/zsh-bd'
[plugins.zsh-cdr]
github = 'willghatch/zsh-cdr'
EOF
# Add settings
cat <<EOF >>~/.zshrc
# 文字コードの指定
export LANG=ja_JP.UTF-8
# 色を使用出来るようにする
autoload -Uz colors
colors
# 日本語ファイル名を表示可能にする
setopt print_eight_bit
# cdなしでディレクトリ移動
setopt auto_cd
# ビープ音の停止
setopt no_beep
# ビープ音の停止(補完時)
setopt nolistbeep
# cd -<tab>で以前移動したディレクトリを表示
setopt auto_pushd
# ヒストリ(履歴)を保存、数を増やす
HISTFILE=~/.zsh_history
HISTSIZE=100000
SAVEHIST=100000
# 同時に起動したzshの間でヒストリを共有する
setopt share_history
# 直前と同じコマンドの場合は履歴に追加しない
setopt hist_ignore_dups
# 同じコマンドをヒストリに残さない
setopt hist_ignore_all_dups
# スペースから始まるコマンド行はヒストリに残さない
setopt hist_ignore_space
# ヒストリに保存するときに余分なスペースを削除する
setopt hist_reduce_blanks
# 履歴検索中、(連続してなくとも)重複を飛ばす
setopt hist_find_no_dups
# histroyコマンドは記録しない
setopt hist_no_store
function select-history() {
BUFFER=\\\$(history -n -r 1 | fzf --no-sort +m --query "\\\$LBUFFER" --prompt="History > ")
CURSOR=\\\$#BUFFER
}
zle -N select-history
bindkey '^r' select-history
# aliases
alias vim="nvim"
alias vi="nvim"
# lsd altanative ls
alias ls="lsd"
# zmv
autoload -Uz zmv
alias zmv='noglob zmv -W'
# Linuxbrew
export PATH=/home/linuxbrew/.linuxbrew/bin:\\\$PATH
eval "\\\$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
# .local/bin
export PATH=\\\${HOME}/.local/bin:\\\$PATH
# Volta
export VOLTA_HOME="\\\$HOME/.volta"
export PATH="\\\$VOLTA_HOME/bin:\\\$PATH"
# Bun
export PATH=\\\${HOME}/.bun/bin:\\\$PATH
# Rust
source "\\\$HOME/.cargo/env"
# LinuxBrew
eval "\\\$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
# Sheldon
eval "\\\$(sheldon source)"
EOF
# # reload
# source ~/.zshrc
# # add sheldon plugins
# sheldon add zsh-autosuggestions --github zsh-users/zsh-autosuggestions
# sheldon add zsh-z --github agkozak/zsh-z
# sheldon add zsh-bd --github Tarrasch/zsh-bd
# sheldon add zsh-cdr --github willghatch/zsh-cdr
sheldon lock --update
EOS
# shldon settings
cat <<EOF >~/.config/sheldon/plugins.toml
shell = "zsh"
[plugins]
[plugins.zsh-autosuggestions]
github = 'zsh-users/zsh-autosuggestions'
[plugins.zsh-z]
github = 'agkozak/zsh-z'
[plugins.zsh-bd]
github = 'Tarrasch/zsh-bd'
[plugins.zsh-cdr]
github = 'willghatch/zsh-cdr'
EOF
chmod +x ~/setup.sh
# ------------------------------------------------------------------------------
# 30. 保留パッケージインストール
# ------------------------------------------------------------------------------
sudo apt list --upgradeable 2>/dev/null | cut -d/ -f1 | grep -v 一覧表示... | while read line
do
sudo apt install -y $line
done
# ------------------------------------------------------------------------------
# 31. Install WebCatalog
# ------------------------------------------------------------------------------
mkdir -p ~/AppImages
cd ~/AppImages
wget https://cdn-2.webcatalog.io/webcatalog/WebCatalog-49.4.0.AppImage
chmod +x WebCatalog-49.4.0.AppImage
cd ~/
# ------------------------------------------------------------------------------
# 32. Create all update packages script
# ------------------------------------------------------------------------------
cat <<EOF > all-update
#!/bin/bash
sudo apt update
sudo apt full-upgrade -y
sudo apt autoremove -y
sudo apt list --upgradeable 2>/dev/null | cut -d/ -f1 | grep -v 一覧表示... | while read line
do
sudo apt install -y \$line
done
brew update && brew upgrade
echo ""
read -p "Do you want to reboot now? (y/N): " yn
case "\$yn" in
[yY]*) reboot;;
*) echo "abort";;
esac
EOF
chmod +x all-update
sudo mv all-update /usr/local/bin/
# ------------------------------------------------------------------------------
# 33. Install Nextcloud
# ------------------------------------------------------------------------------
mkdir -p ~/AppImages
cd ~/AppImages
wget https://github.com/nextcloud-releases/desktop/releases/download/v3.9.0/Nextcloud-3.9.0-x86_64.AppImage
chmod +x Nextcloud-3.9.0-x86_64.AppImage
cd ~/
# ------------------------------------------------------------------------------
# 34. Install Visual Studio Code
# ------------------------------------------------------------------------------
sudo apt-get install -y wget gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor >packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg
sudo apt-get install -y apt-transport-https
sudo apt-get update
sudo apt-get install -y code
sudo apt-get autoremove -y
# code --install-extension
mkdir -p ~/.config/Code/User
cat <<EOF >~/.config/Code/User/keybindings.json
// 既定値を上書きするには、このファイル内にキー バインドを挿入します
[
// Git管理
// サイドバーのgitボタンクリックの動作
{
"key": "shift+ctrl+g",
"command": "workbench.view.scm"
},
//
//
// spaceでエディターにdiffを開きつつカーソルは残したまま
// {
// "key": "ctrl+shift+space",
// "command": "list.selectAndPreserveFocus",
// "when": "sideBarFocus && activeViewlet == 'workbench.view.scm'"
// },
//
//
// uでステージング
// {
// "key": "ctrl+shift+u",
// "command": "git.stage",
// "when": "sideBarFocus && activeViewlet == 'workbench.view.scm'"
// },
//
//
// shift + c でコミットメッセージの入力へ
// {
// "key": "shift+c",
// "command": "git.commitStaged",
// "when": "sideBarFocus && activeViewlet == 'workbench.view.scm'"
// },
//
//
// shfit + p でプッシュ
// {
// "key": "shift+p",
// "command": "git.push",
// "when": "sideBarFocus && activeViewlet == 'workbench.view.scm'"
// },
//
//
// shift+u でステージングを戻す
// {
// "key": "shift+u",
// "command": "git.unstage",
// "when": "sideBarFocus && activeViewlet == 'workbench.view.scm'"
// },
//
//
// エクスプローラーへフォーカス
{
"key": "ctrl+w h",
"command": "workbench.action.focusSideBar",
"when": "editorFocus"
},
//
//
// エディタへフォーカス
{
"key": "escape",
"command": "workbench.action.focusFirstEditorGroup",
"when": "!editorFocus"
},
{
"key": "ctrl+w l",
"command": "workbench.action.focusFirstEditorGroup",
"when": "!editorFocus"
},
//
//
// エクスプローラー表示/非表示切り替え
{
"key": "ctrl+1 ctrl+1",
"command": "workbench.view.explorer",
"when": "viewContainer.workbench.view.explorer.enabled"
},
{
"key": "ctrl+1 ctrl+1",
"command": "workbench.action.toggleSidebarVisibility",
"when": "filesExplorerFocus"
},
//
//
// ドキュメントフォーマット
{
"key": "ctrl+alt+l",
"command": "editor.action.formatDocument.none",
"when": "editorTextFocus && !editorHasDocumentFormattingProvider && !editorReadonly"
},
{
"key": "ctrl+shift+i",
"command": "-editor.action.formatDocument.none",
"when": "editorTextFocus && !editorHasDocumentFormattingProvider && !editorReadonly"
},
{
"key": "ctrl+alt+l",
"command": "editor.action.formatDocument",
"when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly && !inCompositeEditor"
},
{
"key": "ctrl+shift+i",
"command": "-editor.action.formatDocument",
"when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly && !inCompositeEditor"
},
{
"key": "ctrl+w ctrl+w",
"command": "workbench.action.closeActiveEditor"
},
{
"key": "ctrl+w",
"command": "-workbench.action.closeActiveEditor"
},
//
//
// エディタ移動
{
"key": "ctrl+shift+]",
"command": "workbench.action.nextEditor"
},
{
"key": "ctrl+pagedown",
"command": "-workbench.action.nextEditor"
},
{
"key": "ctrl+shift+[",
"command": "workbench.action.previousEditor"
},
{
"key": "ctrl+pageup",
"command": "-workbench.action.previousEditor"
},
//
//
// デバッグなしで実行
{
"key": "shift+f10",
"command": "workbench.action.debug.run",
"when": "debuggersAvailable && debugState != 'initializing'"
},
{
"key": "ctrl+f5",
"command": "-workbench.action.debug.run",
"when": "debuggersAvailable && debugState != 'initializing'"
},
//
//
// デバッグ実行
{
"key": "shift+f9",
"command": "workbench.action.debug.start",
"when": "debuggersAvailable && debugState == 'inactive'"
},
{
"key": "f5",
"command": "-workbench.action.debug.start",
"when": "debuggersAvailable && debugState == 'inactive'"
},
//
//
// ターミナル表示/非表示
{
"key": "ctrl+f12",
"command": "workbench.action.terminal.toggleTerminal",
"when": "terminal.active"
},
//
//
// ブレークポイント設定/解除
{
"key": "ctrl+f7",
"command": "editor.debug.action.toggleBreakpoint",
"when": "debuggersAvailable && editorTextFocus"
},
{
"key": "f8",
"command": "-editor.debug.action.toggleBreakpoint",
"when": "debuggersAvailable && editorTextFocus"
},
//
//
// ステップアウト
{
"key": "f8",
"command": "workbench.action.debug.stepOut",
"when": "debugState != 'inactive'"
},
{
"key": "ctrl+f11",
"command": "-workbench.action.debug.stepOut",
"when": "debugState != 'inactive'"
},
//
//
// ステップイン
{
"key": "f7",
"command": "workbench.action.debug.stepInto",
"when": "debugState != 'inactive'"
},
{
"key": "f11",
"command": "-workbench.action.debug.stepInto",
"when": "debugState != 'inactive'"
},
{
"key": "tab",
"command": "editor.action.indentLines",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+]",
"command": "-editor.action.indentLines",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+tab",
"command": "editor.action.outdentLines",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+[",
"command": "-editor.action.outdentLines",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+/",
"command": "macros.commentLineAndNext"
},
{
"key": "ctrl+n",
"command": "workbench.action.files.newUntitledFile"
},
{
"key": "ctrl+n",
"command": "-workbench.action.files.newUntitledFile"
},
{
"key": "alt+n",
"command": "explorer.newFile"
},
{
"key": "ctrl+shift+n",
"command": "explorer.newFolder"
},
{
"key": "shift+alt+pageup",
"command": "workbench.action.terminal.resizePaneUp"
},
{
"key": "shift+alt+pagedown",
"command": "workbench.action.terminal.resizePaneDown"
},
{
"key": "ctrl+shift+alt+/",
"command": "editor.action.quickFix",
"when": "editorHasCodeActionsProvider && editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+.",
"command": "-editor.action.quickFix",
"when": "editorHasCodeActionsProvider && editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+shift+j",
"command": "-rust-analyzer.joinLines",
"when": "editorTextFocus && editorLangId == 'rust'"
},
{
"key": "ctrl+shift+j",
"command": "-workbench.action.search.toggleQueryDetails",
"when": "inSearchEditor || searchViewletFocus"
},
{
"key": "ctrl+shift+c",
"command": "-workbench.action.terminal.openNativeConsole",
"when": "!terminalFocus"
},
{
"key": "ctrl+shift+alt+[BracketLeft]",
"command": "workbench.action.toggleMaximizedPanel"
},
{
"key": "shift+f5",
"command": "-workbench.action.debug.stop",
"when": "inDebugMode && !focusedSessionIsAttach"
},
{
"key": "ctrl+f2",
"command": "workbench.action.debug.disconnect",
"when": "focusedSessionIsAttach && inDebugMode"
},
{
"key": "shift+f5",
"command": "-workbench.action.debug.disconnect",
"when": "focusedSessionIsAttach && inDebugMode"
},
{
"key": "ctrl+f2",
"command": "workbench.action.debug.stop"
},
{
"key": "shift+f11",
"command": "bookmarks.toggle",
"when": "editorTextFocus"
},
{
"key": "ctrl+alt+k",
"command": "-bookmarks.toggle",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+f11",
"command": "bookmarks.jumpToNext",
"when": "editorTextFocus"
},
{
"key": "ctrl+alt+l",
"command": "-bookmarks.jumpToNext",
"when": "editorTextFocus"
},
{
"key": "shift+alt+[Minus]",
"command": "macros.fakeUnderscore"
},
{
"key": "ctrl+shift+alt+p",
"command": "clipring.pasteRingItem",
"when": "editorFocus"
},
{
"key": "ctrl+shift+v",
"command": "-clipring.pasteRingItem",
"when": "editorFocus"
}
]
//
EOF
cat <<EOF >~/.config/Code/User/settings.json
{
// 単体テストツールとしてpytestを有効化
"python.testing.pytestEnabled": true,
// ファイル保存時にテスト対象コードを自動的に探索
"python.testing.autoTestDiscoverOnSaveEnabled": true,
// 単体テストツールとしてpytestを有効化
"python.testing.pytestEnabled": true,
// ファイル保存時にテスト対象を自動的に探索
"python.testing.autoTestDiscoverOnSaveEnabled": true,
// pytest実行時の引数設定を追加
// --cov: カバレッジ計測の有効化
// --cov-report xml: カバレッジ計測レポートをxml形式(coverage.xml)で出力
"python.testing.pytestArgs": [
"--cov=src",
"--cov-report",
"xml"
],
// エディタ上のカバレッジ表示設定
// ガター(ブレークポイント等が表示される場所)でのカバレッジ表示有無(default: true)
"coverage-gutters.showGutterCoverage": true,
// エディタ行でのカバレッジ表示有無(default: false)
"coverage-gutters.showLineCoverage": true,
// ルーラーでのカバレッジ表示有無(default: false)
"coverage-gutters.showRulerCoverage": true,
"macros": {
"fakeUnderscore": [
{
"command": "type",
"args": {
"text": "_"
}
}
],
"commentLineAndNext": [
"editor.action.commentLine",
"cursorDown",
],
},
"vim.easymotion": true,
// 'j' -> 'k' == ESC
"vim.insertModeKeyBindings": [
{
"before": [
"j",
"k"
],
"after": [
"<Esc>"
]
}
],
"vim.normalModeKeyBindings": [
{
"before": [
"u"
],
"commands": [
"undo"
]
},
{
"before": [
"<C-r>"
],
"commands": [
"redo"
]
}
],
"vim.handleKeys": {
"<C-a>": false,
"<C-f>": false,
"<C-n>": false,
"<C-c>": false,
"<C-x>": false,
"<C-v>": false,
"<C-b>": false,
"<C-j>": false,
"<C-k>": false
},
"git.enableSmartCommit": true,
"git.confirmSync": false,
"git.autofetch": true,
"explorer.confirmDelete": false,
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"redhat.telemetry.enabled": true,
"workbench.iconTheme": "material-icon-theme",
"terminal.external.osxExec": "wezterm",
"terminal.external.linuxExec": "wezterm",
"terminal.integrated.profiles.linux": {
// "bash": {
// "path": "bash",
// "icon": "terminal-bash"
// },
"zsh": {
"path": "zsh",
"icon": "terminal-bash"
},
"fish": {
"path": "fish"
},
"tmux": {
"path": "tmux",
"icon": "terminal-tmux"
},
"pwsh": {
"path": "pwsh",
"icon": "terminal-powershell"
}
},
"terminal.integrated.defaultProfile.linux": "zsh",
"[shellscript]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[dockerfile]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"python.condaPath": "/home/sware/micromamba/condabin/conda",
"vs-kubernetes": {
"vscode-kubernetes.helm-path.linux": "/home/sware/.local/state/vs-kubernetes/tools/helm/linux-amd64/helm",
"vscode-kubernetes.kubectl-path.linux": "/home/sware/.local/state/vs-kubernetes/tools/kubectl/kubectl",
"vscode-kubernetes.minikube-path.linux": "/home/sware/.local/state/vs-kubernetes/tools/minikube/linux-amd64/minikube"
},
"git.ignoreRebaseWarning": true,
"editor.minimap.enabled": false,
"editor.accessibilitySupport": "off",
"editor.mouseWheelZoom": true,
"explorer.confirmDragAndDrop": false,
"remote.SSH.remotePlatform": {
"dev.vlue.io": "linux"
},
"indentRainbow.errorColor": "rgba(128,32,32,0.1)",
"indentRainbow.tabmixColor": "rgba(128,32,96,0.1)",
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[dockercompose]": {
"editor.defaultFormatter": "ms-azuretools.vscode-docker"
},
"files.exclude": {
"**/__pycache__": true,
"**/*.pyc": true
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"files.autoSave": "afterDelay",
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
"files.associations": {
"*.ts": "typescript"
},
"explorer.compactFolders": false,
"security.workspace.trust.untrustedFiles": "open",
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"window.zoomLevel": 5,
"workbench.colorTheme": "Nord Deep",
"[php]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"vsicons.dontShowNewVersionMessage": true,
"gitlens.codeLens.enabled": false,
"gitlens.hovers.enabled": false,
"explorer.autoReveal": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"todo-tree.highlights.customHighlight": {
"BUG": {
"icon": "bug"
},
"HACK": {
"icon": "tools"
},
"FIXME": {
"icon": "flame"
},
"XXX": {
"icon": "$(close)"
}
},
"todo-tree.highlights.useColourScheme": true,
"todo-tree.general.tags": [
"BUG",
"HACK",
"FIXME",
"TODO",
"XXX",
"[ ]",
"[x]",
"TEMP",
"INFO",
"MEMO"
],
"php.validate.enable": false,
"php.suggest.basic": false,
"php.validate.executablePath": "/home/linuxbrew/.linuxbrew/bin/php",
"editor.fontFamily": "'UDEV Gothic', 'Droid Sans Mono', 'monospace', monospace",
"vim.useSystemClipboard": true,
"workbench.editor.enablePreview": false,
"vite.autoStart": false,
//
}
EOF
# 日本語指定で一度起動する
# code --locale=ja
# 一時停止
# sleep 10s
# 終了する
# ps aux | grep /usr/share/code/code | grep -v grep | awk '{ print "kill -9", $2 }' | sh
# ------------------------------------------------------------------------------
# Reboot
# ------------------------------------------------------------------------------
sudo reboot
# ------------------------------------------------------------------------------
# EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment