mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 06:12:34 +00:00
Cleaning up some scripts and moving to autoload functions
This commit is contained in:
4
TODO.md
4
TODO.md
@@ -1,6 +1,6 @@
|
||||
# TODO
|
||||
|
||||
- Remove brewfiles and use the `dots` cli manager instead.
|
||||
- Add zsh functions to dots cli manager.
|
||||
- Add tmux plugins to dots cli manager.
|
||||
- Add tmux-powerline linking to `dots` cli manager.
|
||||
|
||||
- Clean up zet commands, maybe make a gum / fzf filter script.
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
<string>com.micheal.clear-screenshots</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>sh</string>
|
||||
<string>zsh</string>
|
||||
<string>-c</string>
|
||||
<string>/Users/michael/.local/scripts/clear_screenshots</string>
|
||||
<string>/Users/michael/.config/zsh/functions/clean-screenshots</string>
|
||||
</array>
|
||||
<key>StartCalendarInterval</key>
|
||||
<dict>
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
session="dots"
|
||||
|
||||
tmux switch-client -t "$session" || \
|
||||
tmux attach -t "$session" || \
|
||||
tmux new-session -c "$DOTFILES" -s "$session"
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# makes files executable
|
||||
test -f "$1" && chmod +x "$1"
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
for file in "$SCREENSHOTS"/*; do
|
||||
rm "$file"
|
||||
done
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/zsh
|
||||
|
||||
# adapted from...
|
||||
# https://github.com/rwxrob/dot/blob/main/scripts/cmt
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
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
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n "$show" ]; then
|
||||
defaults write com.apple.finder CreateDesktop true && killall Finder
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Please pass in --hide | --show"
|
||||
exit 1
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Creates an encrypted disk image from a folder
|
||||
|
||||
set -e
|
||||
|
||||
from="$1"
|
||||
to="$2"
|
||||
|
||||
if [ -z "$1" ] || [ -z "$2" ]; then
|
||||
echo "Usage: dmg <fromdir> <todir>"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
name="$(isosec).dmg"
|
||||
hdiutil create -encryption AES-256 -srcfolder "$from" "$to/$name"
|
||||
@@ -1,9 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
date -u '+%Y%m%d%H%M%S'
|
||||
|
||||
isosec() {
|
||||
echo "$(date -u '+%Y%m%d%H%M%S')"
|
||||
}
|
||||
|
||||
isosec
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Lists files and directories, including hidden files.
|
||||
|
||||
ls -lah --color "$@"
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Creates a directory then `cd`'s into the directory
|
||||
|
||||
set -e
|
||||
|
||||
dir="$1"
|
||||
|
||||
test -n "${dir}" || echo "usage: mkcd <dir>" && exit 1
|
||||
|
||||
mkdir "${dir}"
|
||||
cd "${dir}"
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
set -e
|
||||
|
||||
# Creates a new `zet` inside the House Call Pro `Zettlekasten`
|
||||
# Creates a new `zet` inside the NCI Summit `Zettlekasten`
|
||||
|
||||
_main() {
|
||||
(ZETDIR="$HOME/Documents/NCISummit" eval zet "$@")
|
||||
ZETDIR="$HOME/Documents/NCISummit" eval zet "$@"
|
||||
}
|
||||
|
||||
_main "$@"
|
||||
|
||||
@@ -16,7 +16,7 @@ shell="${2:-sh}"
|
||||
|
||||
if [ -e "${path}" ]; then
|
||||
echo "Already exists try:"
|
||||
echo "vi ${path}"
|
||||
echo "$EDITOR $path"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
#!/bin/sh
|
||||
#!/bin/zsh
|
||||
|
||||
# Change / select an nvim configuration.
|
||||
#
|
||||
# The configuration's need to be in the ~/.config folder
|
||||
# to work properly.
|
||||
#
|
||||
main() {
|
||||
items=("default" "m-housh" "kickstart" "lazy")
|
||||
config=$(printf "%s\n" "${items[@]}" | fzf --prompt=" Neovim Config ➣ " --height=50% --layout=reverse --border --exit-0)
|
||||
if [[ -z $config ]]; then
|
||||
config=$(printf "%s\n" "${items[@]}" \
|
||||
| fzf --prompt=" Neovim Config ➣ " --height=50% --layout=reverse --border --exit-0
|
||||
)
|
||||
if [ -z "$config" ]; then
|
||||
echo "Nothing selected"
|
||||
return 0
|
||||
elif [[ $config == "default" ]]; then
|
||||
elif [ $config == "default" ]; then
|
||||
config=""
|
||||
fi
|
||||
unset VIMINIT && unset MYVIMRC && export NVIM_APPNAME=$config && nvim $@
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
# Move into the proposals directory
|
||||
cd "$HOME/Library/Mobile Documents/com~apple~CloudDocs/Work/Proposals"
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
# Creates a new `zet` inside the House Call Pro `Zettlekasten`
|
||||
# Creates a new `zet` inside the private `Zettlekasten`
|
||||
|
||||
_main() {
|
||||
(ZETDIR="$GHREPOS/private-zets" eval zet "$@")
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# opens a shell command in $EDITOR
|
||||
cmd="$(command -v $1)"
|
||||
test -n "$cmd" && "$EDITOR" "$cmd"
|
||||
@@ -2,6 +2,7 @@
|
||||
export XDG_CONFIG_HOME="$HOME/.config"
|
||||
export XDG_DATA_HOME="$HOME/.local"
|
||||
export ZDOTDIR="$HOME/.config/zsh"
|
||||
export ZFUNCDIR="$ZDOTDIR/functions"
|
||||
export SHELL="$(which zsh)"
|
||||
|
||||
# Git
|
||||
|
||||
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" ] \
|
||||
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