1

linhaha的个人空间

 3 years ago
source link: https://my.oschina.net/linhaha/blog/5025208
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

本人作为云计算后台开发需要经常跟一些后台服务打交道,需要SSH到各个开发机上查看一些状态,执行一些脚本命令。对开发环境的配置也是在这个过程中一点点积累起来的。

§ 0x01 bash alias

1、使用常用的alias,提高效率。

§ 0x02 定制sshrc

https://github.com/danrabinowitz/sshrc

1、定制PS1,可以显示远程主机相关的信息; 2、显示当前的主机时间等信息。

§ 0x03 sshfs挂载远程主机目录

可以方便地在本地修改,在远程主机上调试。 sshfs root@ip:/root local

§ 0x04 tmux相关技巧

  1. 将常用的窗口保存在.sh中,开机后快速恢复开发窗口;
  2. prefix+ Ctrl-x,可以同时操作多个Panel;

§ 0x05 wd工具,记录多个常用目录

$ wd list
 * All warp points:
                 dev  ->  /mnt/data/dev
             go-lean  ->  ~/code/go/src/lean

§ 0x06 terminal篇

  1. 设置窗口透明,可以避免开多窗口,看到背景窗口的信息;

  2. 安装用oh-my-zsh;

  3. 启用vi-mode;

§ 0x07 fzf高效搜索

§ 0x08 安装docker本地模拟大多数的开发环境

§ 0x09 记录和使用常用的快捷键

快捷键 作用 备注 Win+1/2/3 切换dock上显示的活动窗口

§ 0x0A 编写常用的git命令脚本

如下删除指定index的分支。对应的index可以通过git branch | nl 添加上序号。

#!/bin/bash

index=$1
progname=$(basename ${BASH_SOURCE[0]})

if [ x$index == "x" ] 
then
    echo "Usage: $progname index(get from glist)"
    exit 1
fi

function get_branch_by_index()
{
    git branch | nl | egrep "\s+$1\s+" | awk '{print $NF}'
}

function inqury() {
read -r -p "Are You Sure? [Y/n] " input

        case $input in
            [yY][eE][sS]|[yY])
                        echo "Yes"
                        ;;

            [nN][oO]|[nN])
                        echo "No"
                        exit 1         
                        ;;
            *)
                        echo "Invalid input..."
            exit 1
                        ;;
        esac
}

br=$(get_branch_by_index $index)

echo "Deleting branch $br"
inqury
git branch -D $br

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK