菜鸟的tmux环境设定小纪录 (mac & ubuntu)(using zshell)

前言

先是在我的macAir上设定了我的tmux环境后,当我要在我的桌机上的linux base系统上设定同样的设定时,虽然我已在Hackmd上有做条列式的纪录,但突然想到不如来写个文吧,上一次写文是铁人赛,因睡过头而在第11天失败的google ml课程。上一次写文的动力是完成的奖品(书包)还有队友的陪伴(一起努力的那股热血),这次,没有奖品也没有队友,而是为了当之后又荒废了一阵子或是又要重设环境时,看自己的纪录可以很快的複习,其次我在查资料时除了官方的manual或tutorial,亦深深的受惠于网路上像这样的文章,不管是非官方的笔记纪录, 教学, 报导,中文(顺代一提,不到万不得已不看简体字文章)或英文(英文佔多数),我希望回馈给这个我索取了许多却从来没有回馈的网路社群,让其他人再经历与我相同处境时能多一个参考资料。除此之外,我也希望能增进自己的写作与表达能力,我是个寡言的人,不遇知交或很好的朋友我是不会久聊,而麻烦的是我的朋友很少,于是长久处在自己一个人的状态,没有机会常把自己的想法传达给别人,我的表达能力着实刊忧,清楚这是一大劣势的我希望在发文的过程中也可以练练自己的表达能力。
这里应该是个hen新手友善的地方,就从唯一发过文的IT邦帮忙开始吧(?)

mac

brew 待补

iterm 待补

zsh(zshell) 待补

tmux 待补

linux: ubuntu

zsh(主要参考)

installation and set to default shell
# install zsh with apt sudo apt install zsh# check if zsh is well installedzsh --version# make it yout default shellchsh -s $(which zsh)
log out and log in and open terminal again, this will show. 我选2,然后安装并设为预设就完成了
This is the Z Shell configuration function for new users,zsh-newuser-install.You are seeing this message because you have no zsh startup files(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory~).  This function can help you with a few settings that shouldmake your use of the shell easier.You can:(q)  Quit and do nothing.  The function will be run again next time.(0)  Exit, creating the file ~/.zshrc containing just a comment.     That will prevent this function being run again.(1)  Continue to the main menu.(2)  Populate your ~/.zshrc with the configuration recommended     by the system administrator and exit (you will need to edit     the file by hand, if so desired).--- Type one of the keys in parentheses --- 

Oh-my-zsh

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

tmux

installation
# install tmux using apt sudo apt install tmux
一个简易的guide,这里就不多做叙述拉,上网找"tmux","tmux tutorial", "tmux guide", "tmux document", "tmux cheatsheet",亦可type "man tmux" in the terminal to see manual

tmux plugin: tpm(tmux pluggin mannager)github: tmux-plugins/tpm

installation
# clone the packagegit clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
add thest to ~/.tmux.config
# List of pluginsset -g @plugin 'tmux-plugins/tpm'set -g @plugin 'tmux-plugins/tmux-sensible'# Other examples:# set -g @plugin 'github_username/plugin_name'# set -g @plugin 'git@github.com/user/plugin'# set -g @plugin 'git@bitbucket.com/user/plugin'# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)run -b '~/.tmux/plugins/tpm/tpm'
如果正在使用tmux则打入下方指令以重制设定
# type this in terminal if tmux is already runningtmux source ~/.tmux.conf

tmux plugin: themepackjimeh/tmux-themepack

# 将以下指令放入~/.tmux.confset -g @plugin 'jimeh/tmux-themepack'

themes: powerlevel10k

