auto
parent
6d642c4df1
commit
49948bfbc9
|
@ -54,3 +54,147 @@ alias ~="cd ~" # ~: Go Home
|
|||
alias c='clear' # c: Clear terminal display
|
||||
alias path='echo -e ${PATH//:/\\n}' # path: Echo all executable Paths
|
||||
mcd () { mkdir -p "$1" && cd "$1"; } # mcd: Makes new Dir and jumps inside
|
||||
|
||||
# copilot
|
||||
ghcs() {
|
||||
TARGET="shell"
|
||||
local GH_DEBUG="$GH_DEBUG"
|
||||
local GH_HOST="$GH_HOST"
|
||||
|
||||
read -r -d '' __USAGE <<-EOF
|
||||
Wrapper around \`gh copilot suggest\` to suggest a command based on a natural language description of the desired output effort.
|
||||
Supports executing suggested commands if applicable.
|
||||
|
||||
USAGE
|
||||
$FUNCNAME [flags] <prompt>
|
||||
|
||||
FLAGS
|
||||
-d, --debug Enable debugging
|
||||
-h, --help Display help usage
|
||||
--hostname The GitHub host to use for authentication
|
||||
-t, --target target Target for suggestion; must be shell, gh, git
|
||||
default: "$TARGET"
|
||||
|
||||
EXAMPLES
|
||||
|
||||
- Guided experience
|
||||
$ $FUNCNAME
|
||||
|
||||
- Git use cases
|
||||
$ $FUNCNAME -t git "Undo the most recent local commits"
|
||||
$ $FUNCNAME -t git "Clean up local branches"
|
||||
$ $FUNCNAME -t git "Setup LFS for images"
|
||||
|
||||
- Working with the GitHub CLI in the terminal
|
||||
$ $FUNCNAME -t gh "Create pull request"
|
||||
$ $FUNCNAME -t gh "List pull requests waiting for my review"
|
||||
$ $FUNCNAME -t gh "Summarize work I have done in issues and pull requests for promotion"
|
||||
|
||||
- General use cases
|
||||
$ $FUNCNAME "Kill processes holding onto deleted files"
|
||||
$ $FUNCNAME "Test whether there are SSL/TLS issues with github.com"
|
||||
$ $FUNCNAME "Convert SVG to PNG and resize"
|
||||
$ $FUNCNAME "Convert MOV to animated PNG"
|
||||
EOF
|
||||
|
||||
local OPT OPTARG OPTIND
|
||||
while getopts "dht:-:" OPT; do
|
||||
if [ "$OPT" = "-" ]; then # long option: reformulate OPT and OPTARG
|
||||
OPT="${OPTARG%%=*}" # extract long option name
|
||||
OPTARG="${OPTARG#"$OPT"}" # extract long option argument (may be empty)
|
||||
OPTARG="${OPTARG#=}" # if long option argument, remove assigning `=`
|
||||
fi
|
||||
|
||||
case "$OPT" in
|
||||
debug | d)
|
||||
GH_DEBUG=api
|
||||
;;
|
||||
|
||||
help | h)
|
||||
echo "$__USAGE"
|
||||
return 0
|
||||
;;
|
||||
|
||||
hostname)
|
||||
GH_HOST="$OPTARG"
|
||||
;;
|
||||
|
||||
target | t)
|
||||
TARGET="$OPTARG"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# shift so that $@, $1, etc. refer to the non-option arguments
|
||||
shift "$((OPTIND-1))"
|
||||
|
||||
TMPFILE="$(mktemp -t gh-copilotXXXXXX)"
|
||||
trap 'rm -f "$TMPFILE"' EXIT
|
||||
if GH_DEBUG="$GH_DEBUG" GH_HOST="$GH_HOST" gh copilot suggest -t "$TARGET" "$@" --shell-out "$TMPFILE"; then
|
||||
if [ -s "$TMPFILE" ]; then
|
||||
FIXED_CMD="$(cat $TMPFILE)"
|
||||
history -s $(history 1 | cut -d' ' -f4-); history -s "$FIXED_CMD"
|
||||
echo
|
||||
eval "$FIXED_CMD"
|
||||
fi
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
ghce() {
|
||||
local GH_DEBUG="$GH_DEBUG"
|
||||
local GH_HOST="$GH_HOST"
|
||||
|
||||
read -r -d '' __USAGE <<-EOF
|
||||
Wrapper around \`gh copilot explain\` to explain a given input command in natural language.
|
||||
|
||||
USAGE
|
||||
$FUNCNAME [flags] <command>
|
||||
|
||||
FLAGS
|
||||
-d, --debug Enable debugging
|
||||
-h, --help Display help usage
|
||||
--hostname The GitHub host to use for authentication
|
||||
|
||||
EXAMPLES
|
||||
|
||||
# View disk usage, sorted by size
|
||||
$ $FUNCNAME 'du -sh | sort -h'
|
||||
|
||||
# View git repository history as text graphical representation
|
||||
$ $FUNCNAME 'git log --oneline --graph --decorate --all'
|
||||
|
||||
# Remove binary objects larger than 50 megabytes from git history
|
||||
$ $FUNCNAME 'bfg --strip-blobs-bigger-than 50M'
|
||||
EOF
|
||||
|
||||
local OPT OPTARG OPTIND
|
||||
while getopts "dh-:" OPT; do
|
||||
if [ "$OPT" = "-" ]; then # long option: reformulate OPT and OPTARG
|
||||
OPT="${OPTARG%%=*}" # extract long option name
|
||||
OPTARG="${OPTARG#"$OPT"}" # extract long option argument (may be empty)
|
||||
OPTARG="${OPTARG#=}" # if long option argument, remove assigning `=`
|
||||
fi
|
||||
|
||||
case "$OPT" in
|
||||
debug | d)
|
||||
GH_DEBUG=api
|
||||
;;
|
||||
|
||||
help | h)
|
||||
echo "$__USAGE"
|
||||
return 0
|
||||
;;
|
||||
|
||||
hostname)
|
||||
GH_HOST="$OPTARG"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# shift so that $@, $1, etc. refer to the non-option arguments
|
||||
shift "$((OPTIND-1))"
|
||||
|
||||
GH_DEBUG="$GH_DEBUG" GH_HOST="$GH_HOST" gh copilot explain "$@"
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ function Colors(color)
|
|||
color = color or "rose-pine"
|
||||
vim.cmd.colorscheme(color)
|
||||
|
||||
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
|
||||
-- vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
|
||||
-- vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
|
||||
end
|
||||
|
||||
Colors()
|
||||
|
|
|
@ -15,7 +15,7 @@ bind -T copy-mode-vi v send-keys -X begin-selection
|
|||
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
|
||||
|
||||
# vim-like pane switching
|
||||
bind -r ^ last-window
|
||||
bind -r a last-window
|
||||
bind -r k select-pane -U
|
||||
bind -r j select-pane -D
|
||||
bind -r h select-pane -L
|
||||
|
|
Loading…
Reference in New Issue