ZSH
Categories:
ZSH является расширенным аналогом BASH и имеет с ним обратную совместимость, добавляя ему большое количество улучшений.
Установка по умолчанию ZSH
Официальный сайт “https://www.zsh.org/" “https://www.zsh.org/"
американское зеркало “https://zsh.sourceforge.io/" “https://zsh.sourceforge.io/"
документация на zsh
“https://zsh.sourceforge.io/Doc/Release/zsh_toc.html" “https://zsh.sourceforge.io/Doc/Release/zsh_toc.html"
Проверить текущую оболочку
$ echo $SHELL
Проверить какие оболочки установлены
chsh -l
Установить по умолчанию zsh:
chsh -s /bin/zsh/
Если не установлен, то в Manjaro выполнить
sudo pacman -S zsh
zsh
если скрипт не запустился, то
autoload -Uz zsh-newuser-install
zsh-newuser-install -f
Поставим OH-MY-ZSH
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Читаем документацию https://github.com/ohmyzsh/ohmyzsh/wiki
Редактируем ~/.zshrc
1. export ZSH="$HOME/.oh-my-zsh"
— путь к настройкам oh-my-zsh
2. ZSH_THEME="strug"
— тема оформления shell-а.
//
plugins=(git
bundler
copyfile
copybuffer
copypath
cp
emacs
node
npm
qrcode
rsync
)
Продолжение настройки: подключаем плагины
19. source $ZSH/oh-my-zsh.sh
— определяю источник для доступа к репозиторию oh-my-zsh
20. EDITOR='emacs'
— назначаю редактор по умолчанию Emacs
21. [[ -s /home/edge/.autojump/etc/profile.d/autojump.sh ]] && source /home/edge/.autojump/etc/profile.d/autojump.sh
— подключаю модуль autojump
т.к. он отказался подключаться по умолчанию и его пришлось устанавливать в ручную.
autojump
Установка из репозитория https://github.com/wting/autojump
настройка обязательно написать в строке ~/.zshrc
[[ -s /home/edge/.autojump/etc/profile.d/autojump.sh ]] && source /home/edge/.autojump/etc/profile.d/autojump.sh
j foo
— быстро переходит в директорию, в которой уже переходили поcd
jc bar
— переходит в дочернюю диреторию не набираяcd
jo music
— откроет директорию в стандартном файловом менеджереjco images
— откроет дочернюю диреторию в стандартном файловом менеджере
bundler
copyfile
copyfile <filename>
copybuffer
copybuffer
или горячая клавиша C-o
copypath
copypath
cpv (модуль cp)
rcync
cpv() {
rsync -pogbr -hhh --backup-dir="/tmp/rsync-${USERNAME}" -e /dev/null --progress "$@"
}
compdef _files cpv
Получает что-то вроде:
cpv doc10 doc11
doc10/themes/hugo-theme-relearn/static/
doc10/themes/hugo-theme-relearn/static/css/
doc10/themes/hugo-theme-relearn/static/css/auto-complete.css
1,75K 100% 1,75kB/s 0:00:00 (xfr#2254, to-chk=199/3084)
doc10/themes/hugo-theme-relearn/static/css/fontawesome-all.min.css
94,26K 100% 94,54kB/s 0:00:00 (xfr#2255, to-chk=198/3084)
doc10/themes/hugo-theme-relearn/static/css/fonts.css
2,72K 100% 2,73kB/s 0:00:00 (xfr#2256, to-chk=197/3084)
emacs
emacs
emacs
— открывает редактор с файломe
— аналогичноemacs
te
— открывает клиента emacs в терминалеeeval
— выполняет командуM-x eval
не открывая Emacseframe
— откроет новый frame emacsefile
— печатает текущий путь файла в буферecd
— печатает тукущую директорию в буфер
Теперь, чтобы открыть этот файл мне нужно набрать:
j hb3
e content/docs/linux/zsh/index/md
и я продолжаю работать. Но это еще не все.
ecode64
base64
Нужно для отправки картинок по почте, вставки на сайты в код и т.д. Иногда пользуюсь, поэтому поставил.
Функция | Алиас | Описание |
---|---|---|
encode64 | e64 | Кодирует в base64 |
encodefile64 | ef64 | Кодирует файл в base64 и помещает в одноименный файл с расширением .txt |
decode64 | d64 | Декодирует из base64 |
╭─edge@edge-manjaro in ~
╰$ e64 "Игорь Ра"
0JjQs9C+0YDRjCDQoNCw
╭─edge@edge-manjaro in ~
╰$
╭─edge@edge-manjaro in ~
╰$ d64 0JjQs9C+0YDRjCDQoNCw
Игорь Ра%
╭─edge@edge-manjaro in ~
╰$
╭─edge@edge-manjaro in ~
╰$ echo "Игорь Ра" | e64
0JjQs9C+0YDRjCDQoNCwCg==
╭─edge@edge-manjaro in ~
╰$ echo "0JjQs9C+0YDRjCDQoNCwCg==" | d64
Игорь Ра
// Создам файл
╭─edge@edge-manjaro in ~
╰$ > etest.txt
Пример файла
^Z
[1] + 8113 suspended > etest.txt
// Закодирую файл
╭─edge@edge-manjaro in ~
╰$ ef64 etest.txt
etest.txt's content encoded in base64 and saved as etest.txt.txt
// Посмотрим, что получилось
╭─edge@edge-manjaro in ~
╰$ cat etest.txt.txt
0J/RgNC40LzQtdGAINGE0LDQudC70LAK
git
Легче посмотреть документацию, чем перечислять здесь: “https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git" “https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git"
Самые ключевые команды:
Алиас | Команда |
---|---|
g | git |
ga | git add |
gaa | git add –all |
gam | git am |
gb | git branch |
gco | git checkout |
gccd | git clone –recurse-submodules “$@” && cd “$(basename $_ .git)” |
gcam | git commit –all –message |
gcmsg | git commit –message |
gd | git diff |
gf | git fetch |
gfo | git fetch origin |
gl | git pull |
gp | git push |
gpf! | git push –force |
gpod | git push origin –delete |
grb | git rebase |
gr | git remote |
grset | git remote set-url |
grm | git rm |
gsh | git show |
gst | git status |
pass
Требует отдельной статьи, т.к. очень серьезная программа для хранения паролей.
qrcode
Передаем текст в сервис “https://qrcode.show/" “https://qrcode.show/"
Алиас | Комманда |
---|---|
qrcode [text] | curl -d “text” qrcode.show |
qrsvg [text] | curl -d “text” qrcode.show -H “Accept: image/svg+xml” |
qrsvg "Игорь Ра"
<?xml version="1.0" standalone="yes"?><svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="330" height="330" viewBox="0 0 330 330" shape-rendering="crispEdges"><rect x="0" y="0" width="330" height="330" fill="#fff"/><path fill="#000" d="M40 40h10v10H40V40M50 40h10v10H50V40M60 40h10v10H60V40M70 40h10v10H70V40M80 40h10v10H80V40M90 40h10v10H90V40M100 40h10v10H100V40M120 40h10v10H120V40M160 40h10v10H160V40M190 40h10v10H190V40M200 40h10v10H200V40M2
╭─edge@edge-manjaro in ~/data/sites
╰$ qrcode "Игорь Ра"
█████████████████████████████████
█████████████████████████████████
████ ▄▄▄▄▄ █ ▀▀▀▄██▄ █ ▄▄▄▄▄ ████
████ █ █ █▄█ ▄▀██▄ █ █ █ ████
████ █▄▄▄█ █▄▀▄▀██▄ █ █▄▄▄█ ████
████▄▄▄▄▄▄▄█▄█▄█▄▀▄▀ █▄▄▄▄▄▄▄████
████▄█▀ ▄ ▄ ▄▀█ ▀ ██ ▄▀█▄█ ████
████▄ ▀▀▄▄▀█▄ █ █▄▀▀▀▄▄▄█▀▀████
████ ▄█▀█▄█▄ ▄▄ ▀ █▄▄█▄██ ▀████
████ ▄ ▀█▄▄▀██▀ ▄▄██ █ ▄▀▀██▀████
████▄██▄▄▄▄▄▀▀▄▀▀▀ ▄▄▄ █▀▄ ████
████ ▄▄▄▄▄ █ ▀ ▄▀█▀ █▄█ ▄ ▀█████
████ █ █ █ ███▄▄ █ ▄▄ ▀█▄▀████
████ █▄▄▄█ ██ ▀█▄█ ▄█▀ ▀█ ▄ ████
████▄▄▄▄▄▄▄█▄▄███▄▄▄█▄▄▄▄█▄█▄████
█████████████████████████████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
rcync
Можно этой команде посвящать отдельный пост. Но в этом случае имеем четыре Алиаса:
Алиас | Команда | Описание |
---|---|---|
rsync-copy | rsync -avz –progress -h | Копирует файлы и директории |
rsync-move | rsync -avz –progress -h –remove-source-files | перемещает файлы и директории |
rsync-update | rsync -avzu –progress -h | обновляет файлы |
rsync-synchronize | rsync -avzu –delete –progress -h | синхронизирует |
hugo && rsync-synchronize ~/data/sites/hb3/public/ ftp_name@server.name:~/public_html/