ZSH 笔记

安装

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
yum update && yum -y install zsh

sh -c "$(wget -O- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

# 配置文件
vim ~/.zshrc

plugins=(
  git
  npm
  yarn
  bower
  yarn
  yum
)

# 查看shell列表
cat /etc/shells

# 切换shell为zsh
chsh -s /bin/zsh

插件安装

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 更改 hosts
vim /etc/hosts
192.168.75.1 gitea.laijw.com

# 下载插件
cd ~/.oh-my-zsh/custom/plugins

# 外网
git clone https://github.com.cnpmjs.org/zsh-users/zsh-autosuggestions.git
git clone https://github.com.cnpmjs.org/zsh-users/zsh-syntax-highlighting.git
git clone https://github.com.cnpmjs.org/wting/autojump.git

# autojump 安装
cd autojump && python install.py
# 按照提示粘贴到 ~/.zshrc 尾部

# 启用插件
vim ~/.zshrc

plugins=(
  git
  zsh-autosuggestions
  zsh-syntax-highlighting
)

# 启用配置
source ~/.zshrc

~/.zshrc

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
plugins=(
  git
  zsh-autosuggestions
  zsh-syntax-highlighting
)

source $ZSH/oh-my-zsh.sh

[[ -s /root/.autojump/etc/profile.d/autojump.sh ]] && source /root/.autojump/etc/profile.d/autojump.sh

autoload -U compinit && compinit -u

常用快捷命令

1
2
# git 三部曲
gaa && gcmsg "2019/12/31 周二 23:57:09.30 赖经纬" && ggp

Aliases

AliasCommandDescription
ysyum searchSearch package
ypyum infoShow package info
ylyum listList packages
yglyum grouplistList package groups
yliyum list installedPrint all installed packages
ymcyum makecacheRebuild the yum package list
yusudo yum updateUpgrade packages
yisudo yum installInstall package
ygisudo yum groupinstallInstall package group
yrsudo yum removeRemove package
ygrsudo yum groupremoveRemove pagage group
yrlsudo yum remove --remove-leavesRemove package and leaves
ycsudo yum clean allClean yum cache
gaagit add –all
gcmsggit commit -m
gpgit push
ggpushgit push origin “$(git_current_branch)”
gpsupgit push –set-upstream origin $(git_current_branch)
gstgit status
glgit pull
gglgit pull origin $(current_branch)
gpristinegit reset –hard && git clean -dfx
yyarnThe Yarn command
yayarn addInstall a package in dependencies (package.json)
yadyarn add --devInstall a package in devDependencies (package.json)
yapyarn add --peerInstall a package in peerDependencies (package.json)
ybyarn buildRun the build script defined in package.json
yccyarn cache cleanClean yarn’s global cache of packages
ygayarn global addInstall packages globally on your operating system
yglsyarn global listLists global installed packages
ygrmyarn global removeRemove global installed packages from your OS
yguyarn global upgradeUpgrade packages installed globally to their latest version
yhyarn helpShow help for a yarn command
yiyarn initInteractively creates or updates a package.json file
yinyarn installInstall dependencies defined in package.json
ylsyarn listList installed packages
youtyarn outdatedCheck for outdated package dependencies
ypyarn packCreate a compressed gzip archive of package dependencies
yrmyarn removeRemove installed packages
yrunyarn runRun a defined package script
ysyarn serveStart the dev server
ystyarn startRun the start script defined in package.json
ytyarn testRun the test script defined in package.json
yucyarn global upgrade && yarn cache cleanUpgrade global packages and clean yarn’s global cache
yuiyarn upgrade-interactivePrompt for which outdated packages to upgrade
yupyarn upgradeUpgrade packages to their latest version
npmgnpm i -gInstall dependencies globally
npmSnpm i -SInstall and save to dependencies in your package.json
npmDnpm i -DInstall and save to dev-dependencies in your package.json
npmEPATH="$(npm bin)":"$PATH"Run command from node_modules folder based on current directory
npmOnpm outdatedCheck which npm modules are outdated
npmVnpm -vCheck package versions
npmLnpm listList installed packages
npmL0npm ls --depth=0List top-level installed packages
npmstnpm startRun npm start
npmtnpm testRun npm test
npmRnpm runRun npm scripts
npmPnpm publishRun npm publish
npmInpm initRun npm init
bibower installInstalls the project dependencies listed in bower.json
blbower listList local packages and possible updates
bsbower searchFinds all packages or a specific package.

Commands

CommandDescription
tabsCreate a new tab in the current directory (macOS - requires enabling access for assistive devices under System Preferences).
takeCreate a new directory and change to it, will create intermediate directories as required.
x / extractExtract an archive (supported types: tar.{bz2,gz,xz,lzma}, bz2, rar, gz, tar, tbz2, tgz, zip, Z, 7z).
zsh_statsGet a list of the top 20 commands and how many times they have been run.
uninstall_oh_my_zshUninstall Oh-my-zsh.
upgrade_oh_my_zshUpgrade Oh-my-zsh.
source ~/.zshrcUptake new changes

AliasCommand
aliaslist all aliases
..cd ..
cd ../..
….cd ../../..
…..cd ../../../..
/cd /
~cd ~
cd +nswitch to directory number n
1cd -
2cd -2
3cd -3
4cd -4
5cd -5
6cd -6
7cd -7
8cd -8
9cd -9
mdmkdir -p
rdrmdir
ddirs -v (lists last used directories)

See ~/.oh-my-zsh/lib/directories.zsh