added options and one to only switch
This commit is contained in:
parent
5ee1c7eddb
commit
deba4793f7
1 changed files with 52 additions and 26 deletions
26
nswitch
26
nswitch
|
@ -14,6 +14,8 @@ exit_with_new_shell() {
|
|||
# check if already in directory
|
||||
[[ "$INITIAL_PWD" = "$PROJECT" ]] && printf '>>> already in directory\n' && exit 0
|
||||
|
||||
cd "$PROJECT" || exit 1
|
||||
|
||||
printf '\n'
|
||||
printf '>>> opening a new \"%s\" shell\n' "$(basename "$SHELL")"
|
||||
printf ' cwd: %s\n' "$(pwd)"
|
||||
|
@ -21,6 +23,7 @@ exit_with_new_shell() {
|
|||
exit 0
|
||||
}
|
||||
|
||||
quick_edit() {
|
||||
cd "$PROJECT" || exit 1
|
||||
nvim
|
||||
|
||||
|
@ -53,3 +56,26 @@ printf ">>> commiting to git\n"
|
|||
git commit -am "$gen"
|
||||
|
||||
exit_with_new_shell
|
||||
}
|
||||
|
||||
|
||||
help_msg() {
|
||||
printf -- ' without arguments start the main loop\n'
|
||||
printf -- '--help | -h -> show this message\n'
|
||||
printf -- '--new-shell-in-project | -s -> show this message\n'
|
||||
}
|
||||
|
||||
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
quick_edit
|
||||
elif [[ "$1" = "--help" || "$1" = "-h" ]]; then
|
||||
help_msg
|
||||
elif [[ "$1" = "--new-shell-in-project" || "$1" = "-s" ]]; then
|
||||
exit_with_new_shell
|
||||
else
|
||||
help_msg
|
||||
printf "=================\n"
|
||||
printf "didn't recognise: %s\n" "$1"
|
||||
exit 1
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue