mirror of
https://git.decapod.one/brethil/dotfiles
synced 2024-11-22 03:21:30 +01:00
zsh: cleanup functions
This commit is contained in:
parent
476fd545b5
commit
c6d444c709
|
@ -166,54 +166,33 @@ function list_functions
|
|||
}
|
||||
|
||||
|
||||
###########################
|
||||
## MAC SPECIFIC #
|
||||
###########################
|
||||
|
||||
# MacOS only
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
## Create a RAM disk. Default size 1GB. If supplied, first argument defines the RAM disk size in GB
|
||||
function ramdisk
|
||||
{
|
||||
if [[ -e $1 ]]; then
|
||||
sizeingb=$1
|
||||
else
|
||||
sizeingb=1
|
||||
fi
|
||||
## Create a RAM disk. Default size 1GB. If supplied, first argument defines the RAM disk size in GB
|
||||
function ramdisk
|
||||
{
|
||||
if [[ -e $1 ]]; then
|
||||
sizeingb=$1
|
||||
else
|
||||
sizeingb=1
|
||||
fi
|
||||
|
||||
# Numsectors is size in bytes / 512 (sector size in bytes)
|
||||
name='RAM_disk'
|
||||
sizeinbytes=$(($sizeingb*1000**3))
|
||||
NUMSECTORS=$(($sizeinbytes/512))
|
||||
mydev=$(hdiutil attach -nomount ram://$NUMSECTORS )
|
||||
# strip whitespace (hdiutil outputs a lot of spaces/tabs along with the device name)
|
||||
mydev=$(echo "$mydev"| xargs echo)
|
||||
newfs_hfs "$mydev"
|
||||
mkdir -p "/tmp/$name"
|
||||
mount -t hfs "$mydev" "/tmp/$name"
|
||||
echo "RAM Disk mounted: /tmp/$name"
|
||||
echo "To eject (destroy) RAM disk, use:"
|
||||
echo " $ diskutil eject $mydev"
|
||||
}
|
||||
|
||||
## Open a pdf version of the man in Preview
|
||||
function man2pdf
|
||||
{
|
||||
man -t "$1" | open -f -a Preview
|
||||
}
|
||||
|
||||
## Open Man in separate (different-looking) window
|
||||
function nman
|
||||
{
|
||||
if [ $# -eq 1 ] ; then
|
||||
open "x-man-page://$1"
|
||||
elif [ $# -eq 2 ] ; then
|
||||
open "x-man-page://$1/$2"
|
||||
fi
|
||||
}
|
||||
# Numsectors is size in bytes / 512 (sector size in bytes)
|
||||
name='RAM_disk'
|
||||
sizeinbytes=$(($sizeingb*1000**3))
|
||||
NUMSECTORS=$(($sizeinbytes/512))
|
||||
mydev=$(hdiutil attach -nomount ram://$NUMSECTORS )
|
||||
# strip whitespace (hdiutil outputs a lot of spaces/tabs along with the device name)
|
||||
mydev=$(echo "$mydev"| xargs echo)
|
||||
newfs_hfs "$mydev"
|
||||
mkdir -p "/tmp/$name"
|
||||
mount -t hfs "$mydev" "/tmp/$name"
|
||||
echo "RAM Disk mounted: /tmp/$name"
|
||||
echo "To eject (destroy) RAM disk, use:"
|
||||
echo " $ diskutil eject $mydev"
|
||||
}
|
||||
fi
|
||||
|
||||
### end of mac-specific functions
|
||||
|
||||
pipupdate(){
|
||||
set -x
|
||||
if [[ "$1" == "user" ]]; then
|
||||
|
|
Loading…
Reference in New Issue
Block a user