-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctions.zsh
More file actions
87 lines (71 loc) · 2.03 KB
/
Copy pathfunctions.zsh
File metadata and controls
87 lines (71 loc) · 2.03 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Functions
#
# Any extra shell functions should live here. I guess this
# could go in aliases.zsh, but heh.
function take() {
[[ -n $1 ]] && mkdir -p -- "$1" && builtin cd -- "$1"
}
# Update the software from major package managers and the base OS
function updatesoftware() {
local now
function _us_header() {
now=$(date +"%H:%M:%S")
echo
echo "==> [$now] $1"
}
# Update zimfw and its modules
if type zimfw >/dev/null 2>&1; then
_us_header "Updating zimfw and modules"
zimfw update
else
_us_header "Skipping zimfw (not installed)"
fi
# Upgrade Homebrew
if hash brew 2>/dev/null; then
_us_header "Upgrading Homebrew, packages and casks"
brew update
brew upgrade
else
_us_header "Skipping Homebrew (not installed)"
fi
# Update Debian based OS
if hash apt-get 2>/dev/null; then
_us_header "Updating OS via apt"
sudo apt-get update && sudo apt-get upgrade -y
_us_header "Cleaning up apt packages"
sudo apt-get autoremove -y
fi
# Update Redhat based OS
if hash yum 2>/dev/null; then
_us_header "Updating OS via yum"
sudo yum update -y
fi
}
# Reset changes in a git repository with a confirmation prompt
function nah() {
if ! hash git 2>/dev/null; then
return 1
fi
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "Not a git repository."
return 1
fi
echo "This will run: git reset --hard; git clean -df"
read -r "reply?Type 'yes' to continue: "
if [[ $reply == "yes" ]]; then
git reset --hard
git clean -df
else
echo "Aborted."
fi
}
# Create a new encrypted vol
function newcryptvol () {
if hash hdiutil 2>/dev/null; then
local vol=$1
echo "Creating new volume: $vol"
hdiutil create -size 15GB -encryption AES-256 -type SPARSE -fs apfs -volname "$vol" $vol
else
echo "Could not find hdiutil, this is probably not macOS"
fi
}