zsh: split off functions now contain a note about use
This commit is contained in:
parent
11ef75c22e
commit
e8064cfac3
5 changed files with 11 additions and 6 deletions
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# Source this and then run `cda`
|
||||||
|
|
||||||
# cd all: opens a new shell in each of the directories below the one you're in, so
|
# cd all: opens a new shell in each of the directories below the one you're in, so
|
||||||
# you can execute commands in them until you type 'exit'
|
# you can execute commands in them until you type 'exit'
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# Source this and then run `cdf`
|
||||||
|
|
||||||
# cd find (interactive): cd to the containing dir of a file, or inside a folder, given part of its name
|
# cd find (interactive): cd to the containing dir of a file, or inside a folder, given part of its name
|
||||||
# Basically, an interactive version of what's above
|
# Basically, an interactive version of what's above
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# Source this and then run `cds`
|
||||||
|
|
||||||
# cd search: cd to a directory, given part of its name
|
# cd search: cd to a directory, given part of its name
|
||||||
# (also can take arguments for an `fd` commnd)
|
# (also can take arguments for an `fd` commnd)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# Source this and then run `gloned`
|
||||||
|
|
||||||
# Git cLONE cD
|
# Git cLONE cD
|
||||||
# Can take extra arguments for git (ex: gloned url:/repo folder)
|
# Can take extra arguments for git (ex: gloned url:/repo folder)
|
||||||
|
@ -7,13 +8,12 @@
|
||||||
|
|
||||||
gloned() {
|
gloned() {
|
||||||
# remove the url up to the last segment, and remove the .git from the end
|
# remove the url up to the last segment, and remove the .git from the end
|
||||||
REPO_DIR="${2:-"$(echo "${1%%.git}" | rev | cut -d '/' -f 1 | rev)"}"
|
REPO_DIR="${2:-"$(echo "${1%.git}" | rev | cut -d '/' -f 1 | rev)"}"
|
||||||
|
|
||||||
git clone "$1" "$REPO_DIR" || exit $?
|
git clone "$1" "$REPO_DIR" || return $?
|
||||||
ls
|
|
||||||
if ! cd "$REPO_DIR";then
|
if ! cd "$REPO_DIR";then
|
||||||
echo 'Error: Could not `cd` into the repo'
|
echo 'Error: Could not `cd` into the repo'
|
||||||
exit 1
|
return 1
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
# ls --color=auto
|
# ls --color=auto
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# Source this and then run `todo`
|
||||||
|
|
||||||
# a simple way to manage your todo list
|
# a simple way to manage your todo list
|
||||||
# Usage:
|
# Usage:
|
||||||
|
@ -9,12 +10,13 @@
|
||||||
# Suggested use: make a git repo for holding your todo list, then make
|
# Suggested use: make a git repo for holding your todo list, then make
|
||||||
# a symlink called 'todo' that points to your todo list in your home directory
|
# a symlink called 'todo' that points to your todo list in your home directory
|
||||||
#
|
#
|
||||||
|
|
||||||
todo() {
|
todo() {
|
||||||
todo_dir="$(dirname "$(realpath ~/todo)")"
|
todo_dir="$(dirname "$(realpath ~/todo)")"
|
||||||
todo_file="$(realpath ~/todo)"
|
todo_file="$(realpath ~/todo)"
|
||||||
if [ -z "$*" ];then
|
if [ -z "$*" ];then
|
||||||
( # subshell to protect against directory changes
|
( # subshell to protect against directory changes
|
||||||
cd "$todo_dir" || exit
|
cd "$todo_dir" || return
|
||||||
|
|
||||||
# pull the latest commits
|
# pull the latest commits
|
||||||
git rev-parse &&
|
git rev-parse &&
|
||||||
|
@ -31,7 +33,7 @@ todo() {
|
||||||
)
|
)
|
||||||
|
|
||||||
elif [ "$*" = "cd" ]; then
|
elif [ "$*" = "cd" ]; then
|
||||||
cd "$todo_dir" || exit
|
cd "$todo_dir" || return
|
||||||
else
|
else
|
||||||
git -C "$todo_dir" $@
|
git -C "$todo_dir" $@
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue