oh-my-zsh配置指南


目前我使用的是deepin manjaro系統

ctrl 和 capsLock鍵位交換

1、在用戶目錄下

vim .xmodmap

** 2、寫入下面六行代碼 **

remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L

** 3、執行命令 **

xmodmap .xmodmap

安裝配置zsh

1、安裝zsh,oh-my-zsh

sudo pacman -S zsh

github地址安裝oh-my-zsh

wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh
然後安裝
chmod +x install.sh
./install.sh

安裝完成之後才生產~/.zshrc這個配置文件

2、使用zsh

查看當前使用的shell
echo $SHELL

切換shell,有的系統可能使用下面的命令後並不會馬上切換系統,需要重啓一下
sudo chsh -s /bin/zsh
sudo chsh -s /bin/bash
或者使用命令
chsh -s $(which zsh)
需要重啓電腦

3、配置zsh

(1)配置主題
查看主題
ls ~/.oh-my-zsh/themes

我使用的是agnoster主題,可以利用管道查看是否有此主題:
ls ~/.oh-my-zsh/themes | grep agnoster

如果有此主題,則修改配置文件:
vim ~/.zshrc

利用下面命令查看ZSH_THEME在第幾行
bat ~/.zshrc | grep "^[^#]" -n

然後修改爲
ZSH_THEME="agnoster"
保存退出即可

可以從oh-my-zsh官方主題這裏選一個自己喜歡的,或者也可以自己定製一個

(2)使用zsh自帶的git別名

我zsh裏面的git別名覺得蠻好用的,這樣就無需單獨配置git了

利用命令查看git別名
bat ~/.oh-my-zsh/plugins/git/git.plugin.zsh
可以跳一些常用的使用記住即可
  42   │ alias g='git'
  43   │ alias ga='git add'
  44   │ alias gaa='git add --all'
  45   │ alias gapa='git add --patch'
  46   │ alias gau='git add --update'
  47   │ alias gav='git add --verbose'
  48   │ alias gap='git apply'
  49   │ 
  50   │ alias gb='git branch'
  51   │ alias gba='git branch -a'
  52   │ alias gbd='git branch -d'

  54   │ alias gbD='git branch -D'
  55   │ alias gbl='git blame -b -w'
  56   │ alias gbnm='git branch --no-merged'
  57   │ alias gbr='git branch --remote'
  58   │ alias gbs='git bisect'
  59   │ alias gbsb='git bisect bad'
  60   │ alias gbsg='git bisect good'
  61   │ alias gbsr='git bisect reset'
  62   │ alias gbss='git bisect start'
  63   │ 
  64   │ alias gc='git commit -v'
  65   │ alias gc!='git commit -v --amend'
  66   │ alias gcn!='git commit -v --no-edit --amend'
  67   │ alias gca='git commit -v -a'
  68   │ alias gca!='git commit -v -a --amend'
  69   │ alias gcan!='git commit -v -a --no-edit --amend'
  70   │ alias gcans!='git commit -v -a -s --no-edit --amend'
  71   │ alias gcam='git commit -a -m'
  72   │ alias gcsm='git commit -s -m'
  73   │ alias gcb='git checkout -b'
  74   │ alias gcf='git config --list'
  75   │ alias gcl='git clone --recurse-submodules'
  76   │ alias gclean='git clean -fd'
  77   │ alias gpristine='git reset --hard && git clean -dfx'
  78   │ alias gcm='git checkout master'
  79   │ alias gcd='git checkout develop'
  80   │ alias gcmsg='git commit -m'
  81   │ alias gco='git checkout'
  82   │ alias gcount='git shortlog -sn'
  83   │ compdef _git gcount
  84   │ alias gcp='git cherry-pick'
  85   │ alias gcpa='git cherry-pick --abort'
  86   │ alias gcpc='git cherry-pick --continue'
  87   │ alias gcs='git commit -S'
  88   │ 
  89   │ alias gd='git diff'
  90   │ alias gdca='git diff --cached'
  91   │ alias gdcw='git diff --cached --word-diff'
  92   │ alias gdct='git describe --tags `git rev-list --tags --max-count=1`'
  93   │ alias gds='git diff --staged'
  94   │ alias gdt='git diff-tree --no-commit-id --name-only -r'
  95   │ alias gdw='git diff --word-diff'
  96   │ 
  97   │ gdv() { git diff -w "$@" | view - }
  98   │ compdef _git gdv=git-diff
  99   │ 
 100   │ alias gf='git fetch'
 101   │ alias gfa='git fetch --all --prune'
 102   │ alias gfo='git fetch origin'
 103   │ 
 104   │ function gfg() { git ls-files | grep $@ }
 105   │ compdef _grep gfg
 106   │ 
 107   │ alias gg='git gui citool'
 108   │ alias gga='git gui citool --amend'
(3)在 oh-my-zsh 進入 包含 git 倉庫目錄時,會變的比平時慢/卡頓
一般是由下面的第一個,如果還卡就使用第二個
git config --add oh-my-zsh.hide-dirty 1
git config --add oh-my-zsh.hide-status 1

在這裏插入圖片描述

4、使用zsh的一些優秀工具

(1)d 命令

輸入小寫字母d,可以獲取近十次路徑,分別是從0到9順序編號
然後cd -數字,例如cd -2就能切換到相應路徑了

(2)G命令

大寫字母G,可以切換到文件末尾

(3)autojump工具
vim ~/.zshrc
進入文件複製下面兩行進去
[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh
source /usr/share/autojump/autojump.zsh

然後運行
source ~/.zshrc
(4)autosuggestions工具安裝和使用

這一步會把插件需要的文件克隆到 zsh 默認的插件目錄 ~/.oh-my-zsh/custom/plugins, 如果你使用 dotfiles 來管理你的配置文件,這裏可以爲 oh-my-zsh 也創建一個軟連接

git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
進入配置文件修改文件
vim ~/.zshrc
找到 plugins=(git) 這一行,然後添加autosuggestions即可
plugins=( git zsh-autosuggestions)
然後重新加載zsh:
1、重啓終端或者
2、source ~/.zshrc
(5)r 命令,ctrl r 命令

r 命令執行上條命令
ctrl r 可以搜索之前使用過的命令

5、vim配置

set showmode
set encoding=utf-8
set autoindent
set tabstop=4
set shiftwidth=4
set expandtab
set softtabstop=4
set cursorline
set textwidth=80
set scrolloff=5
set history=1000

參考

tmux配置

touch ~/.tmux.conf 在這個文件中寫入下面配置
source ~/.tmux.conf 這個文件的時候會報錯,不用理會。直接輸入tmux進入即可

set -g prefix C-f
set -g pane-base-index 1
setw -g pane-base-index 1

bind r source-file ~/.tmux.conf \; display "Reload"
bind C-f send-prefix

bind = split-window -h
bind - split-window -v

bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

set -g default-terminal "screen-256color"

set -g status-interval 1000
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章