docs: what is dotar and its naming, network/system/string commnads

This commit is contained in:
hophacker 2022-05-06 11:11:37 +08:00 committed by hophacker
parent d91cf84f24
commit fcc9a5d6fc
5 changed files with 51 additions and 29 deletions

View File

@ -1,7 +1,11 @@
# Ruilisi dotfiles
Forked from https://github.com/skwp/dotfiles
<p align="center">
<img align="center" src="logo.png" width="150px" height="150px" />
</p>
<h1 align="center">Dotar</h1>
<p align="center">Dotar is an all-in-one dev configuration for your mac/linux which includes setup for zsh, spacevim(nvim), tmux and many more</p>
# The story
Dotar got its name by the combination of `dot` and `tar` which means package(`tar`) dotfiles togeter.
# Get started
## Requirements
* `zsh`, `tmux`, `vim`, `ag` are installed and zsh is set as your login shell:
@ -16,11 +20,11 @@ python3 -m pip install --user --upgrade pynvim
## Install
```sh
bash -c "`curl -fsSL https://raw.githubusercontent.com/ruilisi/dotfiles/master/install.sh`"
bash -c "`curl -fsSL https://raw.githubusercontent.com/ruilisi/dotar/master/install.sh`"
```
Or
```sh
bash -c "`curl -fsSL https://xiemala.com/ruilisi/dotfiles/raw/branch/master/install.sh`"
bash -c "`curl -fsSL https://xiemala.com/ruilisi/dotar/raw/branch/master/install.sh`"
```
## Upgrade
@ -67,6 +71,26 @@ ae | Edit alias
ar | Reload alias
ESC C-x C-e |Edit current command line in vim
#### Network tools
Command | Description
:-----------|:--------
test-port PORT | test whether PORT is opened
intercept-request-hosts | intercept requests and show hosts
host-ip | show host ip of your system
#### System commands
Command | Description
:-----------|:--------
yell | print the script name and all arguments to stderr
die | does the same as yell, but exits with a non-0 exit status, which means "fail".
try | uses the || (boolean OR), which only evaluates the right side if the left one didnt fail.
list-large-files DIR | list large files sort by reversed order of size and print size in the order of `KB`, `MB`, `GB`
#### String commands
Command | Description
:------------|:--------
random-hex | print random hex
random-string| print random string of alphabets `a-zA-Z0-9`
#### Git Commands
YADR will take over your ~/.gitconfig, so if you want to store your git username and other settings, please put them in ~/.gitconfig.user

View File

@ -309,9 +309,6 @@ function dc {
fi
docker-compose -f $docker_file_path $@
}
function get_ip_of_ssh_hostname {
ssh -G $1 | awk '/^hostname / { print $2 }'
}
unalias gc 2>/dev/null
unalias gcm 2>/dev/null
function gc {
@ -334,21 +331,3 @@ function gc {
function gcm {
(gc --message $*) || return
}
function random_hex {
openssl rand -hex $(expr $1 / 2)
}
function random-string {
cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1
}
function list-large-files {
LIST=`du $1`
echo $LIST | grep '^[0-9.]*K.' | sort -n
echo $LIST | grep '^[0-9.]*M.' | sort -n
echo $LIST | grep '^[0-9.]*G.' | sort -n
}
yell() { echo "$0: $*" >&2; }
die() { yell "$*"; exit 111; }
try() { "$@" || die "cannot $*"; }

View File

@ -1,7 +1,7 @@
alias intercept_request_hosts="sudo tcpdump -i any -A -vv -s 0 | grep -e 'Host:'"
host_ip() {
alias intercept-request-hosts="sudo tcpdump -i any -A -vv -s 0 | grep -e 'Host:'"
host-ip() {
ip route get 8.8.8.8 | awk '/8.8.8.8/ {print $7}'
}
test_port() {
test-port() {
nc -z localhost $1
}

7
zsh/string.zsh Normal file
View File

@ -0,0 +1,7 @@
random-hex() {
openssl rand -hex $(expr $1 / 2)
}
random-string() {
cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1
}

12
zsh/system.zsh Normal file
View File

@ -0,0 +1,12 @@
yell() { echo "$0: $*" >&2; }
die() { yell "$*"; exit 111; }
try() { "$@" || die "cannot $*"; }
list-large-files() {
LIST=`du $1`
echo $LIST | grep '^[0-9.]*K.' | sort -n
echo $LIST | grep '^[0-9.]*M.' | sort -n
echo $LIST | grep '^[0-9.]*G.' | sort -n
}