shell for mac

This commit is contained in:
2026-03-26 10:57:56 +08:00
parent f4f2db7de1
commit 4a1a5abb96
4 changed files with 145 additions and 38 deletions

View File

@@ -34,8 +34,8 @@ alias ll='ls -palFh --color=auto'
alias mkdir='mkdir -pv'
alias where='whereis' # zsh builtin
alias ps='ps auxf'
alias psg='ps aux | grep -v grep | grep -i -e VSZ -e'
# alias ps='ps auxf'
# alias psg='ps aux | grep -v grep | grep -i -e VSZ -e'
alias wine='LANG=ru_RU.utf8 wine'
alias wine64='LANG=ru_RU.utf8 wine64'

View File

@@ -16,41 +16,78 @@ fi
### AAA ##########################################
isMac() { uname -s | grep -q "Darwin"; }
isLinux() { uname -s | grep -q "Linux"; }
addPath() { [ -d "$1" ] && export PATH="$1:$PATH"; }
safeSource() { [ -s "$1" ] && source "$1" 2>/dev/null || true; }
export EDITOR="nano"
# export JAVA_HOME="/usr/lib/jvm/java-21-openjdk-amd64"
export JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"
export PATH="$JAVA_HOME/bin/:$PATH"
export PATH="$PATH:/opt/nvim/bin/"
export PATH="$PATH:$HOME/.local/bin/"
export PATH="$PATH:$HOME/.local/share/JetBrains/Toolbox/scripts/"
if hash composer >/dev/null; then
composer_home=$(composer config -g home 2>/dev/null)
export PATH="$PATH:$composer_home/vendor/bin"
fi
# phpbrew
# export PHPBREW_SET_PROMPT=1
# export PHPBREW_RC_ENABLE=1
# [ -f $HOME/.phpbrew/bashrc ] && source $HOME/.phpbrew/bashrc
# golang
export PATH="$PATH:/usr/local/go/bin"
export NVM_DIR="$HOME/.nvm"
export GOPATH="$HOME/.go"
# rust cargo
[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env"
### MacBook section
if isMac; then
# brew software
if [ -d "/opt/homebrew/bin/" ]; then
# brew itself
eval "$(/opt/homebrew/bin/brew shellenv zsh)"
addPath "/opt/homebrew/bin/"
# nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && source "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# nvm (not nvim!)
safeSource "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
safeSource "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
fi
# The next line updates PATH for Yandex Cloud CLI.
[ -f "$HOME/yandex-cloud/path.bash.inc" ] && source "$HOME/yandex-cloud/path.bash.inc"
# jbtoolbox
addPath "$HOME/Library/Application Support/JetBrains/Toolbox/scripts"
# The next line enables shell command completion for yc.
[ -f "$HOME/yandex-cloud/completion.zsh.inc" ] && source "$HOME/yandex-cloud/completion.zsh.inc"
# orbstack
safeSource "$HOME/.orbstack/shell/init.zsh"
fi
### MacBook section end
# misc
[[ -f "$HOME/.profile.local" ]] && source "$HOME/.profile.local"
### Ubuntu section
if isLinux; then
# golang
export PATH="$PATH:/usr/local/go/bin"
# export GOPATH="$HOME/.go"
# java
# export JAVA_HOME="/usr/lib/jvm/java-21-openjdk-amd64"
export JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"
export PATH="$JAVA_HOME/bin/:$PATH"
# nvim (not nvm!)
[ -d "/opt/nvim/bin/" ] && export PATH="$PATH:/opt/nvim/bin/"
# rust cargo
[ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env"
# nvm (not nvim!)
safeSource "$NVM_DIR/nvm.sh" # This loads nvm
safeSource "$NVM_DIR/bash_completion" # This loads nvm bash_completion
if hash composer >/dev/null; then
composer_home=$(composer config -g home 2>/dev/null)
export PATH="$PATH:$composer_home/vendor/bin"
fi
# phpbrew
# export PHPBREW_SET_PROMPT=1
# export PHPBREW_RC_ENABLE=1
# [ -f $HOME/.phpbrew/bashrc ] && source $HOME/.phpbrew/bashrc
# The next line updates PATH for Yandex Cloud CLI.
[ -f "$HOME/yandex-cloud/path.bash.inc" ] && source "$HOME/yandex-cloud/path.bash.inc"
# The next line enables shell command completion for yc.
[ -f "$HOME/yandex-cloud/completion.zsh.inc" ] && source "$HOME/yandex-cloud/completion.zsh.inc"
# jbtoolbox
if [ -d "$HOME/.local/share/JetBrains/Toolbox/scripts/" ]; then
export PATH="$PATH:$HOME/.local/share/JetBrains/Toolbox/scripts/"
fi
fi
### Ubuntu section end
safeSource "$HOME/.profile.local"

View File

@@ -6,13 +6,13 @@ if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]
fi
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
# Path to your Oh My Zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# load a random theme each time Oh My Zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="powerlevel10k/powerlevel10k"
@@ -77,13 +77,43 @@ ZSH_THEME="powerlevel10k/powerlevel10k"
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git docker docker-compose composer zsh-autosuggestions zsh-syntax-highlighting laravel)
plugins=(git docker docker-compose composer zsh-autosuggestions zsh-syntax-highlighting)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='nvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch $(uname -m)"
# Set personal aliases, overriding those provided by Oh My Zsh libs,
# plugins, and themes. Aliases can be placed here, though Oh My Zsh
# users are encouraged to define aliases within a top-level file in
# the $ZSH_CUSTOM folder, with .zsh extension. Examples:
# - $ZSH_CUSTOM/aliases.zsh
# - $ZSH_CUSTOM/macos.zsh
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ -f ~/.p10k.zsh ]] && source ~/.p10k.zsh
### AAA
[[ -f ~/.bash_aliases ]] && source ~/.bash_aliases
# [[ -f ~/.bashrc.local ]] && source ~/.bashrc.local
[[ -f ~/.profile ]] && source ~/.profile

40
shell/README.md Normal file
View File

@@ -0,0 +1,40 @@
## Краткое описание файлов
- `.bashrc` — bash для интерактивного non-login: история, prompt, aliases, completion.
- `.zshrc` — zsh для интерактивного shell: плагины, тема, инициализация окружения.
- `.profile` — общие login-настройки: PATH, переменные, platform-specific config.
- `.bash_aliases` — набор пользовательских aliases для удобной навигации и команд.
- `.p10k.zsh` — конфигурация темы Powerlevel10k.
## Иерархия загрузки
```
ИНТЕРАКТИВНЫЙ ШЕЛЛ
├── bash
│ ├── .bashrc
│ │ ├── .bash_aliases
│ │ └── .profile
│ └── .profile
└── zsh
├── .zshrc
│ ├── .bash_aliases
│ ├── .profile
│ └── .p10k.zsh
└── .profile
```
## Загрузка по типам shell
```
LOGIN SHELL
├── bash: ~/.bash_profile → ~/.bash_login → ~/.profile
└── zsh: ~/.zprofile → ~/.zshrc
INTERACTIVE NON-LOGIN
├── bash: ~/.bashrc
└── zsh: ~/.zshrc
NON-INTERACTIVE
└── конфиги не загружаются автоматически
```