@@ -1106,23 +1106,35 @@ function ba() {
11061106 local log_file="${HOME}/.ba.log"
11071107 local error_log="${HOME}/.ba.errors.log"
11081108
1109+ if [[ -f "${log_file}" ]]; then
1110+ mv -f "${log_file}" "${log_file}.1"
1111+ fi
1112+ touch "$log_file"
1113+
11091114 # link all ollama models to lm-studio
11101115 llamalink >>"${log_file}" 2>&1 &
11111116
11121117 # update vscode packages
11131118 code --update-extensions >>"${log_file}" 2>&1 &
1119+ gh extension upgrade --all >>"${log_file}" 2>&1 &
11141120
11151121 # Update Claude Code
11161122 claude update >>"${log_file}" 2>&1 &
11171123
1118- npm install -g --upgrade @qwen-code/qwen-code@latest @google/gemini-cli
1119- uv tool install claude-monitor -U
1124+ # Update global npm packages (which is just claude code, gemini-cli, claude-code-router, and qwen-code)
1125+ npm-check-updates -g -u
1126+ npm install -g --upgrade @qwen-code/qwen-code@latest @google/gemini-cli \
1127+ @musistudio/claude-code-router @anthropic-ai/claude-code@latest ccusage \
1128+ ccstatusline@latest ccexp@latest vibe-kanban@latest >>"${log_file}" 2>&1 &
1129+
1130+ # claudekit@latest
1131+
1132+ uv tool install claude-monitor -U >>"${log_file}" 2>&1 &
1133+ uv tool install claude-code-tools >>"${log_file}" 2>&1 &
11201134
11211135 # update homebrew and all apps
11221136 brew update >>"${error_log}" 2>&1
11231137
1124- mv "${log_file}" "${log_file}.1"
1125-
11261138 echo "Upgrading shell and packages in the background, tail -f ${log_file} for details."
11271139
11281140 touch "${log_file}" "${error_log}"
@@ -1200,7 +1212,6 @@ function __upgrade_packages() {
12001212
12011213 pip3 install -U pip
12021214 npm i -g npm-check-updates
1203- npm i -g @google/gemini-cli
12041215 \ncu --global
12051216 echo | vim +PluginInstall +qall &>/dev/null
12061217
@@ -1683,27 +1694,32 @@ function aws-sso() {
16831694 return 1
16841695 fi
16851696 aws sso login --profile "$1"
1686- eval "$(aws configure export-credentials --format env --profile "$1")"
1697+
1698+ # Set the profile and region in current shell
16871699 export AWS_PROFILE="$1"
16881700 export AWS_REGION=ap-southeast-2
16891701
1702+ # Get the credentials using AWS CLI and set them in the current shell
1703+ eval "$(aws configure export-credentials --format env --profile "$1")"
1704+
16901705 # Create a temporary file only user can access for short-lived, rotating credentials
16911706 mkdir -p "${HOME}/.tmp"
16921707 local aws_creds_file
16931708 aws_creds_file="${HOME}/.tmp/awltmp"
16941709 rm -f "$aws_creds_file"
1695- touch "$aws_creds_file"
1696- chmod 600 "$aws_creds_file"
16971710
1698- # Export AWS credentials to the temporary file
1711+ # Write the current environment variables to the file
16991712 cat > "$aws_creds_file" << EOF
17001713export AWS_SESSION_TOKEN='$AWS_SESSION_TOKEN'
17011714export AWS_ACCESS_KEY_ID='$AWS_ACCESS_KEY_ID'
17021715export AWS_SECRET_ACCESS_KEY='$AWS_SECRET_ACCESS_KEY'
1703- export AWS_PROFILE='$AWS_PROFILE '
1704- export AWS_REGION='$AWS_REGION '
1716+ export AWS_PROFILE='$1 '
1717+ export AWS_REGION='ap-southeast-2 '
17051718EOF
17061719
1720+ chmod 600 "$aws_creds_file"
1721+
1722+ echo "AWS credentials exported to $aws_creds_file"
17071723 echo "Run the following in other terminals to source the credentials:"
17081724 echo "source $aws_creds_file"
17091725}
@@ -1801,3 +1817,108 @@ cd() {
18011817 builtin cd "$@"
18021818 fi
18031819}
1820+
1821+ # Function to list and display comments made by GitHub Copilot on the current PR
1822+ copilot-comments() {
1823+ local -r current_branch="$(git branch --show-current 2>/dev/null)" || {
1824+ printf "Error: Not in a git repository or no current branch\n" >&2
1825+ return 1
1826+ }
1827+
1828+ local base_branch pr_num general_reviews inline_comments all_prs
1829+
1830+ # Use printf instead of echo for better portability and consistency
1831+ base_branch="$(gh repo view --json defaultBranch --jq '.defaultBranch.name' 2>/dev/null)" || base_branch="main"
1832+ pr_num="$(gh pr list --head "${current_branch}" --base "${base_branch}" --json number --jq '.[0].number' 2>/dev/null)" || pr_num=""
1833+
1834+ if [[ -z "${pr_num}" || "${pr_num}" == "null" ]]; then
1835+ printf "No open PR found for current branch %s\n" "${current_branch}"
1836+
1837+ if all_prs="$(gh pr list --base "${base_branch}" --json number,title,headRefName --jq '.[] | "PR #\(.number): \(.title) (branch: \(.headRefName))"' 2>/dev/null)" && [[ -n "${all_prs}" ]]; then
1838+ printf "All open PRs to %s:\n%s\n" "${base_branch}" "${all_prs}"
1839+ fi
1840+ return 1
1841+ fi
1842+
1843+ # Helper function to reduce code duplication
1844+ _fetch_copilot_data() {
1845+ local -r endpoint="$1"
1846+ local -r jq_filter="$2"
1847+ gh api "repos/:owner/:repo/pulls/${pr_num}/${endpoint}" 2>/dev/null | jq -r "${jq_filter}" 2>/dev/null || true
1848+ }
1849+
1850+ general_reviews="$(_fetch_copilot_data "reviews" '.[] | select(.user.login == "Copilot") | .body')"
1851+ inline_comments="$(_fetch_copilot_data "comments" '.[] | select(.user.login == "Copilot") | "\(.path) (line \(.line))\n\(.body)\n" + ("=" * 50) + "\n"')"
1852+
1853+ if [[ -n "${general_reviews}" || -n "${inline_comments}" ]]; then
1854+ printf "I submitted the changes to Github Copilot to review, keep in mind that Github Copilot doesn't use a very strong AI model so it may not be accurate.\n"
1855+
1856+ printf "🤖 GitHub Copilot comments on PR #%s:\n" "${pr_num}"
1857+
1858+ if [[ -n "${general_reviews}" ]]; then
1859+ printf "## Copilot review comments\n"
1860+ printf "%s\n" "${general_reviews}\n------\n"
1861+ fi
1862+
1863+ if [[ -n "${inline_comments}" ]]; then
1864+ printf "\n## Copilot inline comments\n"
1865+ printf "%s\n" "${inline_comments}"
1866+ fi
1867+
1868+ printf "⚠️ Be mindful that GitHub Copilot's comments may be inaccurate. Ignore any invalid or out of context comments. Please review them carefully before applying any changes. Discuss recommendations with me if the path forward is unclear.\n"
1869+ fi
1870+ }
1871+
1872+ # Quick navigation to git repositories, optionally taking a subdirectory as an argument
1873+ _git_nav() {
1874+ local cmd="$1"
1875+ shift # Remove the command from arguments
1876+ local base_dir
1877+
1878+ case "$cmd" in
1879+ "gs")
1880+ base_dir="$HOME/git/sammcj"
1881+ ;;
1882+ "gm")
1883+ base_dir="$HOME/git/mantel"
1884+ ;;
1885+ "g")
1886+ base_dir="$HOME/git"
1887+ ;;
1888+ *)
1889+ echo "Unknown git navigation command: $cmd"
1890+ return 1
1891+ ;;
1892+ esac
1893+
1894+ if [[ $# -eq 0 ]]; then
1895+ cd "$base_dir"
1896+ else
1897+ local target_dir="$base_dir/$1"
1898+ if [[ -d "$target_dir" ]]; then
1899+ cd "$target_dir"
1900+ else
1901+ cd "$base_dir"
1902+ echo "Directory '$1' not found in $base_dir"
1903+ fi
1904+ fi
1905+ }
1906+ # Use the git quick navigation function
1907+ gs() { _git_nav "gs" "$@"; }
1908+ gm() { _git_nav "gm" "$@"; }
1909+ g() { _git_nav "g" "$@"; }
1910+
1911+
1912+ fcs() {
1913+ # https://github.com/pchalasani/claude-code-tools#-find-claude-session
1914+ # fcs "keyword1,keyword2,keyword3" # Search in current project
1915+ # fcs "keywords" -g Search across all Claude projects
1916+
1917+ # Check if user is asking for help
1918+ if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]]; then
1919+ find-claude-session --help
1920+ return
1921+ fi
1922+ # Run find-claude-session in shell mode and evaluate the output
1923+ eval "$(find-claude-session --shell "$@" | sed '/^$/d')"
1924+ }
0 commit comments