Зміст

WezTerm

Гарний сучасний термінал, працює в усіх десктопних ОС: Linux, Windows MacOs, FreeBSD.

Встановлення WezTerm

Убунту

можна через репозиторій:

curl -fsSL https://apt.fury.io/wez/gpg.key | sudo gpg --yes --dearmor -o /usr/share/keyrings/wezterm-fury.gpg
echo 'deb [signed-by=/usr/share/keyrings/wezterm-fury.gpg] https://apt.fury.io/wez/ * *' | sudo tee /etc/apt/sources.list.d/wezterm.list
sudo chmod 644 /usr/share/keyrings/wezterm-fury.gpg
sudo apt update
sudo apt install wezterm

MacOS

brew install wezterm

Встановлення Zsh

Убунту

sudo apt install zsh zsh-doc zsh-autosuggestions zsh-syntax-highlighting

MacOS

в MacOS нічого не робити поки що

Встановлення Jetbrains Mono Nerd Font

Убунту

mkdir -p ~/.local/share/fonts
cd /tmp
wget https://github.com/ryanoasis/nerd-fonts/releases/latest/download/JetBrainsMono.zip
unzip JetBrainsMono.zip -d ~/.local/share/fonts/JetBrainsMono && rm JetBrainsMono.zip
fc-cache -fv

Перевірка:

fc-list | grep -i "JetBrainsMono"

MacOS

brew install font-jetbrains-mono-nerd-font

Встановлення Oh-my-Zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

і перемкнутися на zsh (якщо цього не сталося автоматично):

zsh

Powerlevel10k (Тема)

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git \
${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

завантажити конфіг Powerlevel 10k config та зберегти в домашньому каталозі:

mv p10k_zsh ~/.p10k.zsh

Тепер додати в кінець .zshrc:

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

А на самий початок ~/.zshrc додати:

# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

Додаткові налаштування Zsh: Аліаси

основна ідея в тому, щоб покласти файли з розширенням .zsh в каталог ~/.oh-my-zsh/custom

Усі

my-aliases.zsh
alias dir="ls -a"
alias l="ls -la"
alias cw="clear; w"
alias x="exit"
alias cls="clear"
alias bc="bc -ql"
alias tt=traceroute
alias ports="sudo netstat -luntp"
alias play_alert="afplay ~/Sync/music/effects/Train\ Fx\ 2.wav"
alias myip="wget -O - -q icanhazip.com"
alias batcat="bat"
alias va='source ./venv/bin/activate'
alias ve='python3 -m venv ./venv'
alias list_instances="aws ec2 describe-instances --no-cli-pager --color off --filter Name=tag-key,Values=Name Name=instance-state-name,Values=running --query 'Reservations[*].Instances[*].{Instance_Id:InstanceId,Type:InstanceType,Public_IP:PublicIpAddress,Private_IP:PrivateIpAddress,SSH_Key:KeyName,Name:Tags[?Key==\`Name\`]|[0].Value}' --output table"
 
# Find top 5 big files
alias findbig="find . -type f -exec ls -s {} \; | sort -n -r | head -5"
 
# To clear all the history and screen
alias hcl='history -c; clear'
 
# Make basic commands verbose
alias cp="cp -v"
alias rm="rm -v"
alias mv="mv -v"
 
# To navigate to the different directories
alias ..='cd ..'
alias ...='cd ../..'
 
# Create and change to a new directory
mcd ()
{
   if [ "$1" == "" ]; then
       echo "mcd directory-name";
   else
       if [ ! -d $1 ]; then
           mkdir $1;
           cd $1;
       else
           echo "$1 directory exists";
       fi;
   fi
}
# display currently mounted file systems nicely
showmounted() { (echo "DEVICE PATH TYPE FLAGS" && mount | awk '$2=$4="";1') | column -t; }
 
# Local aliases
alias gfo="git fetch origin && git status"
alias zimdate="LC_TIME=en_US.UTF-8 date '+Week %V%n%A, %d.%m.%Y'"
 
alias apg1="apg -a 0 -n 1 -m 8 -x 10 -M NCL -E I1l0O"
alias apg2="apg -a 0 -n 1 -m 14 -x 16 -M NCL -E I1l0O"
alias apg3="apg -a 0 -n 1 -m 14 -x 16 -M NCLS -E I1l0O"

MacOS

my-aliases.zsh
# Exit if it's not MacOS
[[ "$(uname -s)" != "Darwin" ]] && return
 
# Configuration if Brew installed
() {
    local bp=""
    [[ -x /opt/homebrew/bin/brew ]] && bp="/opt/homebrew"
    [[ -x /usr/local/bin/brew ]] && bp="/usr/local"
 
    if [[ -n "$bp" ]]; then
        export HOMEBREW_AUTO_UPDATE_SECS=86400
        export HOMEBREW_NO_ANALYTICS=1
 
        if (( $+commands[gls] )); then
            # Використовуємо локальну змінну для аліасів
            alias ls="$bp/bin/gls --color=never -F --group-directories-first"
            alias date="$bp/bin/gdate"
        else
                [[ -t 1 ]] && echo "\e[33mNotice:\e[0m Coreutils not found. Run: brew install coreutils"
        fi
    fi
}
 
alias openfinder='open -a Finder $1'
alias flushdns='sudo dscacheutil -flushcache'
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete" # This alias will find and delete all ".DS_Store" files in the current directory and all subdirectories.
alias battery="pmset -g batt | grep -Eo '[0-9]+%' | sed 's/%//'"

Убунту

my-aliases-ubuntu.zsh
alias ls='/bin/ls --color=never -F --group-directories-first'
alias pbcopy="$HOME/scripts/stub_pbcopy.sh"
alias monitor_turn_off='xset dpms force off'
alias play_sound='aplay ~/Music/effects/Train\ Fx\ 2.wav'
alias psc='ps xawf -eo pid,user,cgroup,args'
alias pss='systemd-cgls'
alias tree='tree -C --dirsfirst'
 
if [[ -f /etc/os-release ]]; then
        if grep -q "^ID=ubuntu$" /etc/os-release; then
                alias update="$HOME/scripts/update.sh"
                alias update_small="sudo apt upgrade --assume-yes"
                alias update_download_only="sudo apt update && sudo apt upgrade --download-only --assume-yes"
        elif grep -q "^ID=debian$" /etc/os-release; then
                alias update="sudo apt update && sudo apt upgrade --assume-yes"
                alias update_download_only="sudo apt update && sudo apt upgrade --download-only --assume-yes"
        fi
fi

MacOS

додамо корисні плагіни zsh-autosuggestions zsh-syntax-highlighting

brew install zsh-autosuggestions zsh-syntax-highlighting
mkdir -pv ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/{zsh-autosuggestions,zsh-syntax-highlighting}
ln -s $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh
ln -s $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh

можливо, щось аналогічне треба зробити й для Лінукс

Для всіх

відкрити ~/.zshrc

plugins=(
  git
  terraform
  direnv
  z
  zsh-autosuggestions
  zsh-syntax-highlighting
)

можна додати й інші плагіни, але обережно, це гальмує запуск терміналу

Щоб додати аліаси та інше, треба створити файл ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/my-aliases.zsh (ім'я на свій смак) і в нього додати:

Посилання

* WezTerm official site