installation(manual, other options see ther github page)
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10kecho 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>! ~/.zshrc
重新开启terminal进入首次设定模式,以下图片为设定操作图前三个他在确认他的icon的资料库的正确性
http://img2.58codes.com/2024/201202948N9KtdOXc9.png
http://img2.58codes.com/2024/20120294f7bdGhC14Q.png
http://img2.58codes.com/2024/20120294shlcS9ilQr.pngprompt的风格选择,我选3
http://img2.58codes.com/2024/20120294fWHz2RG7If.png解码的选择,我决的主要的差别是最左右还有分隔的地方Unicode可以显示尖角,我比较喜欢尖角,左右我也不喜欢有多那个,佔空间也没特别好看,不过那个之后的设定可以关掉所以我选1.
http://img2.58codes.com/2024/20120294X0qnJaGDV6.png显示时间再最右边,我会在tmux右下角显示时间,所以这里就不用了,而且这里的好像不会随时更新
http://img2.58codes.com/2024/20120294FyE0aYIqMc.png要不要尖角就在这里选拉
http://img2.58codes.com/2024/20120294Jm0D3rKoja.png尖头或是渐层,我选尖头
http://img2.58codes.com/2024/201202946EIC6H2ykC.png尾巴要尖尾或平尾或渐层,我选平尾
http://img2.58codes.com/2024/201202945PDRe49ZJY.png这里就可以选要不要左有那两个拉,佔空间,不要
http://img2.58codes.com/2024/20120294hYENI60INz.png紧紧靠在一起或是空一格,我省空间,不空
http://img2.58codes.com/2024/201202949CRkAEWix8.png又佔空间,我选一
http://img2.58codes.com/2024/20120294MQKjCYMQ68.png是新功能(compare to powerlevel9k),不用白不用,就用用看啰,我选1
http://img2.58codes.com/2024/20120294UX1qrZ1rzJ.png似乎也是新功能,试试看啰,我选3
http://img2.58codes.com/2024/20120294qNVrMZc4rn.png要不要自动加该加的code到~/.vimrc,我是不知道他要加什么拉所以就选
http://img2.58codes.com/2024/201202946dNNvftMm3.png刚刚有选要自动加到~/.vimrc的话,它就会加这些东西进去
> diff /tmp/.zshrc.PRYh6Isxzq ~/.zshrc0a1,7> # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.> # Initialization code that may require console input (password prompts, [y/n]> # confirmations, etc.) must go above this block; everything else may go below.> if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then>   source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"> fi> 38a46,48> > # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.> [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
想要再次开启设定的话打这个就可以了
p10k configure

icon错误的修正

My theme error, shows question mark symbol #23
linuxA comment in Themes do not work on "Bash on Ubuntu on Windows" #5444

Install Menlo for Powerline and set it as your font for the Ubuntu Sub System
Right Click Ubuntu Terminal Window
Click Properties
Click the Font Tab
Set Font to Menlo for PowerLine
Click Ok
Restart the Ubuntu App

后记

突然想到 来立一个flag好了,下次来做个shortkeys, environment settings,alias的纪录,包括vimrc, .tmux.conf
再立一个flag 繁体字的安装纪录ibus, x11, hime, blablabla
再立! 难道爆的arch linux安装纪录
再再立! 用英文写!
未来说不定可以像大大一样,把自己的这些纪录放到github host上

references

分类跟上面不太一样请见谅,这是从我的笔记複製过来的

mac

How to install gcc compiler on Mac OS X
in Apple’s developer page download "Command Line Tools for Xcode"Simple trick to pipe an output to clipboard in Mac OS X on the command line

terminal

Painless copy paste between tmux, vim, and system
itermkevin-smets/iterm2-solarized.mdAuto suggestions (for Oh My Zsh)powerlevel10ktransient prompttype command: p10k configurezshOh-my-Zshcopymac:cat filename|pbcopyorsed -n ?,?p filename|pbcopylinu: Ctrl + Shift + c&v

powerline

My theme error, shows question mark symbol #23
linuxA comment in Themes do not work on "Bash on Ubuntu on Windows" #5444

