windows平台 软件技巧
安装gitbash
- win平台弱化了程序员的命令行能力,所以要多学习linux命令
- 安装 阉割版的 gitbash 保证你能使用基本的 常用 shell
- 安装gitbash参考此文章即可
gitbash 骚操作
gitbash 如何复制文本
- 复制:bash框顶部 右键 选择 options 选择 Mouse -> 选择 Copy on select
- 粘贴:鼠标中间代表 顶栏 右键 options Mouse -> Middle mouse button 选择 Paste
快速跳转 曾经去过的目录 j命令
- step01 github 搜索 “z” 找到 https://github.com/rupa/z
- step02 打开 gitbash 切换到用户目录
cd ~
~ 代表 c/User/"你wind平台电脑的用户名"
- step03
cd ~
后新建一个目录mkdir demorepos
克隆z仓库代码 到此目录
1 | cd ~ |
vi ~/.bashrc
添加一行
. ~/demorepos/z/z.sh
保存退出
然后你去过的任何目录 都可以被记录下来
1 |
|
cd ~/Desktop
cd /c
cd /d
cd ~/
验证
输入 z 回车,出现所有你去过的目录
z
模糊跳转
z d # 跳转到 /d 目录
z Des # 跳转到 ~/Desktop
1 |
|
继续编辑 ~/.bashrc
完整内容如下
. ~/demorepos/z/z.sh
用 j 代替 z
alias j=’z’
保存退出
让bash生效两种方式
- 退出bash 重新 gtibash here
- source ~/.bashrc
1
2
3
4
## alias 技巧
### mac 的 `open .` 代表打开当前目录,但是win平台没有open命令它有个类似的叫做 `start .`
. ~/demorepos/z/z.sh
alias j=’z’
alias gi=”git init”
alias gst=”git status -sb”
alias ga=”git add”
alias gcv=”git commit -v”
alias gcm=”git commit -m”
alias gp=”git push”
alias gl=”git pull”
alias open=”start”
alias ll=”ls -la”
alias glog=”git log –graph –pretty=format:’%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset’ –abbrev-commit – | less”
1 |
|
export PATH=”$PATH:/c/soft/GnuWin32/bin”
1 |
|
export PATH=”c/Users/你的win用户名/AppData/Roaming/npm:$PATH”
1 |
|
查找文件
f() {
local file
q=$1
file=$( fzf –query=”” –select-1 –exit-0 -x)
if [ -n “$file” ] ;then
¦ vim “$file”
fi
echo “fzf: bye”
}
查找并 open 文件,如果你没有 open 请先 alias 一下 open
fo(){
local file
q=$1
#file=$(ag -l -g “”| fzf –query=”$q” –select-1 –exit-0 -x)
file=$( fzf –query=”” –select-1 –exit-0 -x)
if [ -n “$file” ] ;then
¦ open “$file”
fi
echo “fzf: bye”
}
查找并打开文件所在目录
fd() {
local file
local dir
file=$(fzf +m -q “$1”) && dir=$(dirname “$file”) && cd “$dir”
}
搜索文件内容并用vim打开对应行
fs(){
local file
q=$1
if [ -z “$q”] ;then
¦ q=”.”
fi
result=$(ag “$q” | fzf)
IFS=’:’ read file line other <<< “$result”
[ -n “$file” ] && vim “$file” +”$line”;
}`