安装Ubuntu后本人的配置

说明:只是对本人的操作进行记录,方便日后重装系统

一、更换apt源

参考https://blog.youkuaiyun.com/u012206617/article/details/122321849

二、安装ssh

1、安装net-tools

sudo apt install net-tools #命令 ifconfig查看 IP地址 依赖于此包

2、安装vim

sudo apt install vim 安装文本编辑器

3、下载ssh服务器

sudo apt-get install openssh-client
sudo apt-get install openssh-server

4、启动SSH服务

sudo /etc/init.d/ssh start

三、安装tmux

1、sudo apt install tmux
2、创建tmux配置文件

$ cd
$ touch .tmux.conf
$ vim .tmux.conf

修改配置文件.tmux.conf


# 修改功能按键ctrl + b 为 ·
unbind-key C-b
set-option -g prefix `

# 修改缓存行数
set-option -g history-limit 100000

# 设置搜索
setw -g mode-keys vi

四、安装git

1. 安装和配置git

sudo apt install git
git config --global core.editor "vim"  #设置git使用vim进行编辑
git config --global user.name "zh** ch**"   #设置用户名邮箱和ssh key
git config --global user.email "348***@***.com"
 
ssh-keygen -t rsa -C "348***@***.com"

公钥位置在/home/stone/.ssh/id_rsa.pub文件中,将公钥添加到远端git仓库

2. 配置hooks

(1) 创建文件

.git/hooks/commit-msg
.git/hooks/commit-template

commit-template 是commit message的模版,内容如下

[type]: title

Description:

--------

******* <****** @****.com>

commit-msg是检查规则,主要是检查type类型:

  • feat: 新功能
  • fix: 修复bug
  • docs: 只有文档改变
  • style: 并没有影响代码的意义(空格,去掉分号,格式的修改等)
  • perf: 代码的修改提高的性能
  • test: 添加测试
  • chore: 构建过程或构建工具的改变(并没有生产环境代码的改变)
#!/bin/sh

# 忽略merge request
MERGE_MSG=`cat $1 | egrep '^Merge branch*'`

if [ "$MERGE_MSG" != "" ]; then
	exit 0
fi
COMMIT_MSG=`cat $1 | egrep "^(\[feat\]|\[fix\]|\[docs\]|\[chore\]|\[perf\]|\[test\]|\[style\])(\(\w+\))?:\s(\S|\w)+"`

if [ "$COMMIT_MSG" = "" ]; then
	echo "Commit Message Irregular,Please check type!\n"
	echo "type introduce: \n"
	echo "1. [feat]: Add new function."
	echo "2. [fix]: Fix some bugs."
	echo "3. [docs]: Add documents."
	echo "4. [chore]: Change for compile."
	echo "5. [perf]: Optimized code."
	echo "6. [test]: Test code."
	echo "7. [style]: Change code style."
	exit 1
fi

if [ ${#COMMIT_MSG} -lt 15 ]; then
	echo "Commit Message Too Short, 15 words is least. Please show me more detail!\n"
	exit 1
fi

(2)配置hooks
vim ~/.gitconfig
[user]
    name = zh** ch**
    email = 348***@***.com
[core]
    editor = vim
    hooksPath = ~/.git/hooks
[commit]
    template = ~/.git/hooks/commit-template

五、安装zsh

(1)安装

  • 安装zsh
 sudo apt install zsh 
  • 将zsh设置成默认shell(不设置的话启动zsh只有直接zsh命令即可)
 sudo chsh -s /bin/zsh
  • 安装curl
 sudo snap install curl  或者   sudo apt  install curl

#国内源安装oh-my-zsh

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

(2)配置zsh

#zsh-autosuggestions 命令行命令键入时的历史命令建议
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
#zsh-syntax-highlighting 命令行语法高亮插件
git clone https://gitee.com/Annihilater/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
#设置主题“steeef”或默认, .zshrc配置如下:

参考:https://zhuanlan.zhihu.com/p/514636147

export ZSH="/home/stone/.oh-my-zsh"
# ZSH_THEME="steeef"
ZSH_THEME="robbyrussell"
plugins=(
        git
        extract
        zsh-autosuggestions
        zsh-syntax-highlighting
)
source $ZSH/oh-my-zsh.sh
source $ZSH_CUSTOM/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source $ZSH_CUSTOM/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

(3) 显示路径

sudo vim ~/.oh-my-zsh/themes/robbyrussell.zsh-theme

修改

(4)遇到的问题

1)按tab出现两个无效字符,

参考解决方案:https://blog.youkuaiyun.com/LittleSeedling/article/details/125193572

六、安装vimplus

参考:https://blog.youkuaiyun.com/qq_41962612/article/details/122883038

git clone https://github.com/chxuan/vimplus.git ~/.vimplus
(国内) git clone https://gitee.com/zhang-taipeng/vimplus.git ~/.vimplus
cd ~/.vimplus
./install.sh

七、安装samba

参考:https://blog.youkuaiyun.com/ding283595861/article/details/125330818

sudo apt-get install samba samba-common
sudo chmod -R 777 /home/<*filename>
sudo smbpasswd -a username
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
sudo vim /etc/samba/smb.conf

修改samba配置

[stone]
    path = /home/stone
    writable=yes
    browseable=yes
    public=yes
    guest ok=yes
    available = yes
    create mask = 0664
    directory mask = 0775
    force user = stone
    force group = stone

sudo /etc/init.d/samba-ad-dc start
sudo /etc/init.d/samba-ad-dc restart

其它命令

1、修改时区

timedatectl status
timedatectl set-timezone Asia/Shanghai

问题

1、在运行了一段时间后发现MobaXterm终端下,在tmux中的vimPlus无法正确显示行号和“#”后的信息

方法
改动两处:

bash/zsh配置文件: 为 H O M E / . b a s h r c ( 针对 b a s h ) 、或 HOME/.bashrc (针对bash)、或 HOME/.bashrc(针对bash)、或HOME/.zshrc新增一行export TERM="xterm-256color"
由此,tmux中的vim已可正常显示颜色,但Shell端依然无法正常恢复彩色;
tmux配置文件: 为$HOME/.tmux.conf新增set -g default-terminal "screen-256color"。Shell配色亦可恢复。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值