Install Menlo for Powerline and set it as your font for the Ubuntu Sub System
Right Click Ubuntu Terminal Window
Click Properties
Click the Font Tab
Set Font to Menlo for PowerLine
Click Ok
Restart the Ubuntu App

vim

vim show line numbers by default on linuxSearch and replaceVim的操作小技巧 高见龙Esc = Ctrl + [All the right moves(Fandom)c language edditing使用VIM打造IDE(针对C语言)Using Vim as C/C++ IDEycm-core/YouCompleteMeUnderstand Vim Mappings and Create Your Own Shortcuts!

tmux

Tactical tmux: The 10 Most Important Commandstmux guid documentationtmux man pageMaking tmux Pretty and Usable - A Guide to Customizing your tmux.confFreeBSD General Commands Manualrajanand02/tmux.conf on githubAwesome Tmuxtmux-plugins/tpmjimeh/tmux-themepacktmux-plugins/tmux-batteryset -goq @themepack-status-left-area-right-format "#(whoami)#=={battery_percentage}"==

附录

my ~/.tmux.conf

# ~/.tmux.conf# this is nd default prefix and set it to ctrl-aunbind C-bset -g prefix C-xbind C-x send-prefix# make delay shorterset -sg escape-time 0# set default color to 256colorset -g default-terminal "screen-256color"# start pane number from 1 similar to windows# set -g pane-base-index 1# resize panesbind -r H resize-pane -L 5bind -r J resize-pane -D 5bind -r K resize-pane -U 5bind -r L resize-pane -R 5# Use Alt-vim keys without prefix key to switch panesbind -n M-h select-pane -Lbind -n M-j select-pane -D bind -n M-k select-pane -Ubind -n M-l select-pane -R# switch between sessionsbind -r ( switch-client -pbind -r ) switch-client -n# don't rename windows automaticallyset-option -g allow-rename off#### key bindings ##### reload config filebind r source-file ~/.tmux.conf \; display ".tmux.conf reloaded!"# quickly open a new window# bind N new-window# synchronize all panes in a windowbind y setw synchronize-panes# pane movement shortcuts (same as vim)bind h select-pane -Lbind j select-pane -Dbind k select-pane -Ubind l select-pane -R# new pane shortcutsbind v split-window -vbind / split-window -h#### copy mode : vim ##### start selection with 'space' and copy using 'y'# bind -t vi-copy 'y' copy-selection# paste using 'p'# unbind p# bind p paste-bufferthe tmux configuration file# enable vi modesetw -g mode-keys vi#### status bar: powerline ####set-option -g status on# set-option -g status-interval 2# set-option -g status-justify "centre"# set-option -g status-left-length 30# set-option -g status-right-length 10# set-option -g status-left "#(~/tmux-powerline/powerline.sh left)"# set-option -g status-right "#(~/tmux-powerline/powerline.sh right)"# set -g status-right '#{battery_status_bg} Batt: #{battery_icon} #{battery_percentage} #{battery_remain} | %a %h-%d %H:%M 'set -g @batt_icon_status_charging '⚡'set -g @batt_icon_status_discharging '?'# List of plugins (prfix+I to reload)set -g @plugin 'tmux-plugins/tpm'set -g @plugin 'tmux-plugins/tmux-sensible'set -g @plugin 'jimeh/tmux-themepack'set -g @plugin 'tmux-plugins/tmux-battery'set -goq @themepack-status-right-area-right-format "%H:%M:%S #{battery_icon}#{battery_percentage}"set -g @themepack 'src/yellow'# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)run -b '~/.tmux/plugins/tpm/tpm'

my ~/.vimrc

" ~/.vimrctset numberset relativenumbersyntax on set tabstop=4set softtabstop=4set shiftwidth=4set exrcset secureset noexpandtab" Let clangd fully control code completionlet g:ycm_clangd_uses_ycmd_caching = 0" Use installed clangd, not YCM-bundled clangd which doesn't get updates.let g:ycm_clangd_binary_path = exepath("clangd")

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章