mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 14:12:41 +00:00
Cleaning up some scripts and moving to autoload functions
This commit is contained in:
6
zsh/config/functions/cdots
Executable file
6
zsh/config/functions/cdots
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
function cdots() {
|
||||
"$SCRIPTS/tmux-sessionator" "$DOTFILES"
|
||||
}
|
||||
|
||||
8
zsh/config/functions/chmox
Executable file
8
zsh/config/functions/chmox
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/zsh
|
||||
|
||||
# makes files executable
|
||||
|
||||
function chmox() {
|
||||
[ ! -f "$1" ] && echo "usage: chmox <file>" && return 1
|
||||
chmod u+x "$1"
|
||||
}
|
||||
7
zsh/config/functions/clean-screenshots
Executable file
7
zsh/config/functions/clean-screenshots
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/zsh
|
||||
|
||||
function clean-screenshots() {
|
||||
for file in "$SCREENSHOTS"/*; do
|
||||
rm "$file"
|
||||
done
|
||||
}
|
||||
23
zsh/config/functions/desktop
Executable file
23
zsh/config/functions/desktop
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/zsh
|
||||
|
||||
function desktop() {
|
||||
declare hide
|
||||
declare show
|
||||
|
||||
zparseopts -D -E -K -- \
|
||||
{h,-hide}=hide \
|
||||
{s,-show}=show
|
||||
|
||||
if [ -n "$hide" ]; then
|
||||
defaults write com.apple.finder CreateDesktop false && killall Finder
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ -n "$show" ]; then
|
||||
defaults write com.apple.finder CreateDesktop true && killall Finder
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "Please pass in --hide | --show"
|
||||
return 1
|
||||
}
|
||||
16
zsh/config/functions/dmg
Executable file
16
zsh/config/functions/dmg
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/zsh
|
||||
|
||||
# Creates an encrypted disk image from a folder
|
||||
function dmg() {
|
||||
from="$1"
|
||||
to="$2"
|
||||
|
||||
if [ -z "$1" ] || [ -z "$2" ]; then
|
||||
echo "Usage: dmg <fromdir> <todir>"
|
||||
echo ""
|
||||
return 1
|
||||
fi
|
||||
|
||||
name="$(isosec).dmg"
|
||||
hdiutil create -encryption AES-256 -srcfolder "$from" "$to/$name"
|
||||
}
|
||||
12
zsh/config/functions/mkcd
Executable file
12
zsh/config/functions/mkcd
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
# Creates a directory then `cd`'s into the directory
|
||||
|
||||
function mkcd() {
|
||||
dir=$1
|
||||
if [ -z "$dir" ]; then
|
||||
echo "usage: mkcd <dir>" && return 1
|
||||
fi
|
||||
mkdir "$dir"
|
||||
cd "$dir"
|
||||
}
|
||||
@@ -8,9 +8,17 @@
|
||||
#
|
||||
|
||||
function n() {
|
||||
[ -d "$1" ] || [ -z "$1" ] \
|
||||
&& nvim -c ":Telescope find_files" \
|
||||
&& return 0
|
||||
if [ -z "$1" ]; then
|
||||
local gitdir=$(git rev-parse --show-toplevel 2> /dev/null)
|
||||
|
||||
[ -n "$gitdir" ] \
|
||||
&& nvim -c ":Telescope git_files" \
|
||||
&& return 0
|
||||
|
||||
[ -d "$1" ] \
|
||||
&& nvim -c ":Telescope find_files" \
|
||||
&& return 0
|
||||
fi
|
||||
|
||||
nvim "$1"
|
||||
}
|
||||
|
||||
19
zsh/config/functions/vic
Executable file
19
zsh/config/functions/vic
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/zsh
|
||||
|
||||
function vic() {
|
||||
# opens a shell command in $EDITOR
|
||||
cmd="$(command -v $1)"
|
||||
|
||||
[ -f "$cmd" ] \
|
||||
&& "$EDITOR" "$cmd" \
|
||||
&& return 0
|
||||
|
||||
# if command was not found try the function directory.
|
||||
cmd="$ZFUNCDIR/$1"
|
||||
[ -f "$cmd" ] \
|
||||
&& "$EDITOR" "$cmd" \
|
||||
&& return 0
|
||||
|
||||
echo "Command not found: $1"
|
||||
return 1
|
||||
}
|
||||
Reference in New Issue
Block a user