restart docker in mac, random-string

This commit is contained in:
hophacker 2021-07-12 14:38:01 +08:00
parent c36707f620
commit f169fe2596
2 changed files with 11 additions and 2 deletions

View File

@ -249,14 +249,17 @@ alias ls_folder_size="du -sch .[!.]* * | sort -h"
alias top_by_memory="top -o %MEM" alias top_by_memory="top -o %MEM"
alias gcaa="gia .; gcF" alias gcaa="gia .; gcF"
alias ror_ctags="ctags -R --languages=ruby --exclude=.git --exclude=log . \$(bundle list --paths)" alias ror_ctags="ctags -R --languages=ruby --exclude=.git --exclude=log . \$(bundle list --paths)"
alias docker_clean_images='docker rmi $(docker images -a --filter=dangling=true -q)'
alias find_large_files="sudo find / -xdev -type f -size +50M" alias find_large_files="sudo find / -xdev -type f -size +50M"
alias vim_plain="vim -u NONE" alias vim_plain="vim -u NONE"
alias edit_alias="vim $yadr_zsh/aliases.zsh $yadr_zsh/functions.zsh -p" alias edit_alias="vim $yadr_zsh/aliases.zsh $yadr_zsh/functions.zsh -p"
alias docker_purge='docker stop $(docker ps -qa);docker rm $(docker ps -qa)'
alias yarn_sass="SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/ yarn" alias yarn_sass="SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/ yarn"
alias vim="nvim" alias vim="nvim"
## docker
alias docker_clean_images='docker rmi $(docker images -a --filter=dangling=true -q)'
alias docker_purge='docker stop $(docker ps -qa);docker rm $(docker ps -qa)'
alias docker_restart_in_mac='killall Docker && open /Applications/Docker.app'
## source files ## source files
alias ss="source ~/.zshrc" alias ss="source ~/.zshrc"
alias delete_all_binaries="find . -type f -perm -u+x -not -path './.git/*' | xargs rm" alias delete_all_binaries="find . -type f -perm -u+x -not -path './.git/*' | xargs rm"

View File

@ -156,6 +156,7 @@ function Replace () {
SED_CMD=s${SEP}$SRC${SEP}$DST${SEP}g SED_CMD=s${SEP}$SRC${SEP}$DST${SEP}g
fi fi
if [[ "$(uname)" == "Darwin" ]]; then if [[ "$(uname)" == "Darwin" ]]; then
echo "xargs sed -i '' \"${SED_CMD}\""
echo $MATCHED_FILES | xargs sed -i '' "${SED_CMD}" echo $MATCHED_FILES | xargs sed -i '' "${SED_CMD}"
elif [[ "$(expr substr $(uname -s) 1 5)" == "Linux" ]]; then elif [[ "$(expr substr $(uname -s) 1 5)" == "Linux" ]]; then
echo $MATCHED_FILES | xargs sed -i ${SED_CMD} echo $MATCHED_FILES | xargs sed -i ${SED_CMD}
@ -372,3 +373,8 @@ function gcm {
function random_hex { function random_hex {
openssl rand -hex $(expr $1 / 2) 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
}