mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 22:22:40 +00:00
Added mkcd
This commit is contained in:
12
scripts/.local/scripts/mkcd
Executable file
12
scripts/.local/scripts/mkcd
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Createsa directory then `cd`'s into the directory
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
dir="$1"
|
||||||
|
|
||||||
|
test -n "${dir}" || echo "usage: mkcd <dir>" && exit 1
|
||||||
|
|
||||||
|
mkdir "${dir}"
|
||||||
|
cd "${dir}"
|
||||||
@@ -8,21 +8,19 @@ test ! -n "${SCRIPTS}" && echo "SCRIPTS not set" && exit 1;
|
|||||||
# fallback to check if the name arg ${1} exists, if not show usage text.
|
# fallback to check if the name arg ${1} exists, if not show usage text.
|
||||||
test ! -n "${1}" && \
|
test ! -n "${1}" && \
|
||||||
echo "usage: newscript <name> <optional: shell>" && \
|
echo "usage: newscript <name> <optional: shell>" && \
|
||||||
echo "shell defaults to `sh` if not supplied" && \
|
echo "shell defaults to sh if not supplied" && \
|
||||||
exit 1;
|
exit 1;
|
||||||
|
|
||||||
path="${SCRIPTS}/${1}"
|
path="${SCRIPTS}/${1}"
|
||||||
shell="${2:-sh}"
|
shell="${2:-sh}"
|
||||||
|
|
||||||
if [ -e "${path}" ]; then
|
if [ -e "${path}" ]; then
|
||||||
read -p "${1} already exists. Edit? " yes
|
echo "Already exists try:"
|
||||||
case "${yes}" in
|
echo "vi ${path}"
|
||||||
y|yes|yep|yeppers|yeah|ok|okay) exec vim "${path}"
|
exit 1
|
||||||
esac
|
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "#!/bin/${shell}"\n\n" > "${path}"
|
printf "#!/bin/%s\n\n" "${shell}" > "${path}"
|
||||||
chmod +x "${path}"
|
chmod +x "${path}"
|
||||||
exec vim +2 "${path}"
|
exec vim +2 "${path}"
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/zsh
|
||||||
# configure aliases
|
# configure aliases
|
||||||
# _ _
|
# _ _
|
||||||
# ( ) (_ ) _
|
# ( ) (_ ) _
|
||||||
@@ -17,22 +18,19 @@ alias cl() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# move into the ~/.dotfiles directory
|
# move into the ~/.dotfiles directory
|
||||||
alias cdots() { cd "$HOME/.dotfiles" }
|
alias cdots="cd ${HOME}/.dotfiles"
|
||||||
|
|
||||||
# move into zsh config files
|
# move into zsh config files
|
||||||
alias zdots() { nvim "$ZDOTDIR" }
|
alias zdots="vi ${ZDOTDIR}"
|
||||||
|
|
||||||
# open dotfiles in nvim editor
|
# open dotfiles in nvim editor
|
||||||
alias dots() { nvim ~/.dotfiles }
|
alias dots="vi $DOTFILES"
|
||||||
|
|
||||||
# reload the zsh shell
|
|
||||||
alias reload() { source "$ZDOTDIR/.zshrc" }
|
|
||||||
|
|
||||||
# print the banner
|
# print the banner
|
||||||
alias banner() { clear && cat < "$ZDOTDIR/banner" }
|
#alias banner() { clear && cat < "$ZDOTDIR/banner" }
|
||||||
|
|
||||||
# create a directory and move into it.
|
# create a directory and move into it.
|
||||||
alias mkcd() { mkdir $1 && cd $1 }
|
#alias mkcd() { mkdir $1 && cd $1 }
|
||||||
|
|
||||||
# list files and directories, including hidden files
|
# list files and directories, including hidden files
|
||||||
alias l() { ls -lah "$@" }
|
alias l() { ls -lah "$@" }
|
||||||
|
|||||||
Reference in New Issue
Block a user