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