Skip to content

Instantly share code, notes, and snippets.

@aiya000
Created March 4, 2025 17:48
Show Gist options
  • Save aiya000/4f0177ed79c7ab7a7357d0296f8b59be to your computer and use it in GitHub Desktop.
Save aiya000/4f0177ed79c7ab7a7357d0296f8b59be to your computer and use it in GitHub Desktop.
Immediately open a GitHub issue by peco or fzf and etc
#!/bin/bash
# Shows GitHub issues in interactive filter and opens selected issue with gh issue view.
#
# ```shell-session
# $ gh-issue-view-select
# # Shows interactive filter with issues
# # Opens selected issue with gh issue view
# ```
if [[ $1 == '--help' ]] ; then
cat << EOF
gh-issue-view-select - Show GitHub issues in interactive filter and open selected issue
Usage:
gh-issue-view-select
gh-issue-view-select --help
Options:
--help Show this help message
EOF
exit 0
fi
selected_issue_number=$(gh issue list | $BASH_TOYS_INTERACTIVE_FILTER | awk '{ print $1 }')
if [[ -z $selected_issue_number ]] ; then
echo "No issue selected"
exit
fi
gh issue view "$selected_issue_number" "$@"
# https://github.com/aiya000/bash-toys
#
# The MIT License (MIT)
#
# Copyright (c) 2024 aiya000
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
@aiya000
Copy link
Author

aiya000 commented Mar 4, 2025

Add export BASH_TOYS_INTERACTIVE_FILTER=peco to your bashrc, zshrc, or else, first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment