chore(macutil): rewrote a good portion of the script
This commit is contained in:
1 parent
165084201a
commit
e80f5c03da
4 files changed
+73
-358
No files matched your search
+72
-163
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env bask
|
||||
#!/usr/bin/env bash
|
||||
sudo -v
|
||||
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
|
||||
|
||||
@@ -6,7 +6,6 @@ if ! command -v brew &> /dev/null; then
|
||||
echo "Installing Homebrew..."
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
|
||||
# Add Homebrew to PATH for the rest of this session (Apple Silicon fix)
|
||||
if [[ $(uname -m) == "arm64" ]]; then
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
else
|
||||
@@ -14,24 +13,22 @@ if ! command -v brew &> /dev/null; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# if ! command -v cargo &> /dev/null; then
|
||||
# echo "Installing Cargo"
|
||||
# curl https://sh.rustup.rs -sSf | sh
|
||||
# fi
|
||||
|
||||
DOTFILES_DIR="$HOME/dotfiles"
|
||||
if [ ! -d "$DOTFILES_DIR" ]; then
|
||||
echo "Cloning dotfiles..."
|
||||
git clone https://git.moomancer.xyz/DarthMooMancer/dotfiles.git
|
||||
git clone https://git.moomancer.xyz/DarthMooMancer/dotfiles.git "$DOTFILES_DIR"
|
||||
else
|
||||
echo "Updating dotfiles"
|
||||
git -C "$DOTFILES_DIR" pull
|
||||
fi
|
||||
|
||||
cd "$DOTFILES_DIR"
|
||||
brew bundle --file=brew/.Brewfile
|
||||
|
||||
stow -v -t "$HOME"
|
||||
stow -v -t "$HOME" .
|
||||
|
||||
cd ~/
|
||||
#
|
||||
# Enable Touch ID for sudo
|
||||
|
||||
if ! grep -q "pam_tid.so" /etc/pam.d/sudo; then
|
||||
echo "Enabling Touch ID for sudo..."
|
||||
sudo sed -i '' '2i\
|
||||
@@ -39,178 +36,90 @@ auth sufficient pam_tid.so
|
||||
' /etc/pam.d/sudo
|
||||
fi
|
||||
|
||||
# Enable Single App Mode
|
||||
sudo nvram StartupMute=%01
|
||||
sudo defaults write /Library/Preferences/com.apple.loginwindow showInputMenu -bool true
|
||||
defaults write NSGlobalDomain AppleFontSmoothing -int 1
|
||||
defaults write com.apple.LaunchServices LSQuarantine -bool false
|
||||
|
||||
defaults write com.apple.dock single-app -bool true
|
||||
defaults write com.apple.dock autohide -bool true
|
||||
defaults write com.apple.dock autohide-delay -float 0
|
||||
defaults write com.apple.dock autohide-time-modifier -float 0.2
|
||||
# Sets a blazingly fast repeat rate
|
||||
defaults write NSGlobalDomain KeyRepeat -int 2
|
||||
# Sets how long you have to hold the key before it starts repeating
|
||||
defaults write NSGlobalDomain InitialKeyRepeat -int 15
|
||||
defaults write com.apple.dock show-recents -bool false
|
||||
defaults write com.apple.dock expose-animation-duration -float 0.1
|
||||
# Show all filename extensions
|
||||
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
|
||||
|
||||
# Finder: show path bar (makes it easier to see exactly where you are)
|
||||
defaults write com.apple.finder ShowPathbar -bool true
|
||||
|
||||
# Keep folders on top when sorting by name (like Windows/Linux)
|
||||
defaults write com.apple.finder _FXSortFoldersFirst -bool true
|
||||
|
||||
# Enable the WebKit Developer Tools in the Mac App Store
|
||||
defaults write com.apple.appstore WebKitDeveloperExtras -bool true
|
||||
|
||||
# Enable Debug Menu in the Mac App Store
|
||||
defaults write com.apple.appstore ShowDebugMenu -bool true
|
||||
|
||||
# Enable the automatic update check
|
||||
defaults write NSGlobalDomain KeyRepeat -int 2
|
||||
defaults write NSGlobalDomain InitialKeyRepeat -int 15
|
||||
|
||||
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
|
||||
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true
|
||||
|
||||
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
|
||||
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false
|
||||
defaults write com.apple.finder ShowPathbar -bool true
|
||||
defaults write com.apple.finder _FXSortFoldersFirst -bool true
|
||||
|
||||
defaults write com.apple.SoftwareUpdate AutomaticCheckEnabled -bool true
|
||||
|
||||
# Check for software updates daily, not just once per week
|
||||
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
|
||||
|
||||
# Download newly available updates in background
|
||||
defaults write com.apple.SoftwareUpdate AutomaticDownload -int 1
|
||||
|
||||
# Install System data files & security updates
|
||||
defaults write com.apple.SoftwareUpdate CriticalUpdateInstall -int 1
|
||||
|
||||
# Automatically download apps purchased on other Macs
|
||||
defaults write com.apple.SoftwareUpdate ConfigDataInstall -int 1
|
||||
|
||||
# Turn on app auto-update
|
||||
defaults write com.apple.commerce AutoUpdate -bool true
|
||||
|
||||
# Allow the App Store to reboot machine on macOS updates
|
||||
defaults write com.apple.commerce AutoUpdateRestartRequired -bool true
|
||||
|
||||
###############################################################################
|
||||
# Safari & WebKit #
|
||||
###############################################################################
|
||||
|
||||
# Privacy: don’t send search queries to Apple
|
||||
defaults write com.apple.Safari UniversalSearchEnabled -bool false
|
||||
defaults write com.apple.Safari SuppressSearchSuggestions -bool true
|
||||
|
||||
# Press Tab to highlight each item on a web page
|
||||
defaults write com.apple.Safari WebKitTabToLinksPreferenceKey -bool true
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2TabsToLinks -bool true
|
||||
|
||||
# Show the full URL in the address bar (note: this still hides the scheme)
|
||||
defaults write com.apple.Safari ShowFullURLInSmartSearchField -bool true
|
||||
|
||||
# Set Safari’s home page to `about:blank` for faster loading
|
||||
defaults write com.apple.Safari HomePage -string "about:blank"
|
||||
|
||||
# Prevent Safari from opening ‘safe’ files automatically after downloading
|
||||
defaults write com.apple.Safari AutoOpenSafeDownloads -bool false
|
||||
|
||||
# Allow hitting the Backspace key to go to the previous page in history
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true
|
||||
|
||||
# Hide Safari’s bookmarks bar by default
|
||||
defaults write com.apple.Safari ShowFavoritesBar -bool false
|
||||
|
||||
# Hide Safari’s sidebar in Top Sites
|
||||
defaults write com.apple.Safari ShowSidebarInTopSites -bool false
|
||||
|
||||
# Disable Safari’s thumbnail cache for History and Top Sites
|
||||
defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2
|
||||
|
||||
# Enable Safari’s debug menu
|
||||
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
|
||||
|
||||
# Make Safari’s search banners default to Contains instead of Starts With
|
||||
defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false
|
||||
|
||||
# Remove useless icons from Safari’s bookmarks bar
|
||||
defaults write com.apple.Safari ProxiesInBookmarksBar "()"
|
||||
|
||||
# Enable the Develop menu and the Web Inspector in Safari
|
||||
defaults write com.apple.Safari IncludeDevelopMenu -bool true
|
||||
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true
|
||||
|
||||
# Add a context menu item for showing the Web Inspector in web views
|
||||
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
|
||||
|
||||
# Enable continuous spellchecking
|
||||
defaults write com.apple.Safari WebContinuousSpellCheckingEnabled -bool true
|
||||
# Disable auto-correct
|
||||
defaults write com.apple.Safari WebAutomaticSpellingCorrectionEnabled -bool false
|
||||
|
||||
# Disable AutoFill
|
||||
defaults write com.apple.Safari AutoFillFromAddressBook -bool false
|
||||
defaults write com.apple.Safari AutoFillPasswords -bool false
|
||||
defaults write com.apple.Safari AutoFillCreditCardData -bool false
|
||||
defaults write com.apple.Safari AutoFillMiscellaneousForms -bool false
|
||||
|
||||
# Warn about fraudulent websites
|
||||
defaults write com.apple.Safari WarnAboutFraudulentWebsites -bool true
|
||||
|
||||
# Disable plug-ins
|
||||
defaults write com.apple.Safari WebKitPluginsEnabled -bool false
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2PluginsEnabled -bool false
|
||||
|
||||
# Disable Java
|
||||
defaults write com.apple.Safari WebKitJavaEnabled -bool false
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaEnabled -bool false
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaEnabledForLocalFiles -bool false
|
||||
|
||||
# Block pop-up windows
|
||||
defaults write com.apple.Safari WebKitJavaScriptCanOpenWindowsAutomatically -bool false
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaScriptCanOpenWindowsAutomatically -bool false
|
||||
|
||||
# Disable auto-playing video
|
||||
#defaults write com.apple.Safari WebKitMediaPlaybackAllowsInline -bool false
|
||||
#defaults write com.apple.SafariTechnologyPreview WebKitMediaPlaybackAllowsInline -bool false
|
||||
#defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2AllowsInlineMediaPlayback -bool false
|
||||
#defaults write com.apple.SafariTechnologyPreview com.apple.Safari.ContentPageGroupIdentifier.WebKit2AllowsInlineMediaPlayback -bool false
|
||||
|
||||
# Enable “Do Not Track”
|
||||
defaults write com.apple.Safari SendDoNotTrackHTTPHeader -bool true
|
||||
|
||||
# Update extensions automatically
|
||||
defaults write com.apple.Safari InstallExtensionUpdatesAutomatically -bool true
|
||||
# Automatically hide and show the Dock
|
||||
|
||||
defaults write com.apple.dock autohide -bool true
|
||||
|
||||
# Don’t show recent applications in Dock
|
||||
defaults write com.apple.dock show-recents -bool false
|
||||
|
||||
|
||||
# Require password immediately after sleep or screen saver begins
|
||||
defaults write com.apple.screencapture location -string "${HOME}/Desktop"
|
||||
defaults write com.apple.screencapture type -string "png"
|
||||
defaults write com.apple.screencapture disable-shadow -bool true
|
||||
defaults write com.apple.screensaver askForPassword -int 1
|
||||
defaults write com.apple.screensaver askForPasswordDelay -int 0
|
||||
|
||||
# Save screenshots to the desktop
|
||||
defaults write com.apple.screencapture location -string "${HOME}/Desktop"
|
||||
|
||||
# Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF)
|
||||
defaults write com.apple.screencapture type -string "png"
|
||||
|
||||
# Disable shadow in screenshots
|
||||
defaults write com.apple.screencapture disable-shadow -bool true
|
||||
|
||||
# Enable subpixel font rendering on non-Apple LCDs
|
||||
# Reference: https://github.com/kevinSuttle/macOS-Defaults/issues/17#issuecomment-266633501
|
||||
defaults write NSGlobalDomain AppleFontSmoothing -int 1
|
||||
|
||||
# Enable HiDPI display modes (requires restart)
|
||||
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool true
|
||||
|
||||
# Disable “natural” (Lion-style) scrolling
|
||||
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false
|
||||
|
||||
# Increase sound quality for Bluetooth headphones/headsets
|
||||
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40
|
||||
|
||||
# Show language menu in the top right corner of the boot screen
|
||||
sudo defaults write /Library/Preferences/com.apple.loginwindow showInputMenu -bool true
|
||||
defaults write com.apple.CrashReporter DialogType none
|
||||
|
||||
# Disable the sound effects on boot
|
||||
sudo nvram SystemAudioVolume=" "
|
||||
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
|
||||
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
|
||||
|
||||
# Disable the “Are you sure you want to open this application?” dialog
|
||||
defaults write com.apple.LaunchServices LSQuarantine -bool false
|
||||
defaults write com.apple.Safari HomePage -string "about:blank"
|
||||
defaults write com.apple.Safari AutoPlayPolicy -int 2
|
||||
defaults write com.apple.Safari UniversalSearchEnabled -bool false
|
||||
defaults write com.apple.Safari SendDoNotTrackHTTPHeader -bool true
|
||||
defaults write com.apple.Safari SuppressSearchSuggestions -bool true
|
||||
defaults write com.apple.Safari WarnAboutFraudulentWebsites -bool true
|
||||
defaults write com.apple.Safari AutoOpenSafeDownloads -bool false
|
||||
defaults write com.apple.Safari ShowFullURLInSmartSearchField -bool true
|
||||
defaults write com.apple.Safari ShowFavoritesBar -bool false
|
||||
defaults write com.apple.Safari ShowSidebarInTopSites -bool false
|
||||
defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2
|
||||
|
||||
defaults write com.apple.Safari InstallExtensionUpdatesAutomatically -bool false
|
||||
|
||||
defaults write com.apple.Safari WebKitJavaScriptCanOpenWindowsAutomatically -bool false
|
||||
|
||||
defaults write com.apple.Safari WebContinuousSpellCheckingEnabled -bool true
|
||||
defaults write com.apple.Safari WebAutomaticSpellingCorrectionEnabled -bool false
|
||||
|
||||
defaults write com.apple.Safari AutoFillFromAddressBook -bool true
|
||||
defaults write com.apple.Safari AutoFillPasswords -bool true
|
||||
defaults write com.apple.Safari AutoFillCreditCardData -bool true
|
||||
defaults write com.apple.Safari AutoFillMiscellaneousForms -bool true
|
||||
|
||||
defaults write com.apple.Safari WebKitJavaScriptCanOpenWindowsAutomatically -bool false
|
||||
|
||||
defaults write com.apple.Safari WebKitTabToLinksPreferenceKey -bool true
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2TabsToLinks -bool true
|
||||
defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true
|
||||
|
||||
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
|
||||
defaults write com.apple.Safari IncludeDevelopMenu -bool true
|
||||
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true
|
||||
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
|
||||
|
||||
killall Dock
|
||||
killall Finder
|
||||
killall Safari 2>/dev/null
|
||||
@@ -1,8 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -uo pipefail
|
||||
|
||||
export PATH="/opt/homebrew/bin:/usr/local/bin:$HOME/.local/bin:$PATH"
|
||||
|
||||
list_sessions() {
|
||||
tmux list-sessions -F '#{session_name}' 2>/dev/null | sed 's/^/@/'
|
||||
}
|
||||
|
||||
@@ -1,188 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Ensure Homebrew and standard paths are accessible inside fzf's preview subshell
|
||||
export PATH="/opt/homebrew/bin:/usr/local/bin:$HOME/.local/bin:$PATH"
|
||||
|
||||
# Tabs definition
|
||||
TABS=("All" "Projects" "Dotfiles" "Blank Session")
|
||||
TOTAL=${#TABS[@]}
|
||||
ACTIVE_TAB=0
|
||||
|
||||
# Terminal Palette Colors for the Tab Header (Ghostty palette 12 and 8)
|
||||
CLR_ACTIVE=$(printf '\033[1;38;5;12m')
|
||||
CLR_INACTIVE=$(printf '\033[38;5;8m')
|
||||
CLR_RESET=$(printf '\033[0m')
|
||||
|
||||
# Dynamic Previewer (Restored exact working structure from your original script)
|
||||
preview_cmd='
|
||||
if [ "{}" = "[Create Blank Session in ~]" ]; then
|
||||
echo "Will spawn an empty session in ~/"
|
||||
elif [ -d {} ]; then
|
||||
if command -v eza >/dev/null 2>&1; then
|
||||
eza --tree --level=2 --icons --color=always --git-ignore -I "node_modules|build|dist|target|.cache" {}
|
||||
elif command -v tree >/dev/null 2>&1; then
|
||||
tree -C -L 2 --gitignore -I "node_modules|build|dist|target|.cache" {}
|
||||
else
|
||||
ls -la --color=always {}
|
||||
fi
|
||||
else
|
||||
tmux list-windows -t {} 2>/dev/null || echo "Session or path: {}"
|
||||
fi'
|
||||
|
||||
get_projects() {
|
||||
if command -v fd &>/dev/null; then
|
||||
[ -d "$HOME/Projects" ] && fd --type d --max-depth 2 . "$HOME/Projects" 2>/dev/null | sed 's:/*$::'
|
||||
[ -d "$HOME/personal/Projects" ] && fd --type d --min-depth 2 --max-depth 2 . "$HOME/personal/Projects" 2>/dev/null | sed 's:/*$::'
|
||||
[ -d "$HOME/personal/Projects_Testing" ] && fd --type d --min-depth 2 --max-depth 2 . "$HOME/personal/Projects_Testing" 2>/dev/null | sed 's:/*$::'
|
||||
else
|
||||
if [ -d "$HOME/Projects" ]; then
|
||||
find "$HOME/Projects" -mindepth 1 -maxdepth 2 \
|
||||
\( -name ".git" -o -name "node_modules" -o -name "build" -o -name ".cache" \) -prune \
|
||||
-o -type d -print 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
if [ -d "$HOME/personal/Projects" ]; then
|
||||
find "$HOME/personal/Projects" -mindepth 2 -maxdepth 2 \
|
||||
\( -name ".git" -o -name "node_modules" -o -name "build" -o -name ".cache" \) -prune \
|
||||
-o -type d -print 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
if [ -d "$HOME/personal/Projects_Testing" ]; then
|
||||
find "$HOME/personal/Projects_Testing" -mindepth 2 -maxdepth 2 \
|
||||
\( -name ".git" -o -name "node_modules" -o -name "build" -o -name ".cache" \) -prune \
|
||||
-o -type d -print 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
get_dotfiles() {
|
||||
if command -v fd &>/dev/null; then
|
||||
# 1. Standard ~/.config/<app>
|
||||
[ -d "$HOME/.config" ] && fd --type d --max-depth 1 . "$HOME/.config" 2>/dev/null | sed 's:/*$::'
|
||||
|
||||
# 2. ~/dotfiles direct packages (e.g. ~/dotfiles/nvim, ~/dotfiles/tmux)
|
||||
# and stow structures (e.g. ~/dotfiles/nvim/.config/nvim or ~/dotfiles/.config/*)
|
||||
if [ -d "$HOME/dotfiles" ]; then
|
||||
# Top-level dotfile modules (depth 1)
|
||||
fd --type d --max-depth 1 . "$HOME/dotfiles" 2>/dev/null | sed 's:/*$::'
|
||||
|
||||
# Unhide and drill down specifically into any .config folders inside dotfiles
|
||||
fd --type d --hidden --no-ignore --max-depth 4 \
|
||||
--full-path '.*/\.config/[^/]+$' "$HOME/dotfiles" 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
else
|
||||
# Fallback using find
|
||||
if [ -d "$HOME/.config" ]; then
|
||||
find "$HOME/.config" -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
if [ -d "$HOME/dotfiles" ]; then
|
||||
# Dotfiles packages + nested .config targets up to 4 levels deep
|
||||
find "$HOME/dotfiles" -mindepth 1 -maxdepth 4 \
|
||||
\( -name ".git" -o -name "node_modules" -o -name ".cache" \) -prune \
|
||||
-o -type d -print 2>/dev/null | grep -E '(dotfiles/[^/]+$|/\.config/[^/]+$)' | sed 's:/*$::'
|
||||
fi
|
||||
fi | sort -u
|
||||
}
|
||||
|
||||
get_items_for_tab() {
|
||||
local tab_idx=$1
|
||||
case "$tab_idx" in
|
||||
1) # Projects only
|
||||
get_projects
|
||||
;;
|
||||
2) # Dotfiles only
|
||||
get_dotfiles
|
||||
;;
|
||||
3) # Blank Session
|
||||
echo "[Create Blank Session in ~]"
|
||||
;;
|
||||
*) # All: tmux sessions + projects + dotfiles + top-level home dirs
|
||||
tmux list-sessions -F "#S" 2>/dev/null
|
||||
get_projects
|
||||
get_dotfiles
|
||||
find "$HOME" -maxdepth 1 -mindepth 1 -type d ! -name "Library" 2>/dev/null | sed 's:/*$::'
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
render_header() {
|
||||
local active=$1
|
||||
local out=""
|
||||
for i in "${!TABS[@]}"; do
|
||||
local name="${TABS[$i]}"
|
||||
if [ "$i" -eq "$active" ]; then
|
||||
out+="${CLR_ACTIVE}[▶ ${name}]${CLR_RESET} "
|
||||
else
|
||||
out+="${CLR_INACTIVE} ${name} ${CLR_RESET} "
|
||||
fi
|
||||
done
|
||||
printf "%s\n" "$out"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Tab Navigation Loop
|
||||
# ---------------------------------------------------------
|
||||
selected=""
|
||||
while true; do
|
||||
fzf_output=$( { render_header "$ACTIVE_TAB"; get_items_for_tab "$ACTIVE_TAB" | grep -v '^$'; } | fzf \
|
||||
--ansi \
|
||||
--header-lines=1 \
|
||||
--expect=tab,btab \
|
||||
--layout=reverse \
|
||||
--border=rounded \
|
||||
--margin=15 \
|
||||
--padding=0 \
|
||||
--height=100% \
|
||||
--prompt=" " \
|
||||
--color="bg:#090E13,bg+:#22262D,fg:#c5c9c7,fg+:#ffffff" \
|
||||
--color="hl:#7fb4ca,hl+:#7fb4ca,prompt:#7fb4ca,pointer:#22262D" \
|
||||
--color="info:#5C6066,spinner:#5C6066,header:#5C6066,border:#2d3139" \
|
||||
--color="label:#7fb4ca" \
|
||||
--preview="$preview_cmd" \
|
||||
--preview-window="right:55%:border-left")
|
||||
|
||||
fzf_status=$?
|
||||
# Cancelled via Escape or Ctrl-C
|
||||
[[ $fzf_status -ne 0 && $fzf_status -ne 1 ]] && exit 0
|
||||
|
||||
key=$(echo "$fzf_output" | head -n 1)
|
||||
selection=$(echo "$fzf_output" | tail -n +2)
|
||||
|
||||
if [ "$key" = "tab" ]; then
|
||||
ACTIVE_TAB=$(( (ACTIVE_TAB + 1) % TOTAL ))
|
||||
elif [ "$key" = "btab" ]; then
|
||||
ACTIVE_TAB=$(( (ACTIVE_TAB - 1 + TOTAL) % TOTAL ))
|
||||
else
|
||||
selected="$selection"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
[[ -z "$selected" ]] && exit 0
|
||||
|
||||
# Strip trailing slash if present
|
||||
selected="${selected%/}"
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Handle Session Creation / Switching
|
||||
# ---------------------------------------------------------
|
||||
if [[ "$selected" == "[Create Blank Session in ~]" ]]; then
|
||||
idx=1
|
||||
while tmux has-session -t "=blank-$idx" 2>/dev/null; do
|
||||
((idx++))
|
||||
done
|
||||
session_name="blank-$idx"
|
||||
tmux new-session -d -s "$session_name" -c "$HOME"
|
||||
elif [[ -d "$selected" ]]; then
|
||||
session_name=$(basename "$selected" | tr '.: ' '_')
|
||||
if ! tmux has-session -t "=$session_name" 2>/dev/null; then
|
||||
tmux new-session -d -s "$session_name" -c "$selected"
|
||||
fi
|
||||
else
|
||||
session_name="$selected"
|
||||
fi
|
||||
|
||||
if [[ -z "$TMUX" ]]; then
|
||||
exec tmux attach-session -t "$session_name"
|
||||
else
|
||||
tmux switch-client -t "$session_name"
|
||||
fi
|
||||
|
||||
+1
-5
@@ -37,10 +37,6 @@ export HOMEBREW_NO_EMOJI=1
|
||||
|
||||
[ -s "$HOME/.bun/_bun" ] && source "$HOME/.bun/_bun"
|
||||
|
||||
export PATH="$BUN_INSTALL/bin:$PATH"
|
||||
export PATH="/opt/homebrew/opt/ruby/bin:$PATH"
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
export PATH="$HOME/go/bin:$PATH"
|
||||
export PATH="$HOME/go/bin/my-bin:$PATH"
|
||||
export PATH="$BUN_INSTALL/bin:/opt/homebrew/opt/ruby/bin:$HOME/.local/bin:$HOME/go/bin:$HOME/go/bin/my-bin:$PATH"
|
||||
export LDFLAGS="-L/opt/homebrew/opt/ruby/lib"
|
||||
export CPPFLAGS="-I/opt/homebrew/opt/ruby/include"
|
||||
Reference in new issue
Block a user