diff --git a/zsh/.aliases.sh b/zsh/.aliases.sh deleted file mode 100644 index a03584e..0000000 --- a/zsh/.aliases.sh +++ /dev/null @@ -1,51 +0,0 @@ -# alias go=colorgo -# alias cd=pushd -alias vim='nvim' -alias vimdiff='nvim -d' -# alias cat='bat' -alias ls='exa' -alias mux='tmuxinator' -alias tmux='tmux -2' -#alias go='grc -e go' - -# alias ls='ls -Gp' # Colorize the ls output ## -# alias ll='ls -la' # Use a long listing format ## -# alias l.='ls -d .*' # Show hidden files ## - -alias grep='grep --colour' - -alias cp='cp -iv' # Preferred 'cp' implementation -alias mv='mv -iv' # Preferred 'mv' implementation -alias mkdir='mkdir -pv' # Preferred 'mkdir' implementation - -alias cd..='cd ../' # Go back 1 directory level (for fast typers) -alias ..='cd ../' # Go back 1 directory level -alias ...='cd ../../' # Go back 2 directory levels -alias .3='cd ../../../' # Go back 3 directory levels -alias .4='cd ../../../../' # Go back 4 directory levels -alias .5='cd ../../../../../' # Go back 5 directory levels -alias .6='cd ../../../../../../' # Go back 6 directory levels - -alias f='open -a Finder ./' # f: Opens current directory in MacOS Finder -alias ~="cd ~" # ~: Go Home - -alias numFiles='echo $(ls -1 | wc -l)' # numFiles: Count of non-hidden files in current dir -alias make1mb='mkfile 1m ./1MB.dat' # make1mb: Creates a file of 1mb size (all zeros) -alias make5mb='mkfile 5m ./5MB.dat' # make5mb: Creates a file of 5mb size (all zeros) -alias make10mb='mkfile 10m ./10MB.dat' # make10mb: Creates a file of 10mb size (all zeros) - -# Recursive directory listing -alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'' | less' - - -# recursively delete .DS_Store files -alias ds_clean='find ./ -name ".DS_Store" -depth -exec rm {} \;' - -swap_files () { - tmp_name=$(TMPDIR=$(dirname -- "$1") mktemp) && - mv -f -- "$1" "$tmp_name" && - mv -f -- "$2" "$1" && - mv -f -- "$tmp_name" "$2" -} - -function zipdiff() { diff -W200 -y <(unzip -vql "$1" | sort -k8) <(unzip -vql "$2" | sort -k8); } diff --git a/zsh/.bash_profile.google b/zsh/.bash_profile.google index 0b67c39..7958bf6 100644 --- a/zsh/.bash_profile.google +++ b/zsh/.bash_profile.google @@ -76,38 +76,11 @@ knock() { echo "ERROR: Cannot invoke knock before gcert has been run" >&2 fi } - -sl() { - blaze build --config gmscore_arm64 //java/com/google/android/gmscore/$1:$2 - - # some targets end in ".apk", this prevents adding the suffix to targets that - # already have it - if [[ "$2" == *".apk"* ]]; then - adb install -d -r blaze-bin/java/com/google/android/gmscore/$1/$2 - else - adb install -d -r blaze-bin/java/com/google/android/gmscore/$1/$2.apk - fi -} - -sl_gms() { - sl integ GmsCore_prodnext_xxhdpi_debug -} - build_gms() { blaze build --config gmscore_arm64 //java/com/google/android/gmscore/integ:GmsCore_prodnext_xxhdpi_debug } -cdm() { - adb shell am start -n com.google.android.gms/.chimera.debug.ChimeraDebugActivity -} - -cdp() { - adb shell am start -n com.google.android.gms/.chimera.multipackage.debug.MultiPackageDebugActivity -} - -icdm() { - adb shell am start -n com.google.android.gms.isolated/com.google.android.gms.chimera.debug.ChimeraDebugActivity -} +abbr cdm = "adb shell am start -n com.google.android.gms/.chimera.debug.ChimeraDebugActivity" jt() { if [[ $PWD =~ '(.*)/javatests(.*)' ]]; then @@ -126,10 +99,6 @@ cl_search() { rg --ignore-case $1 $(hg pstatus -ma -n --template= -- 2>/dev/null) } -todos() { - cl_search "TODO" -} - cl_replace() { hg status -n --change . --template= | xargs -i sh -c "sed -i '$1' {}" } @@ -139,11 +108,6 @@ restart_gms() { adb shell am broadcast -a com.google.android.gms.INITIALIZE } -objfs_cp() { - tmp=$(mktemp) && \ - fileutil cp -f $1 $tmp && unzip $tmp $2 && unlink $tmp -} - from_cloud(){ scp baggins.c.googlers.com:$1 ~/Downloads/ echo "Saved $1 to downloads" @@ -183,3 +147,7 @@ alias copybara='/google/bin/releases/copybara/public/copybara/copybara' alias allow_ptrace='/google/bin/releases/cider/dbg/allow_ptrace' alias bluze=/google/bin/releases/blueprint-bluze/public/bluze source /google/bin/releases/gmscore-tools/cli/prod/setup_prod_gms.sh + +abbr bq="blaze query" +abbr br="blaze run" +abbr bb="blaze build" diff --git a/zsh/.zshrc b/zsh/.zshrc index e97bc43..a2ae1bb 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -29,6 +29,8 @@ zplug "plugins/docker", from:oh-my-zsh; zplug "plugins/rsync", from:oh-my-zsh; zplug "plugins/safepaste", from:oh-my-zsh; zplug "mattberther/zsh-pyenv" +zplug "olets/zsh-abbr" +zplug "olets/zsh-autosuggestions-abbreviations-strategy" zplug "Tarrasch/zsh-autoenv" # Expects .autoenv.zsh or .autoenv_leave.zsh zplug "zsh-users/zsh-syntax-highlighting", defer:2 @@ -49,6 +51,8 @@ fi # Then, source plugins and add commands to $PATH zplug load +ZSH_AUTOSUGGEST_STRATEGY=( abbreviations $ZSH_AUTOSUGGEST_STRATEGY ) + [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. # Initialization code that may require console input (password prompts, [y/n] diff --git a/zsh/abbreviations.zsh b/zsh/abbreviations.zsh new file mode 100644 index 0000000..af1ad85 --- /dev/null +++ b/zsh/abbreviations.zsh @@ -0,0 +1,23 @@ +alias grep='grep --colour' +abbr vim='nvim' +abbr vimdiff='nvim -d' +# abbr cat='bat' +alias ls='exa' +abbr mux='tmuxinator' +alias tmux='tmux -2' + +alias cp='cp -iv' # Preferred 'cp' implementation +alias mv='mv -iv' # Preferred 'mv' implementation +alias mkdir='mkdir -pv' # Preferred 'mkdir' implementation + +# recursively delete .DS_Store files +abbr ds_clean='find ./ -name ".DS_Store" -depth -exec rm {} \;' + +swap_files () { + tmp_name=$(TMPDIR=$(dirname -- "$1") mktemp) && + mv -f -- "$1" "$tmp_name" && + mv -f -- "$2" "$1" && + mv -f -- "$tmp_name" "$2" +} + +function zipdiff() { diff -W200 -y <(unzip -vql "$1" | sort -k8) <(unzip -vql "$2" | sort -k8); } diff --git a/zsh/g3path.zsh b/zsh/g3path.zsh index 7508c18..2ed80c9 100644 --- a/zsh/g3path.zsh +++ b/zsh/g3path.zsh @@ -13,7 +13,7 @@ autoload -Uz add-zsh-hook add-zsh-hook chpwd g3path::hook g3path::zle::accept-line () { - if [[ -n $GOOGLE3_ROOT && ! $BUFFER =~ \\s*(blaze|g4|p4|g4d|add_dep|buildozer|build_cleaner|debug_android_lint|rabbit|hb|gqui|builddoctor|unused_deps|clipper|blaze_lint_refactoring|migrants_sh.sar) ]]; then + if [[ -n $GOOGLE3_ROOT && ! $BUFFER =~ \\s*(bb|bq|br|blaze|g4|p4|g4d|add_dep|buildozer|build_cleaner|debug_android_lint|rabbit|hb|gqui|builddoctor|unused_deps|clipper|blaze_lint_refactoring|migrants_sh.sar) ]]; then BUFFER=${BUFFER// \/\// $GOOGLE3_ROOT\/} fi zle .accept-line