https://github.com/wenerme/dotfiles
Relax dotfiles for Linux, Cygwin & Mac OSX
https://github.com/wenerme/dotfiles
bashrc cygwin dotfiles homebrew linux mac-osx shell sshrc
Last synced: about 1 year ago
JSON representation
Relax dotfiles for Linux, Cygwin & Mac OSX
- Host: GitHub
- URL: https://github.com/wenerme/dotfiles
- Owner: wenerme
- License: mit
- Created: 2013-11-08T07:47:19.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2024-10-17T10:42:34.000Z (over 1 year ago)
- Last Synced: 2025-05-13T00:45:27.704Z (about 1 year ago)
- Topics: bashrc, cygwin, dotfiles, homebrew, linux, mac-osx, shell, sshrc
- Language: Shell
- Homepage:
- Size: 8.8 MB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dotfiles
Relax dotfiles for Linux, Cygwin & macOS
## Features
- Homebrew
- Linuxbrew
- Java
- Go
- npm
- nvm
- bash_completion
- cygwin
- msys2
## Configuration
- 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`
- 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](https://www.man7.org/linux/man-pages/man1/bash.1.html)
- [Bash Startup Files](https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html)
## Installation
```
chezmoi init --source wenerme
```
## 加载顺序/Load order
```
.bashrc -> .bash_profile -> utils.sh -> log4bash.sh ->
func,exports,prompt,alias,extra,after -> rc_my_*
```
## 扩展和自定义/Customize
可在 .bashrc.d 下添加自己的扩展配置,文件名格式为 `rc_my_*`.会在 after 后加载
## 目录说明
```
.font
包含了一些我喜欢的字体文件
.bashrc.d
所有 bashrc 的文件都在这里
.completion.d
包含了一部分补全脚本
```
# Misc
- 因为针对的是 bash 4+,所以使用 bash-completion 时要求使用[bash-completion2](https://github.com/Homebrew/homebrew-versions)
brew 默认是 bash-completion,因为 OS 默认的 Bash 是 3+的
# Reference
- [Advanced Bash-Scripting Guide](http://tldp.org/LDP/abs/html/)
- [What rc mean ?](http://unix.stackexchange.com/a/3469/47774)
# Document
This document is generated by `BASH_DOC_CAT=1 lrc`
```bash
# 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 '/^\nHERE-BASH-DOC\n' README.md -i
sed -e '/^HERE-BASH-DOC/{
s/^HERE-BASH-DOC//g
r /tmp/BASH_DOC_CAT
}' README.md -i
```
## utils.sh
Utils used for whole configs.
### Docs
```bash
# 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
### Commands
| 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
### Examples
```
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
```
## log4bash.sh
log for shell.
Based on [fredpalmer/log4bash](http://github.com/fredpalmer/log4bash).
```
log4bash - Makes logging in Bash scripting suck less
Copyright (c) Fred Palmer
Licensed under the MIT license
http://github.com/fredpalmer/log4bash
```
### Changelog
- Add log level
- use `tput colors` to test the term
### Commands
| 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 |
### Log level
Use level like this
```shell
log_level WARN # Only show WARN ERROR
log_level DEBUG # Only show DEBUG
log_level NONE # no log
log_level # display log level
```
## rc_func
- `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
## rc_after
- 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`
## rc_alias
- cd
- `..`,`...`,`....`,`.....`,`~`,`-`
- `cd-`,`cd..`,`cd...`
- ls
- `-h` by default
- `l`,`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
## rc_my_osx
定义我在 osx 下使用的一些配置
- 将 macvim (mvim) 映射为 gvim
- lockscreen 锁屏
- screensaver 屏保