-
Notifications
You must be signed in to change notification settings - Fork 0
/
shellfn
56 lines (46 loc) · 2.23 KB
/
shellfn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#########################################
# Utility Functions
# Create a new git repo with one README commit and CD into it
function gitnr() { mkdir $1; cd $1; git init; touch README; git add README; git commit -mFirst-commit;}
# Do a Matrix movie effect of falling characters
function matrix1() {
echo -e "\e[1;40m" ; clear ; while :; do echo $LINES $COLUMNS $(( $RANDOM % $COLUMNS)) $(( $RANDOM % 72 )) ;sleep 0.05; done|gawk '{ letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()"; c=$4; letter=substr(letters,c,1);a[$3]=0;for (x in a) {o=a[x];a[x]=a[x]+1; printf "\033[%s;%sH\033[2;32m%s",o,x,letter; printf "\033[%s;%sH\033[1;37m%s\033[0;0H",a[x],x,letter;if (a[x] >= $1) { a[x]=0; } }}'
}
function matrix2() {
echo -e "\e[1;40m" ; clear ; characters=$( jot -c 94 33 | tr -d '\n' ) ; while :; do echo $LINES $COLUMNS $(( $RANDOM % $COLUMNS)) $(( $RANDOM % 72 )) $characters ;sleep 0.05; done|gawk '{ letters=$5; c=$4; letter=substr(letters,c,1);a[$3]=0;for (x in a) {o=a[x];a[x]=a[x]+1; printf "\033[%s;%sH\033[2;32m%s",o,x,letter; printf "\033[%s;%sH\033[1;37m%s\033[0;0H",a[x],x,letter;if (a[x] >= $1) { a[x]=0; } }}'
}
function tmx() {
$( tmux attach-session -t $1 || tmux new-session -s $1 )
}
# Use Mac OSX Preview to open a man page in a more handsome format
function manp() {
man -t $1 | open -f -a /Applications/Preview.app
}
# Show normally hidden system and dotfile types of files
# in Mac OSX Finder
function showhiddenfiles() {
defaults write com.apple.Finder AppleShowAllFiles YES
osascript -e 'tell application "Finder" to quit'
sleep 0.25
osascript -e 'tell application "Finder" to activate'
}
# Hide (back to defaults) normally hidden system and dotfile types of files
# in Mac OSX Finder
function hidehiddenfiles() {
defaults write com.apple.Finder AppleShowAllFiles NO
osascript -e 'tell application "Finder" to quit'
sleep 0.25
osascript -e 'tell application "Finder" to activate'
}
# kill all instances of a process by name
function skill()
{
sudo kill -9 `ps ax | grep $1 | grep -v grep | awk '{print $1}'`
}
function schef()
{
sudo chef-client
}
function fixperms(){
find . \( -name "*.sh" -or -type d \) -exec chmod 755 {} \; && find . -type f ! -name "*.sh" -exec chmod 644 {} \;
}