Files
dotfiles/nixos/docs/02-shell-environment.md
T
Dmitry 17b0cdfbac feat: add comprehensive NixOS configuration documentation and structure
- Introduced `08-structure.md` detailing project structure, main files, and versioning.
- Created `README.md` for documentation overview and quick start guide.
- Added user-specific configurations for Alacritty, Vim, Micro, Git, Zsh, Tmux, and tools.
- Implemented system modules for desktop environment (KDE Plasma), audio (PipeWire), networking, and services (OpenSSH, GnuPG).
- Configured Nix settings with flakes support and garbage collection.
- Established user management for `ada` with necessary groups and shell settings.
- Enabled VirtualBox guest additions for improved VM experience.
2026-03-10 13:10:52 +03:00

204 lines
4.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Shell окружение и алиасы
Как настроить ZSH, добавить alias и переменные окружения.
## Где окружение?
Конфигурация ZSH находится в:
```
home/ada/zsh.nix
```
## Добавить alias
1. Открыть `home/ada/zsh.nix`
2. Найти секцию `shellAliases`
3. Добавить новый alias:
```nix
# Было:
ls = "eza --icons --group-directories-first";
la = "eza -la --icons --group-directories-first --git";
# Стало:
ls = "eza --icons --group-directories-first";
la = "eza -la --icons --group-directories-first --git";
lh = "eza -la --icons --group-directories-first --git | head -20"; # Первые 20
```
4. Собрать:
```bash
nh os switch
```
## Добавить переменную окружения
Переменные находятся в секции `sessionVariables`:
```nix
sessionVariables = {
EDITOR = "micro";
VISUAL = "code --wait";
PAGER = "less";
# Добавить новую переменную:
MY_CUSTOM_VAR = "value";
};
```
## Примеры alias
### Быстрая навигация
```nix
dl = "cd ~/Downloads";
dt = "cd ~/Desktop";
dev = "cd ~/dev";
```
### Безопасность
```nix
rm = "rm -i"; # Подтверждение удаления
cp = "cp -i"; # Подтверждение копирования
mv = "mv -i"; # Подтверждение перемещения
```
### Работа с Git
```nix
g = "git";
gs = "git status";
ga = "git add";
gp = "git push";
gl = "git log --oneline";
```
### Docker
```nix
d = "docker";
dps = "docker ps";
dpsa = "docker ps -a";
dex = "docker exec -it";
```
## Организация алиасов
В `zsh.nix` алиасы организованы по категориям:
```
Навигация (cd ...)
Файлы (ls variants)
Безопасность (rm, cp, mv)
Система (grep, df, du)
Сеть (ping, ports)
NixOS (nixos-rebuild и т.д.)
Git
Docker
Kubectl
Lazy инструменты
```
## История ZSH
История настраивается в секции `history`:
```nix
history = {
size = 50000; # Размер истории
save = 50000; # Сохранять 50000 команд
ignoreDups = true; # Не сохранять дубликаты
ignoreSpace = true; # Не сохранять команды начинающиеся с пробела
share = true; # Делиться историей между сессиями
};
```
## Интеграции
### Zoxide (быстрая навигация)
```bash
z <directory> # Перейти в папку
zi # Интерактивный выбор
```
### Direnv (окружения)
```bash
# .envrc файл в папке с переменными
cat > .envrc << EOF
export MY_VAR=value
EOF
direnv allow # Разрешить автоматическое применение
```
### FZF (интерактивный поиск)
```bash
Ctrl+R # Поиск по истории
Ctrl+T # Поиск файлов
```
## Проверка после изменения
```bash
# Просто применить и проверить
nh os switch
# Потом проверить alias
alias ls # Показать что это такое
```
## Примеры полезных alias
```nix
# Список процессов
ps = "ps aux | grep";
# Размер папок
du_sort = "du -sh * | sort -hr";
# Network
ip_local = "ip -4 addr show | grep -oP '(?<=inet\\s)\\d+(\\.\\d+){3}' | grep -v 127.0.0.1";
# Поиск по типу файла
find_py = "find . -name '*.py'";
```
## Переменные окружения
### Полезные переменные
```nix
sessionVariables = {
# Главный редактор
EDITOR = "micro";
VISUAL = "code --wait";
# Пейджер
PAGER = "less";
# Данные
XDG_CONFIG_HOME = "$HOME/.config";
XDG_DATA_HOME = "$HOME/.local/share";
XDG_CACHE_HOME = "$HOME/.cache";
# Язык
LANG = "en_US.UTF-8";
# Git
GIT_AUTHOR_NAME = "Dmitry";
GIT_AUTHOR_EMAIL = "ada.dmitry@gmail.com";
};
```
## Часто изменяемое
Самые частые изменения:
1. Добавить новый alias
2. Изменить EDITOR
3. Добавить PATH переменную
Всё это делается в `zsh.nix` в соответствующих секциях.