zsh: realized some things need to be functions
By that, I mean things that change my working directory need to be functions
This commit is contained in:
parent
cba8e92e1d
commit
06ab216290
11 changed files with 93 additions and 94 deletions
|
@ -1,16 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 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'
|
||||
# If I use this enough, I may make something that can do more
|
||||
# Ideas for what it could do in the future:
|
||||
# - somehow record typed commands so they can be automatically repeated like a macro
|
||||
# - maybe get the length of the histfile before and after, executing the last X number of commands
|
||||
# - Maybe just add an argument that takes a command and executes it in all dirs
|
||||
# (although that wouldn't be as good as recording actions bc it's easy to do
|
||||
# that by just writing a for loop)
|
||||
|
||||
for DIR in *; do
|
||||
(cd "$DIR" && zsh)
|
||||
done
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 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
|
||||
# can take an `fd` command
|
||||
# requires that `fzy` is installed
|
||||
|
||||
DIR="$(fd $@ | fzy)"
|
||||
if [ -f "$DIR" ];then
|
||||
cd "$(dirname "$DIR")" && pwd
|
||||
else
|
||||
cd "$DIR" && pwd
|
||||
fi
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# cd search: cd to a directory, given part of its name
|
||||
# (also can take arguments for an `fd` commnd)
|
||||
# (also can cd to a file if `-t f` is passed)
|
||||
|
||||
if ! [ -z "$1" ];then
|
||||
DIR="$(fd --max-results=1 -t d $@)"
|
||||
if [ -f "$DIR" ];then
|
||||
cd "$(dirname "$DIR")" && pwd
|
||||
else
|
||||
cd "$DIR" && pwd
|
||||
fi
|
||||
else
|
||||
echo "$0: no arguments provided"
|
||||
return 1
|
||||
fi
|
||||
|
|
@ -3,6 +3,6 @@
|
|||
# for sending error messages from functions and whatnot
|
||||
|
||||
ERROR_CODE="$?"
|
||||
>&2 echo "An error occurred within a function in the .zshrc on line number ${1}"
|
||||
>&2 echo "$0: An error occurred on line number ${1}"
|
||||
return $ERROR_CODE
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Simple extraction script. Taken from manjaro's .bashrc
|
||||
|
||||
if [ -f $1 ] ; then
|
||||
if [ -f "$1" ] ; then
|
||||
case $1 in
|
||||
*.tar.bz2) tar xjf "$1" ;;
|
||||
*.tar.gz) tar xzf "$1" ;;
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Git cLONE cD
|
||||
# Can take extra arguments for git (ex: gloned url:/repo folder)
|
||||
|
||||
# shellcheck disable=SC2068,SC2016
|
||||
|
||||
git clone $@ || return $?
|
||||
if ! cd "$(echo "$1" | sed 's/\.git//g' | rev | cut -d '/' -f 1 | rev)";then
|
||||
echo 'Error: Could not `cd` into the repo'
|
||||
return 1
|
||||
fi
|
||||
echo
|
||||
# ls --color=auto
|
||||
|
|
@ -6,18 +6,18 @@
|
|||
# usage: sitepath
|
||||
# usage: sitepath <fd commands> -- you can search with 'fd' if you put in a command
|
||||
|
||||
# account for if there is no urlencode command
|
||||
URLENCODE=urlencode
|
||||
if ! command -v urlencode > /dev/null 2>&1;then
|
||||
URLENCODE=cat
|
||||
fi
|
||||
# If there is no input, make the input the current directory
|
||||
[ -z ${1+x} ] && 1="$(pwd)"
|
||||
FILEPATH="$(([ -e "$1" ] && readlink -f "$1") || fd $@ /home/blake/docker/blakenorth.net/site)"
|
||||
# account for if there is no urlencode command
|
||||
URLENCODE=urlencode
|
||||
if ! command -v urlencode > /dev/null 2>&1;then
|
||||
URLENCODE=cat
|
||||
fi
|
||||
# If there is no input, make the input the current directory
|
||||
[ -z ${1+x} ] && 1="$(pwd)"
|
||||
FILEPATH="$(([ -e "$1" ] && readlink -f "$1") || fd $@ /home/blake/docker/blakenorth.net/site)"
|
||||
|
||||
# change all file paths into urls
|
||||
echo "$FILEPATH" |
|
||||
grep -o 'site.*' |
|
||||
sed 's+^site+https://blakenorth.net+g' |
|
||||
$URLENCODE # if you need this, I am using dead10ck/urlencode (cargo install urlencode)
|
||||
# change all file paths into urls
|
||||
echo "$FILEPATH" |
|
||||
grep -o 'site.*' |
|
||||
sed 's+^site+https://blakenorth.net+g' |
|
||||
$URLENCODE # if you need this, I am using dead10ck/urlencode (cargo install urlencode)
|
||||
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# a simple way to manage your todo list
|
||||
# Usage:
|
||||
# todo -- pull latest repo version and edit ~/todo
|
||||
# todo [any git command] -- manage todo for easy syncing, assuming ~/todo is
|
||||
# a symlink that points to a file in a git repo
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
todo_dir="$(dirname "$(realpath ~/todo)")"
|
||||
todo_file="$(realpath ~/todo)"
|
||||
if [ -z "$@" ];then
|
||||
( # subshell to protect against directory changes
|
||||
cd "$todo_dir"
|
||||
|
||||
# pull the latest commits
|
||||
git rev-parse &&
|
||||
git pull
|
||||
|
||||
# open the file
|
||||
"$EDITOR" "$todo_file"
|
||||
|
||||
# commit and push the file if it's in a git repo and the file has changed
|
||||
if git rev-parse && ! git diff --exit-code "$todo_file"; then
|
||||
git commit "$todo_file" -m 'todo' &&
|
||||
git push
|
||||
fi
|
||||
)
|
||||
|
||||
elif [ "$@" = "cd" ]; then
|
||||
cd "$todo_dir"
|
||||
|
||||
else
|
||||
git -C "$todo_dir" $@
|
||||
|
||||
fi
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue