this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

zsh: fmt, and add trm function to remove task folders

+75 -61
+75 -61
zsh/zshenv
··· 50 50 51 51 # find worktrunk worktree directories 52 52 function wtl() { 53 - fd --type d '\.wt\.' "${1:-.}" 53 + fd --type d '\.wt\.' "${1:-.}" 54 54 } 55 55 56 56 # Task workspace management ··· 58 58 alias cdt="cd ${TASKS_DIR}" 59 59 60 60 function tn() { 61 - task_desc="${1-$(date +%s)}" 62 - task_dir="$TASKS_DIR/${task_desc}" 63 - mkdir -p "$task_dir" 61 + task_desc="${1-$(date +%s)}" 62 + task_dir="$TASKS_DIR/${task_desc}" 63 + mkdir -p "$task_dir" 64 64 65 - touch "$task_dir/TASK.md" 66 - cd "$task_dir" || { 67 - echo "failed to cd: ${task_dir}" 68 - return 1 69 - } 65 + touch "$task_dir/TASK.md" 66 + cd "$task_dir" || { 67 + echo "failed to cd: ${task_dir}" 68 + return 1 69 + } 70 70 } 71 71 72 72 function tcd() { 73 - local selected 74 - selected=$(find "$TASKS_DIR" -maxdepth 1 -mindepth 1 -type d 2>/dev/null | 75 - sed 's|^'"$TASKS_DIR"'/||' | 76 - fzf --height 40% --reverse --preview "ls -la $TASKS_DIR/{}" \ 77 - --preview-window=right:50%:wrap) 78 - if [[ -n "$selected" ]]; then 79 - cd "$TASKS_DIR/$selected" || return 1 80 - fi 73 + local selected 74 + selected=$(find "$TASKS_DIR" -maxdepth 1 -mindepth 1 -type d 2>/dev/null | 75 + sed 's|^'"$TASKS_DIR"'/||' | 76 + fzf --height 40% --reverse --preview "ls -la $TASKS_DIR/{}" \ 77 + --preview-window=right:50%:wrap) 78 + if [[ -n "$selected" ]]; then 79 + cd "$TASKS_DIR/$selected" || return 1 80 + fi 81 + } 82 + 83 + function trm() { 84 + local selected 85 + selected=$(find "$TASKS_DIR" -maxdepth 1 -mindepth 1 -type d 2>/dev/null | 86 + sed 's|^'"$TASKS_DIR"'/||' | 87 + fzf --height 40% --reverse --preview "ls -la $TASKS_DIR/{}" \ 88 + --preview-window=right:50%:wrap) 89 + [[ -z "$selected" ]] && return 1 90 + 91 + local task_path="$TASKS_DIR/$selected" 92 + 93 + trash "$task_path" 94 + echo "Removed task: $selected" 81 95 } 82 96 83 97 # Accepts a target markdown file and opens it with firefox. ··· 85 99 # Expects the [markdown viewer](https://github.com/simov/markdown-viewer) 86 100 # FF extension to be installed. 87 101 function mdp { 88 - local file="${1}" 102 + local file="${1}" 89 103 90 - # If it isn't already an absolute path, make it one 91 - if [[ ! "$file" == "/"* ]]; then 92 - file="${PWD}/${file}" 93 - fi 104 + # If it isn't already an absolute path, make it one 105 + if [[ ! "$file" == "/"* ]]; then 106 + file="${PWD}/${file}" 107 + fi 94 108 95 - # If it isn't a markdown file, bail 96 - if [[ ! "$file" == *".md" ]]; then 97 - echo "Must provide a markdown file" 98 - exit 1 99 - fi 109 + # If it isn't a markdown file, bail 110 + if [[ ! "$file" == *".md" ]]; then 111 + echo "Must provide a markdown file" 112 + exit 1 113 + fi 100 114 101 - open -a Helium.app "${file}" 115 + open -a Helium.app "${file}" 102 116 } 103 117 104 118 function rand { 105 - count=$1 106 - if [ -z "$count" ]; then 107 - count=8 108 - fi 109 - date +%s | shasum | head -c$1 119 + count=$1 120 + if [ -z "$count" ]; then 121 + count=8 122 + fi 123 + date +%s | shasum | head -c$1 110 124 } 111 125 112 126 function gittmp { 113 - repo_uri=$1 114 - if [ -z "$1" ]; then 115 - echo "must provide a repo to clone" 116 - return 1 117 - fi 127 + repo_uri=$1 128 + if [ -z "$1" ]; then 129 + echo "must provide a repo to clone" 130 + return 1 131 + fi 118 132 119 - newdir=$(mktemp -d) 120 - git clone $1 $newdir 133 + newdir=$(mktemp -d) 134 + git clone $1 $newdir 121 135 122 - session_name="gittmp-$(rand 4)" 123 - tmux new -A -s $session_name -c $newdir -d 124 - tmux switch -t $session_name 136 + session_name="gittmp-$(rand 4)" 137 + tmux new -A -s $session_name -c $newdir -d 138 + tmux switch -t $session_name 125 139 } 126 140 127 141 function gbrowse() { 128 - branch=$(git branch --show-current) 129 - if [ -z "$branch" ]; then 130 - branch=$(git rev-parse HEAD) 131 - fi 142 + branch=$(git branch --show-current) 143 + if [ -z "$branch" ]; then 144 + branch=$(git rev-parse HEAD) 145 + fi 132 146 133 - origin=$(git remote get-url origin) 134 - if [[ "$origin" =~ .*gitlab\.com.* ]]; then 135 - # Assume it's on gitlab 136 - # gitlab's cli doesn't have a `browse` command, so do this instead 137 - baseurl=$origin 138 - if [[ "$origin" =~ ^git@gitlab.* ]]; then 139 - baseurl=$(echo $origin | sed 's/git@/https:\/\//' | sed 's/\.com:/\.com\//' | sed 's/\.git$//') 140 - fi 141 - open "$baseurl/-/blob/$branch/$1" 142 - else 143 - # Assume it's on github 144 - gh browse --branch="$branch" $1 145 - fi 147 + origin=$(git remote get-url origin) 148 + if [[ "$origin" =~ .*gitlab\.com.* ]]; then 149 + # Assume it's on gitlab 150 + # gitlab's cli doesn't have a `browse` command, so do this instead 151 + baseurl=$origin 152 + if [[ "$origin" =~ ^git@gitlab.* ]]; then 153 + baseurl=$(echo $origin | sed 's/git@/https:\/\//' | sed 's/\.com:/\.com\//' | sed 's/\.git$//') 154 + fi 155 + open "$baseurl/-/blob/$branch/$1" 156 + else 157 + # Assume it's on github 158 + gh browse --branch="$branch" $1 159 + fi 146 160 } 147 161 148 162 # Load zapier-specific config if on my work machine 149 163 ZAPIER_ZSHENV="${HOME}/projects/zapier/utils/zshenv" 150 164 if [[ $(hostname) == "asteroid" && -f "${ZAPIER_ZSHENV}" ]]; then 151 - source "${ZAPIER_ZSHENV}" 165 + source "${ZAPIER_ZSHENV}" 152 166 fi 153 167 154 168 export HOMEBREW_BUNDLE_FILE="$HOME/dotfiles/Brewfile"