Relax dotfiles for Linux, Cygwin & macOS
- Homebrew
- Linuxbrew
- Java
- Go
- npm
- nvm
- bash_completion
- cygwin
- msys2
- profile - for login shell
- setup PATH
- rc - for interactive shell
- setup Terminal, autocomplete, prompt
item | sh | BASH | ZSH |
---|---|---|---|
profile | .profile | .bash_profile | .zprofile |
rc | .bashrc | .zshrc | |
login | .bash_login | .zlogin | |
logout | .bash_logout | .zlogout |
- PATH
- $HOME/.local/bin - by XDG 3.0
- $HOME/bin - persinal bin
- bash
--login
,-l
- Login-i
- Interactive-r
- Restricted--noprofile
- /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile
--norc
- ~/.bashrc
--rcfile ~/.bashrc
--init-file FILE
- non-interactively
- load
$BASH_ENV
- e.g.
if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
- e.g.
- load
- symlink to sh
- minimic sh
.profile
- SHELLOPTS, BASHOPTS, CDPATH, GLOBIGNORE
- zsh
- ZDOTDIR=$HOME
- TMPPREFIX=/tmp/zsh
- TCSH
- .login, tcshrc, .logout
- PDKSH
- .profile, .kshrc
- bash.1
- Bash Startup Files
chezmoi init --source wenerme
.bashrc -> .bash_profile -> utils.sh -> log4bash.sh ->
func,exports,prompt,alias,extra,after -> rc_my_*
可在 .bashrc.d 下添加自己的扩展配置,文件名格式为 rc_my_*
.会在 after 后加载
.font
包含了一些我喜欢的字体文件
.bashrc.d
所有 bashrc 的文件都在这里
.completion.d
包含了一部分补全脚本
- 因为针对的是 bash 4+,所以使用 bash-completion 时要求使用bash-completion2 brew 默认是 bash-completion,因为 OS 默认的 Bash 是 3+的
This document is generated by BASH_DOC_CAT=1 lrc
# This will show you how to update bellow docs
# You can see a document example here
# https://github.com/wenerme/dotfiles/blob/master/.bashrc.d/utils.sh#L104
BASH_DOC_GEN=en lrc > /tmp/BASH_DOC_CAT
sed -e '/^<!--\s*BEGIN-BASH-DOC/,/END-BASH-DOC/c\<!-- BEGIN-BASH-DOC -->\nHERE-BASH-DOC\n<!-- END-BASH-DOC -->' README.md -i
sed -e '/^HERE-BASH-DOC/{
s/^HERE-BASH-DOC//g
r /tmp/BASH_DOC_CAT
}' README.md -i
Utils used for whole configs.
# Generate doc for en
BASH_DOC_GEN=en lrc > doc_en.md
# You can write doc in scripts like this, if no locale, this doc will used for all locale
bashdoc en <<'DOC-HERE'
# Header
Content
DOC-HERE
Command | Arguments | Description | e.g. |
---|---|---|---|
bashdoc | Used to accept docs | bashdoc <<<'#Title Here' |
|
osis | -n | OS check | osis cygwin , osis -n linux |
termis | -n | $TERM typ check |
termis xterm |
iscmd | -n | Command chech | iscmd git ,iscmd -n brew |
iscontains | -n | Check element in array | |
isbrewed | Check formula is installed | isbrewed go |
|
try_prepend_path | Ensure prepend givend path to $PATH |
try_prepend_path ~/bin |
|
try_prepend_manpath | Ensure prepend givend path to $MANPATH |
try_prepend_path ~/man |
|
try_source | 尝试 source 文件 | try_source ~/my-bash |
-n
for negative
iscmd cls || alias cls="echo -en '\ec'"
iscmd -n clear && alias clear="cls"
osis Cygwin && {
# Cygwin stuff
}
osis Linux && {
# Linux stuff
}
osis Darwin && {
# Mac OS X stuff
}
bashdoc <<'DOC-HERE'
# Markdown title
What dose `this` mean.
DOC-HERE
# Generate docs
BASH_DOC_CAT=1 lrc
log for shell.
Based on fredpalmer/log4bash.
log4bash - Makes logging in Bash scripting suck less
Copyright (c) Fred Palmer
Licensed under the MIT license
http://github.com/fredpalmer/log4bash
- Add log level
- use
tput colors
to test the term
Command | Arguments | Description |
---|---|---|
log | message level color | Basic log command |
log_speak | msg | speak out |
log_debug | msg | DEBUG level |
log_info | msg | INFO level |
log_warn | msg | WARN level |
log_error | msg | ERROR level |
log_success | msg | SUCCESS level |
log_captains | msg | |
log_campfire | msg | |
log_level | [level] | set/get log level |
Use level like this
log_level WARN # Only show WARN ERROR
log_level DEBUG # Only show DEBUG
log_level NONE # no log
log_level # display log level
o [dir]
- Open director
- Support cmd,cygwin,Centos(nautilus),Mint(nemo),OS X
- mkd
- mkdir && cd
- colorname
- Echo manual for color and name
- 256colors
- for 256 color
- 16colors
- for 16 color
- server [port:-8000]
- stary a simple http server
- will try python, npm server, php
- Detech Homebrew
- Add bin
- Add coreutils without
g
prefix - Add bash_completion
- Setup relate PATH or HOME
- Init command-not-found-init
- nvm
- nvm use node
- npm
- Add bin
- Setup
npm-exec
- direnv
eval "$(direnv hook bash)"
- sshrc
- After sshrc
- Add sym link for
~/.inputrc
,~/.gitconfig
-
cd
..
,...
,....
,.....
,~
,-
cd-
,cd..
,cd...
-
ls
-h
by defaultl
,la
,ll
,lsd
,lst
-
cls <-> clear
-
ifconfig <-> ipconfig
-
pushcd
- push current director
-
lrc
- reload bashrc
-
ports
- show used ports
-
utf82gbk,gbk2utf8
-
please
- use sudo to run last command
-
tolower,toupper
-
random-string
-
Darwin
- saynow
定义我在 osx 下使用的一些配置
- 将 macvim (mvim) 映射为 gvim
- lockscreen 锁屏
- screensaver 屏保