code stringlengths 1 1.96M | language stringclasses 1
value |
|---|---|
#!/bin/zsh -f
command defaults write com.apple.dashboard mcx-disabled -boolean YES
command killall Dock
return 0
| Shell |
#!/bin/zsh -f
# bitrot
version="0.1.7"
# Revision history:
# 0.1.7 De-write-protect and reprotect after adding hashtags if needed.
# 0.1.6 Warn or add missing hashtags.
# 0.1.5 Provide example launchd plist file in comments section.
# If a discrepency is... | Shell |
#!/bin/zsh -f
version="2.0.0"
# The script must be run as an admin user
#
if [[ -z $(/usr/bin/id -p $USER | grep admin) ]];then
print "You must be an administrative user with sudo privileges in order to run $0"
fi
# For 10.5: Eliminated niutil commands in favor of Directory Service
# Obtained and modified from a... | Shell |
#!/bin/zsh -f
# sudo_open takes a filename as an argument and allows you to select a
# Cocoa or unix application with which to open your file using sudo.
################################################################################
################################################################################... | Shell |
#!/bin/zsh -f
cd "$(posd)"
pwd
| Shell |
#!/bin/zsh -f
command open http://xanana.ucsc.edu/xtal/wiki/index.php/ZSH_on_OS_X
return $?
| Shell |
#!/bin/zsh -f
osascript <<-eof
tell app "Finder"
activate
set f to POSIX path of ((choose file with prompt \
"Select a file:\
$Example") as string)
end
eof
| Shell |
#!/bin/zsh -f
# llock: List all locked files in subdirectories of the argument
command find $* -exec GetFileInfo {} \; | command sed -n -e '/file/{h;}' -e '/attribute.*L/{g;p;}'
| Shell |
#!/bin/zsh -f
# Execute a command in the same directory but in a new tab
if [[ $TERM_PROGRAM != iTerm.app ]]; then
open -a Terminal
return 0
fi
# First, get the directory for the new tab
ThisDirectory=$PWD
if [[ $# == 0 ]]; then
print "usage: $0 [commands]"
return 1
fi
osascript <<-eof
tel... | Shell |
#!/bin/zsh -f
#
# mailit
#
# Use the perl mail drop in replacement to send mail by command line
# http://www.cs.cornell.edu/nystrom/macscripts/mail.txt
# Prompt user for email address, subject, and attachments
# Usage: mailit [recipient@address.com] [attachment.file] ["subject line"]
# initialize
recipientaddres... | Shell |
#!/bin/zsh -f
if [[ $(uname) != "Darwin" ]]; then
print "This function is specific to OS X"
return 1
fi
if [[ $( defaults read com.apple.dock workspaces ) = 1 ]]; then
defaults write com.apple.dock workspaces -bool false
killall Dock
print "\e[1m Turning \"Spaces\" off. \e[0m "
elif [[ $(... | Shell |
#!/bin/zsh
# sd: switch desktops (using CodeTek virtual desktops or Virtue).
# set -x
##########################################################################
##########################################################################
function DesktopsRunning {
cvd_process=( $(ps -ax | grep "VirtualDesktop... | Shell |
#!/bin/zsh -f
# shell script name cdleft: cd to the directory displayed on the left panel of ForkLift
version="0.0.1"
# Please note that this is not flawless, as it takes awhile for the plist file to update.
###############################################################################
# Created by on .
# ... | Shell |
#!/bin/zsh -f
# aeon: toggle AppleEvent logging on or off
if [ -z "$AEDebug" ]; then
export AEDebug=1 AEDebugSend=1 AEDebugReceives=1;
else
unset AEDebug AEDebugSend AEDebugReceives;
fi
| Shell |
#!/bin/zsh -f
# whichfunctions -a lists completions and functions
# whichfunctions -f lists functions but not completions
# whichfunctions -c lists only completion functions
if [[ $1 == '-f' ]]; then
function whichfunctions { command functions | command grep "()" | /usr/bin/awk '{print $1}' \
... | Shell |
#!/bin/zsh -f
if [[ -z $prompt_text ]];then
prompt_text=( Choose an item: )
fi
# Thanks to Gary Kerbaugh for the next five lines
list_items=""
# for argument in "$@"; do
# list_items=${list_items}\"${argument}'", '
# done
# list_items=${list_items%, }
# Thanks to Daniel... | Shell |
#!/bin/zsh -f
# Get the directory for the new tab or terminal window
if [[ $# == 0 ]]; then
ThisDirectory=$PWD
elif [[ $# == 1 && -d "$1" ]]; then
ThisDirectory="$@"
else
print "usage: ntrm [directory]"
return 1
fi
if [[ $TERM_PROGRAM == Apple_Terminal ]]... | Shell |
#!/bin/zsh -f
# FILE NAME addIcon
# Uses /usr/bin/sips --addIcon but preserves the original file creation date.
version="0.0.1"
###############################################################################
# Created by on .
# Copyright (c) . All rights reserved.
# This program is free software;... | Shell |
#!/bin/zsh -f
# Parts of this come from Apple's NFS startup file, modified
# by W. G. Scott and many important improvements were then
# added by Gary Kerbaugh. Specifically, the script now checks
# for successful outcome of disk arbitration, which can take
# awhile for really big disks and RAID devices.
# This is a ... | Shell |
#!/bin/zsh -f
# cdd: change the Finder directory along with the pwd
function cdd { command cd "$@" ; ( fdc >|/dev/null & ) }
| Shell |
#!/bin/zsh -f
# set -x
# Start a full-screen xwindowmanager session but in a nested window.
###############################################################################
# Do some reality checks:
if [[ ! -x $(which Xnest) && ! -x /usr/X11/bin/Xephyr ]];then
print "Xnest and Xephyr do not appear to be on th... | Shell |
#!/bin/zsh -f
autoload -U pashua_run
VERSION='0.0.1'
# May 11, 2007
# configure_zsh_templates_gui
# shell script name shell script function
version="0.0.1"
###############################################################################
# Created by William Scott on May 11, 2007.
# Copyright (c) 2007. All r... | Shell |
#!/bin/zsh -f
# The _open completion function in 10.4 should work very quickly. If it doesn't, this
# may be due to indexing being turned off for the root partition. If we are running 10.4
# check to see if indexing is disabled. If it is disabled, turn it on.
if [[ $(whereis mdfind) == /usr/bin/mdfind ]];then
if... | Shell |
#!/bin/zsh -f
# mybom: lsbom the listed package with the given arguments
lsbom -p sfMUG /Library/Receipts/*"$1"*.pkg/Contents/Archive.bom;
| Shell |
#!/bin/zsh -f
osascript -e "tell app \"Finder\" to empty trash"
| Shell |
#!/bin/zsh -f
# Function to run a program in an 8-bit (256 colors) X11 display
# without disturbing the default 24-bit X11.
# Created by William Scott on 2007-04-26.
# Copyright (c) 2007. All rights reserved.
version="0.0.1"
# Check to make sure /usr/X11R6/bin/Xquartz is present
if [[ ! -x /usr/X11R6/bin/Xqua... | Shell |
#!/bin/zsh -f
# set -x
#######################################################################
## host_setup ##
## ##
## by Wataru Kagawa ##
## Marc... | Shell |
#!/bin/zsh -f
prompt_text="Select Xwindow to focus:"
# Associative array key-value pairs:
typeset -A windowarray
windowarray=($( xwininfo -root -children -tree | awk '! NF == 0' | \
awk '! /(has no name|0x0|child|\"mozilla-bin\"\:|\"firefox-bin\"\:)/ {y = NF-3; print $1 " " $y}' | \
perl -p -e 's|[\",\(]||... | Shell |
#!/bin/zsh -f
###############
# finder_update
###############
#-------------------------------------------------------
# function to update desktop and all open Finder windows
#-------------------------------------------------------
function finder_update {
osascript <<-eof
tell application "Finder"
update... | Shell |
#!/bin/zsh -f
command defaults write com.apple.dashboard mcx-disabled -boolean NO
command killall Dock
return 0
| Shell |
#!/bin/zsh -f
# spath, when issued from the command prompt in Terminal, iTerm, or xterm, will
# copy the directory corresponding to the web page displayed in Safari into the
# clip-board paste buffer and will assign the variable SPATH to that directory.
# Put your top-level server directory here:
if [[ -z $PUBLI... | Shell |
#!/bin/zsh -f
# pbcp: copy the output of a command to the clipboard and to stdout
eval "$* | tee /dev/tty | pbcopy"
| Shell |
#!/bin/zsh -f
# shell script name acl_adduser
# An acl nuclear option to give access to user $1 to the directory tree rooted at $2.
version="0.0.1"
###############################################################################
# Created by wgscott on 1 August 2009.
# Copyright (c) . All rights reserved.
#... | Shell |
#!/bin/zsh -f
# function to start the screensaver (and thereby lock the screen if you have set this up)
open /System/Library/Frameworks/Screensaver.framework/Versions/A/Resources/ScreenSaverEngine.app "$@"
return $?
| Shell |
#!/bin/zsh -f
if [[ $(uname) != Darwin ]]; then
# Don't try this if we are not using OS X
print "\e[1m This only works on Mac OS X. \e[0m "
return 1
fi
# function osa_display_dialog takes up to three arguments (button item options)
# supplied after invoking the function.
function osa_display_dialog {
# Disp... | Shell |
#!/bin/zsh -f
# cdt:
# change the current working directory to that corresponding to the file displayed in Textmate's frontmost window
# change this and the Finder (-F)
# change the finder only (-f)
DocPath="$(osascript -e 'tell app "TextMate" to return path of first document')"
DocDir="$(dirname "$DocPath")"
print... | Shell |
#!/bin/zsh -f
# Use ghostscript to join pdf file 1, 2, ..., N together and output one file named merged.pdf
#
function joinpdf {
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged.pdf "$@"
}
| Shell |
#!/bin/zsh -f
command ps -axww | grep -v "awk" | awk -F" " "/$1/{ print \$1 } "
| Shell |
#!/bin/zsh -f
# alias showargs="printf '>>> %s <<<\n'"
testvar='one two'
print "element one $testvar[1] element two $testvar[2]"
setopt sh_word_split
print "element one $testvar[1] element two $testvar[2]"
| Shell |
#!/bin/zsh -f
#
# Function to invoke sudo vi if it is needed to edit a protected file
#
LIMIT=$#
for ((i = 1; i <= $LIMIT; i++ )) do
eval file="\$$i"
if [[ -e $file && ! -O $file ]]; then
otherfile=1
else
fi
done
if [[ $otherfile = 1 ]]; then
echo -ne "\e]1; vi $@\a"; ... | Shell |
#!/bin/zsh
# use this in conjunction with the local functions
# called chpwd and dirstack
# In an attempt to have a shared directory stack (i.e.,
# shared between different shell sessions), this appends
# the pwd onto the bottom of a file called ~/.zsh/zdirdump
print ${PWD// /_SPACE_} >>| ~/.zsh/zdirdump
... | Shell |
#!/bin/zsh -f
# function to settab to show the named process running and then reset with settab
# for command screen
echo -ne "\e]1; screen: $2 \a"; command screen -h 10000 "$@"; settab
| Shell |
#!/bin/zsh -f
# renice_grep: renice by string
proc=$( ps -auxww | grep -i "${2}" | grep -v "[p ]grep" | awk '{ print $2 }' );
renice "${1}" -p "$proc";
| Shell |
#!/bin/zsh
# usage: dirstack [n]
# n = # of lines of directory stack printed
# if n is not given, default to 20
# command to update and then print out the shared directory stack
# aliases a series of cd-type commands corresponding to the line
# number in the directory stack printout
# eg:
# cd7 will cd to t... | Shell |
#!/bin/zsh -f
command find / -name "*${1}*" -print 2>/dev/null
| Shell |
#!/bin/zsh -f
################################################################
# prompt v0.0.2 for use with zsh
# slight modifications by W G Scott
# to prevent clobbering precmd
# prompt v0.0.1 for use with Bash on Darwin-OSX ......
# by Gary Kerbaugh
# Send comments, bugs or money to gkerbaugh@nc.rr.com
#
# Source t... | Shell |
#!/bin/zsh -f
command jobs -s | wc -l | awk '{print $1}'
| Shell |
#!/bin/zsh -f
# function function_content
# list the argument(s) of a supplied function.
if [[ $# == 1 ]];then
# strip off the first and last lines of the output
command functions $1 | command grep -v "$1 ()" | sed '$d'
return 0
else
print "Usage: function_content [name_of_function] "
return 1
fi
| Shell |
#!/bin/zsh -f
command history 1 | grep -i "${1}" | grep -v "[hp ]grep"
| Shell |
#!/bin/zsh -f
command find / -name "${1}" -print 2>/dev/null
| Shell |
#!/bin/zsh -f
# envgrep: grep the output of set
function envgrep { set | grep -i --binary-files=text "$1" | grep -v "\(_c\omps\|p\orts\)"; }
| Shell |
#!/bin/zsh
#
# Figure out where to get the best help, and get it.
#
# Install this function by placing it in your FPATH and then
# adding to your .zshrc the lines:
# unalias run-help
# autoload run-help
#
# set -x
emulate -R zsh
setopt localoptions
[[ $1 == "." ]] && 1="dot"
[[ $1 == ":" ]] && 1="colon"
helppath... | Shell |
#!/bin/zsh -f
# find duplicate files on specified directory tree
# Author: Karl Zimmerman
osize=0
osum=0
ofile=""
newFile () {
osum="${1}"
osize="${2}"
ofile="${3}"
}
find "${1}" -type f -exec sum {} \; 2>/dev/null | sort | while read sum size file; do
[ ${osize} != ${size} ] && newFile ${su... | Shell |
#!/bin/zsh -f
# dotgrep: grep through invisible files for arguments
command ls -A1 | sed -n '/^\./p' | xargs -n1 grep -iInH "$1";
| Shell |
#!/bin/zsh -f
command history 1 | grep -i "${1}" | grep -v "[hp ]grep"
| Shell |
#!/bin/zsh -f
################################################################
# prompt v0.0.2 for use with zsh
# slight modifications by W G Scott
# to prevent clobbering precmd
# prompt v0.0.1 for use with Bash on Darwin-OSX ......
# by Gary Kerbaugh
# Send comments, bugs or money to gkerbaugh@nc.rr.com
#
# Source t... | Shell |
#!/bin/zsh -f
#
# Function to invoke sudo gvim if it is needed to edit a protected file
#
#
LIMIT=$#
for ((i = 1; i <= $LIMIT; i++ )) do
eval file="\$$i"
if [[ -e $file && ! -O $file ]]; then
otherfile=1
else
fi
done
if [[ $otherfile = 1 ]]; then
echo -ne "\e]1; sudo gvi... | Shell |
#!/bin/zsh -f
command find / -name "*${1}*" -print 2>/dev/null
| Shell |
#!/bin/zsh -f
# lgrep: grep the output of locate to match only the file part of the path
command locate "$1" | grep -i ".*/[^/]*$1[^/]*$";
| Shell |
#!/bin/zsh -f
# Use ghostscript to join pdf file 1, 2, ..., N together and output one file named merged.pdf
#
function joinpdf {
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged.pdf "$@"
}
| Shell |
#!/bin/zsh -f
# alias showargs="printf '>>> %s <<<\n'"
testvar='one two'
print "element one $testvar[1] element two $testvar[2]"
setopt sh_word_split
print "element one $testvar[1] element two $testvar[2]"
| Shell |
#!/bin/zsh -f
command jobs -s | wc -l | awk '{print $1}'
| Shell |
#!/bin/zsh -f
command ps -axww | grep -v "awk" | awk -F" " "/$1/{ print \$1 } "
| Shell |
#!/bin/zsh -f
# Make an image file transparent, saving a backup.
if [[ $(which convert) == *not\ found* ]];then
print "Cannot find ImageMagick convert command"
return 1
fi
foreach imagefile in "$@"
cp $imagefile $imagefile.bak
convert -transparent white $imagefile /tmp/$imagefile
cp /tmp/$image... | Shell |
#!/bin/zsh -f
command ls $* | xargs -n 1 tar -zxvf
| Shell |
#!/bin/zsh -f
# function to settab to show the named process running and then reset with settab
# for command screen
echo -ne "\e]1; screen: $2 \a"; command screen -h 10000 "$@"; settab
| Shell |
#!/bin/zsh
# usage: dirstack [n]
# n = # of lines of directory stack printed
# if n is not given, default to 20
# command to update and then print out the shared directory stack
# aliases a series of cd-type commands corresponding to the line
# number in the directory stack printout
# eg:
# cd7 will cd to t... | Shell |
#!/bin/zsh -f
# envgrep: grep the output of set
function envgrep { set | grep -i --binary-files=text "$1" | grep -v "\(_c\omps\|p\orts\)"; }
| Shell |
#!/bin/zsh -f
# ppath: list the Perl #INC path
perl -e 'print map "$_\n", @INC'
| Shell |
#!/bin/zsh -f
#
# Function to invoke sudo vi if it is needed to edit a protected file
#
LIMIT=$#
for ((i = 1; i <= $LIMIT; i++ )) do
eval file="\$$i"
if [[ -e $file && ! -O $file ]]; then
otherfile=1
else
fi
done
if [[ $otherfile = 1 ]]; then
echo -ne "\e]1; vi $@\a"; ... | Shell |
#!/bin/zsh -f
# whichre: search for commands using regular expressions
command echo $PATH | awk 'BEGIN{ RS = ":" } { print }' | xargs ls | grep "$1";
| Shell |
#!/bin/zsh -f
# killit: lookup pid of the argument and kill it
ps -auxww | awk /"$1"/'{ if ( $0 !~ "awk" && $2 > 200 ) print $2 }' | xargs kill
| Shell |
#!/bin/zsh -f
# renice_grep: renice by string
proc=$( ps -auxww | grep -i "${2}" | grep -v "[p ]grep" | awk '{ print $2 }' );
renice "${1}" -p "$proc";
| Shell |
#!/bin/zsh -f
command ls -AFlh ${1} | grep "^d"
| Shell |
#!/bin/zsh -f
# prompt_simple_setup
# Create a simple minimal prompt (eg: zsh-%), and put the other usual stuff
# into the title bar (and if availble) the $PWD and penultimate directory
# in the tab. Also enable transient display of a running command (eg vim).
# Currently works with iTerm (OSX) and konsole (KDE)... | Shell |
#!/bin/zsh -f
command ps -auxww | command grep -i "${1}" | command grep -v "[p ]grep"
| Shell |
#!/bin/zsh -f
# Bug: I can't get this to work for directories with spaces.
# cd $_ will work fine for those cases.
# Execute cd "$(dirname $_)" if $_ is a file
# Execute cd "$_" if $_ is a directory
# or, more generally, get the numbered string position in the last line and cd to it (or it's directory)
# eg:
# l... | Shell |
#!/bin/zsh -f
# invoke tidy to do in-place cleanup and conversion to xhtml
if [[ "$@":e == xml ]];then
command tidy -m -xml "$@"
else
command tidy -m -asxml "$@"
fi
| Shell |
#!/bin/zsh -f
# locwd: locate files that match exactly
function locwd { locate "*/${@}"; }
| Shell |
#!/bin/zsh -f
#
# Function to invoke sudo vim with a .vimrc file if it is needed to edit a protected file
#
# set -x # uncomment to debug
version="2.0.1"
###############################################################################
function resetter {
# re-initialize everything:
unset i
binplistfile=""
o... | Shell |
#!/bin/zsh -f
# function function_content
# list the argument(s) of a supplied function.
if [[ $# == 1 ]];then
# strip off the first and last lines of the output
command functions $1 | command grep -v "$1 ()" | sed '$d'
return 0
else
print "Usage: function_content [name_of_function] "
return 1
fi
| Shell |
#!/bin/zsh -f
command find / -name "${1}" -print 2>/dev/null
| Shell |
#!/bin/zsh -f
# sgrep: grep the output of set
set | grep -i --binary-files=text "$1"
| Shell |
#!/bin/zsh -f
# This is the successor to settab and settitle functions (as well as the chpwd function).
# It avoids the explicit definition and use of special functions such as
# chpwd, precmd, preexec, instead setting appropriate arrays. This is to prevent conflicts
# with user's prompt functions and so forth.
# T... | Shell |
#!/bin/zsh -f
command grep -i "[ -]${1}[ ,]" /System/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks/CarbonCore.framework/Versions/Current/Headers/MacErrors.h
| Shell |
#!/bin/zsh -f
command osascript -e 'open location "$1"'
| Shell |
#!/bin/zsh -f
ssh -f -Y "$@"
remoteargs=( "$@" )
print
print " Running \e[1m $remoteargs[2,-1] \e[0m on $1 \e[1m "
print ""
sleep 4
print "\e[0m "
print " Returning to $HOST:r:r:r "
print ""
| Shell |
#!/bin/zsh
# use this in conjunction with the local functions
# called chpwd and dirstack
# In an attempt to have a shared directory stack (i.e.,
# shared between different shell sessions), this appends
# the pwd onto the bottom of a file called ~/.zsh/zdirdump
print ${PWD// /_SPACE_} >>| ~/.zsh/zdirdump
... | Shell |
#!/bin/zsh -f
# txtgrep: grep only text files
command grep -in "$1" `file "${2}"/* | egrep 'script|text' | awk -F: '{print $1}'`;
| Shell |
#!/bin/zsh -f
# dusize: use du to get filesizes and sum them in awk
# functin dusize {
command du "$@" | command awk '{ fsize += $1 } END { print fsize/1024 " Megabytes" }'
#}
| Shell |
#!/bin/zsh -f
# Created by William Scott on 2007-05-03.
# Copyright (c) 2007. All rights reserved.
version="0.0.2"
# set -x
# depfinder
# Look at the contents of a debian package and find the dependencies.
###############################################################################
# Created by on .
# ... | Shell |
#!/bin/zsh -f
#
# Function to invoke sudo gvim if it is needed to edit a protected file
#
#
LIMIT=$#
for ((i = 1; i <= $LIMIT; i++ )) do
eval file="\$$i"
if [[ -e $file && ! -O $file ]]; then
otherfile=1
else
fi
done
if [[ $otherfile = 1 ]]; then
echo -ne "\e]1; sudo gvi... | Shell |
#!/bin/zsh -f
ssh -f -Y "$@"
remoteargs=( "$@" )
print
print " Running \e[1m $remoteargs[2,-1] \e[0m on $1 \e[1m "
print ""
sleep 4
print "\e[0m "
print " Returning to $HOST:r:r:r "
print ""
| Shell |
#!/bin/zsh -f
command grep -i "[ -]${1}[ ,]" /System/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks/CarbonCore.framework/Versions/Current/Headers/MacErrors.h
| Shell |
#!/bin/zsh -f
# dusize: use du to get filesizes and sum them in awk
# functin dusize {
command du "$@" | command awk '{ fsize += $1 } END { print fsize/1024 " Megabytes" }'
#}
| Shell |
#!/bin/zsh
#
# Figure out where to get the best help, and get it.
#
# Install this function by placing it in your FPATH and then
# adding to your .zshrc the lines:
# unalias run-help
# autoload run-help
#
# set -x
emulate -R zsh
setopt localoptions
[[ $1 == "." ]] && 1="dot"
[[ $1 == ":" ]] && 1="colon"
helppath... | Shell |
#!/bin/zsh -f
command ls -AFlh ${1} | grep "^d"
| Shell |
#!/bin/zsh -f
# This is the successor to settab and settitle functions (as well as the chpwd function).
# It avoids the explicit definition and use of special functions such as
# chpwd, precmd, preexec, instead setting appropriate arrays. This is to prevent conflicts
# with user's prompt functions and so forth.
# T... | Shell |
#!/bin/zsh -f
# lgrep: grep the output of locate to match only the file part of the path
command locate "$1" | grep -i ".*/[^/]*$1[^/]*$";
| Shell |
#!/bin/zsh -f
# killit: lookup pid of the argument and kill it
ps -auxww | awk /"$1"/'{ if ( $0 !~ "awk" && $2 > 200 ) print $2 }' | xargs kill
| Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.