From fcc9a5d6fc989322b1531312fe6d39fd35dbca59 Mon Sep 17 00:00:00 2001 From: hophacker Date: Fri, 6 May 2022 11:11:37 +0800 Subject: [PATCH] docs: what is dotar and its naming, network/system/string commnads --- README.md | 34 +++++++++++++++++++++++++++++----- zsh/functions.zsh | 21 --------------------- zsh/network-tools.zsh | 6 +++--- zsh/string.zsh | 7 +++++++ zsh/system.zsh | 12 ++++++++++++ 5 files changed, 51 insertions(+), 29 deletions(-) create mode 100644 zsh/string.zsh create mode 100644 zsh/system.zsh diff --git a/README.md b/README.md index 3e81ebb..5ae51cc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,11 @@ -# Ruilisi dotfiles - -Forked from https://github.com/skwp/dotfiles +

+ +

+

Dotar

+

Dotar is an all-in-one dev configuration for your mac/linux which includes setup for zsh, spacevim(nvim), tmux and many more

+# 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 didn’t 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 diff --git a/zsh/functions.zsh b/zsh/functions.zsh index c128a37..53aba29 100644 --- a/zsh/functions.zsh +++ b/zsh/functions.zsh @@ -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 $*"; } diff --git a/zsh/network-tools.zsh b/zsh/network-tools.zsh index e1348cd..a684624 100644 --- a/zsh/network-tools.zsh +++ b/zsh/network-tools.zsh @@ -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 } diff --git a/zsh/string.zsh b/zsh/string.zsh new file mode 100644 index 0000000..7e81427 --- /dev/null +++ b/zsh/string.zsh @@ -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 +} diff --git a/zsh/system.zsh b/zsh/system.zsh new file mode 100644 index 0000000..2caa9e5 --- /dev/null +++ b/zsh/system.zsh @@ -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 +}