Skip to content

Instantly share code, notes, and snippets.

@sellmerfud
sellmerfud / promptMenuSH.sh
Created September 14, 2023 23:03
Bourne shell function to prompt using a menu
#! /usr/bin/env sh
# Present a menu and prompt user to select one of the given options.
#
# usage:
# prompt_menu "<choices>" "<cols>:<width>" prompt="Choose one: " delim=":"
# $1 - choices
# contains the values to be seleted separated by newlines
# Optionally, each value can be followed by a User friendly label that will
@sellmerfud
sellmerfud / promptMenu.sh
Last active September 15, 2023 00:06
Bash function to prompt using a menu
#! /usr/bin/env bash
# Present a menu and prompt user to select one of the given options.
#
# usage:
# prompt_menu "<choices>" "<cols>:<width>" prompt="Choose one: " delim=":"
# $1 - choices
# contains the values to be seleted separated by newlines
# Optionally, each value can be followed by a User friendly label that will
# be displayed for that value. The label if present must be appened to the value
# Basic Settings
# windowTitleSCM can also be used and will display the current scm branch if an SCM is in use
# for the current project.
#windowTitle = "$TM_DISPLAYNAME — ${TM_DIRECTORY/^.*\///}"
windowTitle = "$TM_DISPLAYNAME${TM_DIRECTORY/\A(?:\/Users\/curt\/dev\/(?=\b(?:roc|projects|playground)\b)\w+\/?(.*)|(.+))\z/${2:? – ${2/\/Users\/curt/~/}:${1/\A(?=.)/ – /}}/}"
# projectDirectory = "$CWD"
fontName = "consolas"
@sellmerfud
sellmerfud / scala-align.rb
Created November 9, 2013 14:26
Textmate align command for scala Adapted from the align bundle. Handles alignment on =>, =, ->, <-
#!/usr/bin/env ruby
#
# Scala alignment command.
#
# This script will attempt to align lines of scala code around one of the following
# symbols:
# case symbol: =>
# assignment: =
# right arrow: ->
# left arrow: <-
@sellmerfud
sellmerfud / gist:6466066
Created September 6, 2013 16:10
Automatically restart shell script as root using sudo.
# Place this at the top of your script.
# The exit $? causes the shell to exit with the
# status of the script instance that is run with sudo.
if [[ $UID -ne 0 ]]; then
sudo -p "Restarting as root, password for %p: " bash $0 "$@"
exit $?
fi
@sellmerfud
sellmerfud / var-from-selection.tmCommand
Created August 30, 2012 22:47
Textmate bundle command to create a variable declaration with the contents of the selection.
#!/usr/bin/env ruby -wKU
# Save: Nothing
# Input: Document
# Output: Replace Input
# Caret Placement: Line Interpolation
COCOA_DIALOG_COMMAND = "#{ENV["TM_SUPPORT_PATH"]}/bin/CocoaDialog.app/Contents/MacOS/CocoaDialog"