zsh: add various alias

This commit is contained in:
Mathieu Maret 2021-09-06 22:10:22 +02:00
parent 08f8e6cc55
commit ed37914a24
2 changed files with 34 additions and 4 deletions

View File

@ -4,6 +4,7 @@ alias mkdir='nocorrect mkdir'
alias rm='nocorrect rm' alias rm='nocorrect rm'
alias sudo='nocorrect sudo' alias sudo='nocorrect sudo'
alias tm='tmux attach || tmux' alias tm='tmux attach || tmux'
alias zzz='systemctl hibernate'
#alias #alias
@ -12,6 +13,7 @@ alias l='ls'
alias ll='ls --color=auto -lh' alias ll='ls --color=auto -lh'
alias la='ls --color=auto -lha' alias la='ls --color=auto -lha'
alias lll='ls --color -lh | less -R' alias lll='ls --color -lh | less -R'
alias lsd="ls -d */"
alias lsg='ls | grep -i ' alias lsg='ls | grep -i '
alias ..='cd ..' alias ..='cd ..'
alias ../..='cd ../..' alias ../..='cd ../..'

View File

@ -135,10 +135,12 @@ resgrep () {
done done
} }
sgrep() { sgrep(){
find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cc|cpp|S|java|xml|sh|mk|aidl)' -print0 | xargs -0 grep --color -n "$@" find . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.\(c\|h\|cc\|cpp\|hpp\|S\|java\|xml\|sh\|mk\|aidl\|vts\)' \
-exec grep --color -n "$@" {} +
} }
mangrep() { mangrep() {
find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -name 'AndroidManifest.xml' -print0 | xargs -0 grep --color -n "$@" find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -name 'AndroidManifest.xml' -print0 | xargs -0 grep --color -n "$@"
} }
@ -152,6 +154,30 @@ docgrep () {
find . -name .repo -prune -o -name .git -prune -o -type f \( -name '*.doc' -o -name '*.docx' -o -name '*.pdf' -o -name '*.odt' \) -print0 | xargs -i -0 docgrepfile {} "$@" find . -name .repo -prune -o -name .git -prune -o -type f \( -name '*.doc' -o -name '*.docx' -o -name '*.pdf' -o -name '*.odt' \) -print0 | xargs -i -0 docgrepfile {} "$@"
} }
ggrep()
{
find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.gradle" \
-exec grep --color -n "$@" {} +
}
gogrep()
{
find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.go" \
-exec grep --color -n "$@" {} +
}
mgrep()
{
find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o \( -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk|.*\.bp)' -o -regextype posix-extended -regex '(.*/)?(build|soong)/.*[^/]*\.go' \) -type f \
-exec grep --color -n "$@" {} +
}
treegrep()
{
find . -name .repo -prune -o -name .git -prune -o -regextype posix-egrep -iregex '.*\.(c|h|cpp|hpp|S|java|xml)' -type f \
-exec grep --color -n -i "$@" {} +
}
findduplicate () findduplicate ()
{ {
find . -name .repo -prune -o -name .git -prune -o -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate find . -name .repo -prune -o -name .git -prune -o -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate
@ -226,7 +252,7 @@ sudocker(){
sdocker (){ sdocker (){
DOCKER_SSH_AUTH=$HOME/docker_ssh_auth DOCKER_SSH_AUTH=$HOME/docker_ssh_auth
AOSP_IMAGE=${AOSP_IMAGE:-$HOME/Project} AOSP_IMAGE=${AOSP_IMAGE:-$HOME/Sources/android}
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
echo "Usage: $0 DOCKER_IMAGE_NAME" echo "Usage: $0 DOCKER_IMAGE_NAME"
@ -248,7 +274,7 @@ sdocker (){
img=$(docker ps -a | grep $1 | awk '{print $1}' | head -1); img=$(docker ps -a | grep $1 | awk '{print $1}' | head -1);
if [ -z $img ]; then if [ -z $img ]; then
echo "Running a new container" echo "Running a new container"
docker run ${AOSP_ARGS} ${=SSH_AUTH_ARGS} -v ${AOSP_IMAGE}:/aosp/Project -v /media/mmaret/data_wd:/aosp/data_wd -v /media/mmaret/data:/aosp/data --user="$(id -u):$(id -g)" $1 docker run ${AOSP_ARGS} ${=SSH_AUTH_ARGS} -v ${AOSP_IMAGE}:/aosp/Project -v /home/mathieu/pixium/:/aosp/pixium/ -v /local/:/local/ -v /media/mmaret/data:/aosp/data -v /home/mathieu/miyoo/:/aosp/miyoo --user="$(id -u):$(id -g)" $1
else else
echo "Starting $img" echo "Starting $img"
docker start -i -a $img docker start -i -a $img
@ -286,3 +312,5 @@ imv() {
[[ $src != $dst ]] && mkdir -p $dst:h && mv -n $src $dst [[ $src != $dst ]] && mkdir -p $dst:h && mv -n $src $dst
done done
} }
transfer(){ if [ $# -eq 0 ];then echo "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>">&2;return 1;fi;if tty -s;then file="$1";file_name=$(basename "$file");if [ ! -e "$file" ];then echo "$file: No such file or directory">&2;return 1;fi;if [ -d "$file" ];then file_name="$file_name.zip" ,;(cd "$file"&&zip -r -q - .)|curl --progress-bar --upload-file "-" "http://transfer.sh/$file_name"|tee /dev/null,;else cat "$file"|curl --progress-bar --upload-file "-" "http://transfer.sh/$file_name"|tee /dev/null;fi;else file_name=$1;curl --progress-bar --upload-file "-" "http://transfer.sh/$file_name"|tee /dev/null;fi;}