diff --git a/.bin/dot b/.bin/dot new file mode 100755 index 0000000..b24a937 --- /dev/null +++ b/.bin/dot @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +$EDITOR $(git --git-dir=$HOME/.dotfiles ls-files | fzf) diff --git a/.bin/dots b/.bin/dots new file mode 100755 index 0000000..e88dfc6 --- /dev/null +++ b/.bin/dots @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME $@ diff --git a/.bin/kill-port b/.bin/kill-port new file mode 100755 index 0000000..63a1fe0 --- /dev/null +++ b/.bin/kill-port @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +sudo kill $(lsof -t -i:"$1") diff --git a/.bin/open b/.bin/open new file mode 100755 index 0000000..01c5269 --- /dev/null +++ b/.bin/open @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +if [[ $OSTYPE =~ "darwin" ]]; then + /usr/bin/open $@ +fi + +if [[ $OSTYPE =~ "linux" ]]; then + detach xdg-open $@ +fi diff --git a/.bin/reload b/.bin/reload new file mode 100755 index 0000000..b8982b5 --- /dev/null +++ b/.bin/reload @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +exec $SHELL -l diff --git a/.bin/tree b/.bin/tree new file mode 100755 index 0000000..561bebc --- /dev/null +++ b/.bin/tree @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# Replace tree with exa +# --git-ignore only works if ignore pattern doesn't have slashes +# See: https://github.com/ogham/exa/commit/827aa8bfc32eadf353f72b0ce41c88dc4ad411c1 +exa -T --group-directories-first --git-ignore $@ diff --git a/.scripts/autoload.sh b/.scripts/autoload.sh new file mode 100644 index 0000000..76449a0 --- /dev/null +++ b/.scripts/autoload.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +source "$HOME/.scripts/gg.sh" diff --git a/.scripts/gg.sh b/.scripts/gg.sh new file mode 100755 index 0000000..e263e61 --- /dev/null +++ b/.scripts/gg.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env zsh + +# Quickly change to any tracked sub-directory within the git work tree from +# anywhere inside the work tree + +gd() { + if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == "true" ]]; then + work_tree=$(git rev-parse --show-toplevel) + + directory=$(echo ".\n$(fd --type d --hidden --exclude .git --base-directory=$work_tree)" | fzf --ansi --preview "exa -T -L1 --git-ignore --group-directories-first --icons {}") + + cd "$work_tree/${directory:-$PWD}" + fi +} + +alias gg="gd && clear" diff --git a/.zshrc b/.zshrc index cfd3ac9..fb21901 100644 --- a/.zshrc +++ b/.zshrc @@ -12,47 +12,23 @@ fi # Customize to your needs... # -alias reload="exec $SHELL -l" -alias vi=nvim -alias ls="exa -l --group-directories-first --icons" -alias la="exa -la --group-directories-first --icons" -# Replace tree with exa -# --git-ignore only works if ignore pattern doesn't have slashes -# See: https://github.com/ogham/exa/commit/827aa8bfc32eadf353f72b0ce41c88dc4ad411c1 -alias tree='exa -T --group-directories-first --git-ignore' - -if [[ $OSTYPE =~ "linux" ]]; then - alias open="detach xdg-open" -fi - -alias o="open" - -alias dots="git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME" -# Quickly change to a sub-directory within the git project -gd() { - _dirs=$(fd --type d --hidden --follow --exclude .git) - _dirs_with_base=".\n$_dirs" - _cmd=$(echo "$_dirs_with_base" | fzf --preview "exa -T -L1 --git-ignore --group-directories-first {}") +export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude .git" +export FZF_DEFAULT_OPS="--ansi" - cd "${_cmd:-.}" -} - -# Jump to git root -gr() { - cd `git rev-parse --show-toplevel` -} - -alias gg="gr && gd && clear" +export VOLTA_HOME="$HOME/.volta" -killPort() { - sudo kill $(lsof -t -i:"$1") -} +# Path exports +export PATH="$VOLTA_HOME/bin:$HOME/.bin:$PATH" -export VOLTA_HOME="$HOME/.volta" -export PATH="$VOLTA_HOME/bin:$PATH" +# Autoload scripts +source "$HOME/.scripts/autoload.sh" -export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git' +# Aliases +alias vi="nvim" +alias ls="exa -l --group-directories-first --icons" +alias la="exa -la --group-directories-first --icons" +alias o="open" eval "$(starship init zsh)" eval "$(trellis shell-init zsh)" diff --git a/README.md b/README.md index a35eb3d..cfeece7 100644 --- a/README.md +++ b/README.md @@ -63,14 +63,17 @@ Some notes on maintaining. ### Using the `dots` Git wrapper alias Following those who have used the bare-repo method of dotfiles before me, I have -made an alias (two actually) as a wrapper around Git to make updating these -dotfiles a breeze. They are `dotfiles` and `dots` (I am lazy and use the -latter). You will notice a few integrations do not work like any shell +made an alias `dots` as a wrapper around Git to make updating these dotfiles a +breeze. You will notice a few integrations do not work like any shell autocompletion or editor Git integration. I am sure that someone else has those things solved, I just haven’t found that yet. Note that with using the repo through the helper, you will need to explicitly add new files. This includes new files that are created as a product of renaming another file. +### Quickly edit a tracked dotfile + +I have a script `dot` which feeds all tracked dotfiles into `fzf` for selection. + ### Installing packages and keeping package lists up-to-date Note that running the setup script again will install new packages for you. If