From d3a6c45a98158ade489807dff6ad7325fb9ea595 Mon Sep 17 00:00:00 2001 From: Christian Nieves Date: Wed, 8 May 2024 18:03:10 +0000 Subject: [PATCH] fix hgshort disable poushd --- google/hgshort/OWNERS | 2 - google/hgshort/README.md | 7 --- google/hgshort/aliases.sh | 21 --------- google/hgshort/hgd.sh | 12 ------ google/hgshort/hgshort.hgrc | 73 -------------------------------- google/hgshort/hgshort.py | 82 ------------------------------------ google/hgshort/hgshort.sh | 20 --------- google/hgshort/tobashargs.py | 35 --------------- google/hgshort/tobashargs.sh | 11 ----- zsh/.aliases.sh | 2 +- zsh/.bash_profile | 8 ---- zsh/.bash_profile.google | 31 +++----------- 12 files changed, 7 insertions(+), 297 deletions(-) delete mode 100644 google/hgshort/OWNERS delete mode 100644 google/hgshort/README.md delete mode 100644 google/hgshort/aliases.sh delete mode 100755 google/hgshort/hgd.sh delete mode 100644 google/hgshort/hgshort.hgrc delete mode 100644 google/hgshort/hgshort.py delete mode 100755 google/hgshort/hgshort.sh delete mode 100755 google/hgshort/tobashargs.py delete mode 100755 google/hgshort/tobashargs.sh diff --git a/google/hgshort/OWNERS b/google/hgshort/OWNERS deleted file mode 100644 index 1cd4e3c..0000000 --- a/google/hgshort/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -parren -yurilev diff --git a/google/hgshort/README.md b/google/hgshort/README.md deleted file mode 100644 index 18e1bc2..0000000 --- a/google/hgshort/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# hgshort - Single Letter Shorthands for Fig - -hgshort makes it really easy to work with files and revisions in Fig. Use -**single letter** shorthand names, instead of long paths and hash codes. - -Documentation can be found -[here](http://g3doc/experimental/fig_contrib/g3doc/hgshort). diff --git a/google/hgshort/aliases.sh b/google/hgshort/aliases.sh deleted file mode 100644 index 400a1c8..0000000 --- a/google/hgshort/aliases.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# Creates the recommended alias definitions for hgshort when sourced. - -HGSHORT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-${(%):-%x}}}")" && pwd)" - -alias hg="source $HGSHORT_DIR/hgshort.sh" - -# There are two ways to customize: -# - define HGSHORT_CMDS_ADDITIONAL in your shell configuration to augment the -# following list. -# - define HGSHORT_CMDS directly in your shell configuration to override the -# following list. -if [[ -z "$HGSHORT_CMDS" ]]; then - HGSHORT_CMDS="$HGSHORT_CMDS_ADDITIONAL ls cat head tail mv cp rm chmod g4 diff merge patch meld vim emacs edit trim less more" -fi - -# Doing the variable expansion with an 'echo' makes this compatible with zsh. -for c in $(echo "$HGSHORT_CMDS"); do - alias $c="source $HGSHORT_DIR/tobashargs.sh $c" -done diff --git a/google/hgshort/hgd.sh b/google/hgshort/hgd.sh deleted file mode 100755 index 0b85cae..0000000 --- a/google/hgshort/hgd.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -HGSHORT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-${(%):-%x}}}")" && pwd)" - -source $HGSHORT_DIR/aliases.sh -cd $(hg hgd "$@") - -CITC="${PWD#/google/src/cloud/$USER/}" -CITC="${CITC%/google3}" -echo "CitC $CITC" - -hg l --color=always diff --git a/google/hgshort/hgshort.hgrc b/google/hgshort/hgshort.hgrc deleted file mode 100644 index 02ecb79..0000000 --- a/google/hgshort/hgshort.hgrc +++ /dev/null @@ -1,73 +0,0 @@ -# .hgrc for use with hgshort. -# -# Adds generated single letter revision and file shorthand names to the outputs -# of 'hg l/xl/ll' and 'hg status'. -# -# * For hg l/xl/ll, modifies the defaults set by: -# http://google3/devtools/piper/hgfission/client/config/google-ui-tweaks.rc -# -# * For hg status, overrides the default template (no extensible template -# available), but with one that looks the same. -# -# To use, add the following line to your ~/.hgrc: -# %include /google/src/head/depot/google3/experimental/fig_contrib/hgshort/hgshort.hgrc -# -# To make hg and other commands actually recognize the outputted shorthand -# names, follow go/hgshort#initial-setup. -# -# If you have already customized the outputs of 'hg l/xl/ll' or 'hg status', -# including this file would override them. Instead: -# -# * If you only aliased or added default arguments for 'hg status', add the -# following argument: -# --template=hgshort_status -# -# * If you customized the outputs themselves, copy the "extensions" and -# optionally the "color" sections and use: -# -# + hgshort_revision_shorthand — in your log templates. -# + hgshort_file_shorthand — in your status templates. - -[extensions] -hgshort = /google/src/head/depot/google3/experimental/fig_contrib/hgshort/hgshort.py - -[color] -# The color used for hgshort's single letter aliases. -hgshort.alias = red bold - -[color256] -# The color used for hgshort's single letter aliases. -hgshort.alias = orange bold - -##### hg l/xl/ll configuration ##### - -[templatealias] -# Get an alias for the current revision (node) with an uppercase letter. -hgshort_revision_shorthand='{hgshort(node,"A")}' -# Add the revision hgshort shorthand name to the output of 'hg l/xl/ll'. -google_compact_line_1_part_1 = '{hgshort_revision_shorthand}{google_compact_uniq_id}' - -##### hg status configuration ##### - -[templatealias] -# Get an alias for the current file with a lowercase letter. -hgshort_file_shorthand='{hgshort(relpath(path),"a")}' -# Get the right built-in label (style) for the file's status. -# See http://screen/8A5ynkOdEED.png for an example output, -# and 'hg help status' for details. -hgshort_status_label(status) = '{ifeq(status, "?", "status.unknown", ifeq(status, "!", "status.deleted", get(dict(A="status.added", M="status.modified", R="status.removed", I="status.ignored", C="status.clean"), status)))}' -hgshort_status_line1 = '{hgshort_file_shorthand}{label(hgshort_status_label(status), '{status} {relpath(path)}')}' -hgshort_status_line2 = '{if(source, " {label("status.copied", " {relpath(source)}")}")}' - -[templates] -# Add the hgshort file shorthand name to the output of 'hg status'. -# In conflict resolution mode, we get empty entries. Filter them out. -hgshort_status = '{if(path,"{separate("\n", hgshort_status_line1, hgshort_status_line2)}\n","")}' - -[defaults] -# Override the default 'hg status' command, but keep -n working. -status = --template=hgshort_status - -[alias] -# Override the default 'hg pstatus' template. -pstatus = pstatus --template=hgshort_status diff --git a/google/hgshort/hgshort.py b/google/hgshort/hgshort.py deleted file mode 100644 index fd9c93c..0000000 --- a/google/hgshort/hgshort.py +++ /dev/null @@ -1,82 +0,0 @@ -'''"shorthand" template filter to emit bash shorthand accessors.''' - -import os -import sys - -from mercurial import error -from mercurial import i18n -from mercurial import registrar -from mercurial import templateutil - -# dict of template built-in functions -funcs = {} -templatefunc = registrar.templatefunc(funcs) -templatefilter = registrar.templatefilter() - -evalboolean = templateutil.evalboolean -evalstring = templateutil.evalstring - -bashvarsfile = None -if sys.stdout.isatty(): - if 'HGSHORT_BASH_VARS' in os.environ: - bashvarsfile = os.environ['HGSHORT_BASH_VARS'] - -nextaliasidbytype = { - b'a': ord(b'a'), - b'A': ord(b'A')} - - -def writealias(name, value): - if not bashvarsfile: - return - with open(bashvarsfile, 'a') as f: - f.write("export %s='%s'\n" % (name.decode('utf-8'), value.decode('utf-8'))) - - -def nextaliaschar(aliastype): - if not bashvarsfile: - return None - aliasid = nextaliasidbytype[aliastype] - if aliasid < ord(aliastype) + 26: - nextaliasidbytype[aliastype] += 1 - return chr(aliasid).encode('utf-8') - return None - - -def maybealias(value, aliastype): - """Export as next bash alias and return id, or None.""" - aliaschar = nextaliaschar(aliastype) - if not aliaschar: return None - writealias(b'hgshort%s' % aliaschar, value) - return aliaschar - - -@templatefilter(b'shorthand', intype=bytes) -def shorthand(text): - """Export as next bash alias.""" - if not bashvarsfile: - return b'' - aliaschar = maybealias(text, b'a') - if not aliaschar: - return b' ' - return b'%s ' % aliaschar - - -@templatefunc( - b'hgshort(text, aliastype)', - argspec=b'text aliastype', - requires={b'ui'}) -def hgshort(context, mapping, args): - """Export as next bash alias and return id, or None.""" - if not bashvarsfile: - return b'' - if b'text' not in args or b'aliastype' not in args: - raise error.ParseError(i18n._(b'hgshort() expects one to three arguments')) - text = evalstring(context, mapping, args[b'text']) - aliastype = evalstring(context, mapping, args[b'aliastype']) - aliaschar = maybealias(text, aliastype) - if not aliaschar: - return b' ' - aliastext = b'%s ' % aliaschar - ui = context.resource(mapping, b'ui') - return ui.label(aliastext, b'hgshort.alias') diff --git a/google/hgshort/hgshort.sh b/google/hgshort/hgshort.sh deleted file mode 100755 index 904cdaa..0000000 --- a/google/hgshort/hgshort.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -HGSHORT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-${(%):-%x}}}")" && pwd)" - -export HGSHORT_BASH_VARS="/tmp/hgshort-bash-vars-$$.sh" -export HGSHORT_BASH_ARGS="/tmp/hgshort-bash-args-$$.sh" - -if [[ -f $HGSHORT_BASH_VARS ]]; then - \rm $HGSHORT_BASH_VARS # don't call rm to avoid alias loop -fi - -HGSHORT_IS_HG=1 $HGSHORT_DIR/tobashargs.py "$@" > $HGSHORT_BASH_ARGS -xargs --null --arg-file=$HGSHORT_BASH_ARGS \ - hg --config extensions.hgshort=$HGSHORT_DIR/hgshort.py -\rm $HGSHORT_BASH_ARGS # don't call rm to avoid alias loop - -if [[ -f $HGSHORT_BASH_VARS ]]; then - source $HGSHORT_BASH_VARS - \rm $HGSHORT_BASH_VARS # don't call rm to avoid alias loop -fi diff --git a/google/hgshort/tobashargs.py b/google/hgshort/tobashargs.py deleted file mode 100755 index 1e7860b..0000000 --- a/google/hgshort/tobashargs.py +++ /dev/null @@ -1,35 +0,0 @@ -#! /usr/bin/python3 -"""Converts single letters like X to bash variable references like $hgshortX.""" - -import os -import re -import sys - -# Shortands can be prefixed with an 'r', in which case several can be used in -# one argument. This is useful for revsets, for example: 'rA::rD'. -ALIAS_RE = re.compile(r'^([a-zA-Z])$|\br([A-Z])\b') - - -def subst(match): - char = match.group(1) or match.group(2) - - var = 'hgshort%s' % char - if var in os.environ: - return os.getenv(var, '') - - return match.group(0) - - -def substall(s): - return ALIAS_RE.sub(subst, s) - - -# Don't process first argument for `hg`, since it's often a command abbreviated -# to a single letter. -if 'HGSHORT_IS_HG' in os.environ: - args = sys.argv[1:2] + list(substall(a) for a in sys.argv[2:]) -else: - args = list(substall(a) for a in sys.argv[1:]) - -# sys.stderr.write('%s\n' % repr(args)) # debug only -sys.stdout.write(chr(0).join(args)) diff --git a/google/hgshort/tobashargs.sh b/google/hgshort/tobashargs.sh deleted file mode 100755 index 182c79a..0000000 --- a/google/hgshort/tobashargs.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -HGSHORT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-${(%):-%x}}}")" && pwd)" - -export HGSHORT_BASH_CMD="$1" -export HGSHORT_BASH_ARGS="/tmp/HGSHORT-bash-args-$$.sh" - -shift -$HGSHORT_DIR/tobashargs.py "$@" > $HGSHORT_BASH_ARGS -xargs --null --arg-file=$HGSHORT_BASH_ARGS $HGSHORT_BASH_CMD -\rm $HGSHORT_BASH_ARGS # don't call rm to avoid alias loop diff --git a/zsh/.aliases.sh b/zsh/.aliases.sh index a68fe31..a03584e 100644 --- a/zsh/.aliases.sh +++ b/zsh/.aliases.sh @@ -1,5 +1,5 @@ # alias go=colorgo -alias cd=pushd +# alias cd=pushd alias vim='nvim' alias vimdiff='nvim -d' # alias cat='bat' diff --git a/zsh/.bash_profile b/zsh/.bash_profile index 0e069d5..74d8bb9 100644 --- a/zsh/.bash_profile +++ b/zsh/.bash_profile @@ -18,10 +18,6 @@ export DEVKITPRO=/opt/devkitpro export DEVKITARM=${DEVKITPRO}/devkitARM export DEVKITPPC=${DEVKITPRO}/devkitPPC -export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm -[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion - source ~/.aliases.sh if [[ -f "$HOME/use_google" ]]; then @@ -29,8 +25,4 @@ if [[ -f "$HOME/use_google" ]]; then fi . "$HOME/.cargo/env" -export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm -[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion - if [ -f ~/.bashrc ]; then . ~/.bashrc; fi diff --git a/zsh/.bash_profile.google b/zsh/.bash_profile.google index e290ca0..be88122 100644 --- a/zsh/.bash_profile.google +++ b/zsh/.bash_profile.google @@ -2,8 +2,6 @@ # --------------- # Google Specific # --------------- -# For running crow against a remote X server -# xhost + export PATH=$PATH:/google/src/head/depot/google3/experimental/users/cnieves/util export PATH="${HOME}/.config/lsp/lua-language-server/bin:${PATH}" export XAUTHORITY=~/.Xauthority @@ -11,8 +9,12 @@ export GOROOT=/usr/lib/google-golang export PATH=$GOROOT/bin:$PATH export JAVA_HOME=$(readlink -ne /usr/local/buildtools/java/jdk) export CARGO_NET_GIT_FETCH_WITH_CLI=true -source /google/bin/releases/knock/knock.sh +source ~/g3path.zsh +source ~/fzf-at-google.zsh +source /etc/bash_completion.d/hgd +gcertstatus --quiet || gcert && source /google/bin/releases/knock/knock.sh +# gcertstatus --quiet || gcert && source /google/bin/releases/gmscore-tools/cli/prod/setup_prod_gms.sh function gcert() { if [[ -n $TMUX ]]; then eval $(tmux show-environment -s) @@ -36,10 +38,6 @@ export FZF_CS_PREVIEW_COMMAND="python third_party/py/pygments/google/google_pygm # Preview highlight: foreground: RG(248, 248, 248) = #F8F8F8, background: RGB(81, 85, 89) = #515559. export FZF_CS_PREVIEW_HIGHLIGHT="\x1b[38;2;248;248;248m\x1b[48;2;81;85;89m" -source ~/g3path.zsh -source /etc/bash_completion.d/hgd - -source /google/bin/releases/gmscore-tools/cli/prod/setup_prod_gms.sh alias aapt2=/google/src/head/depot/google3/third_party/java/android/android_sdk_linux/platform-tools/aapt2 alias acid=/google/bin/releases/mobile-devx-platform/acid/acid alias apido='/google/data/ro/teams/oneplatform/apido' @@ -55,24 +53,19 @@ alias replace_string=/google/src/head/depot/google3/devtools/scripts/replace_str alias safergcp=/google/bin/releases/safer-gcp/tools/safergcp alias add_deps_to_usages='/google/src/head/depot/google3/apps/framework/tools/add_deps_to_usages.sh' alias plxutil='/google/data/ro/teams/plx/plxutil' -export HGSHORT_CMDS="cat head tail mv cp rm chmod g4 diff merge patch meld trim less more" +export HGSHORT_CMDS="cat head tail mv cp rm chmod g4 diff merge patch meld trim less more nvim" export HGSHORT_DIR='/google/src/head/depot/google3/experimental/fig_contrib/hgshort' # default alias vim="source $HGSHORT_DIR/tobashargs.sh nvim" -source /google/src/head/depot/google3/experimental/fig_contrib/hgshort/hgd-local.sh 2>/dev/null # just to get HGSHORT_DIR in env alias hgd='source /google/src/head/depot/google3/experimental/fig_contrib/hgshort/hgd-local.sh' alias builddoctor=/google/bin/releases/build-doctor/builddoctor alias rudi=/google/data/ro/teams/lsc/bin/rudi-cli alias rudi-cli=/google/data/ro/teams/lsc/bin/rudi-cli alias graphviz=/google/data/ro/projects/graphviz-server/graphviz alias xrefs=/google/bin/releases/grok/tools/xrefs -# alias tmux=tmx2 -# compdef tmx2=tmux export ACID_STARTUP_SCRIPT_PATH=~/acid_startup.sh export PATH=$PATH:/usr/local/google/home/cnieves/.local/binexport PATH=$PATH:/usr/local/google/home/cnieves/.local/bin -source ~/fzf-at-google.zsh - # Temporary definition for knock, which will override itself with the # real implementation. knock() { @@ -116,11 +109,6 @@ icdm() { adb shell am start -n com.google.android.gms.isolated/com.google.android.gms.chimera.debug.ChimeraDebugActivity } -hgr() { - source /google/src/head/depot/google3/experimental/users/cnieves/util/hgr.sh || return - hgr "$@" -} - jt() { if [[ $PWD =~ '(.*)/javatests(.*)' ]]; then cd "${match[1]}/java${match[2]}" @@ -193,10 +181,3 @@ bdoctor_modules() { alias bisect=/google/data/ro/teams/tetralight/bin/bisect alias copybara='/google/bin/releases/copybara/public/copybara/copybara' alias allow_ptrace='/google/bin/releases/cider/dbg/allow_ptrace' -source /etc/bash_completion.d/g4d -gcertstatus --quiet || gcert && source /google/bin/releases/gmscore-tools/cli/prod/setup_prod_gms.sh - -complete -D -C /google/data/ro/users/sk/skaushik/www/public-tools/flagpick -o bashdefault -o default - -# Setup go/hi #!>>HI<>HI<