plugin/dirs: `shfmt` && `shellcheck`
parent
68f0cd6ebf
commit
5c8ef51dfb
|
|
@ -88,6 +88,7 @@ plugins/available/basher.plugin.bash
|
||||||
plugins/available/blesh.plugin.bash
|
plugins/available/blesh.plugin.bash
|
||||||
plugins/available/cmd-returned-notify.plugin.bash
|
plugins/available/cmd-returned-notify.plugin.bash
|
||||||
plugins/available/direnv.plugin.bash
|
plugins/available/direnv.plugin.bash
|
||||||
|
plugins/available/dirs.plugin.bash
|
||||||
plugins/available/docker-machine.plugin.bash
|
plugins/available/docker-machine.plugin.bash
|
||||||
plugins/available/git.plugin.bash
|
plugins/available/git.plugin.bash
|
||||||
plugins/available/go.plugin.bash
|
plugins/available/go.plugin.bash
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
# shellcheck shell=bash
|
||||||
# Directory stack navigation:
|
# Directory stack navigation:
|
||||||
#
|
#
|
||||||
# Add to stack with: pu /path/to/directory
|
# Add to stack with: pu /path/to/directory
|
||||||
|
|
@ -32,39 +33,39 @@ alias pu="pushd"
|
||||||
alias po="popd"
|
alias po="popd"
|
||||||
|
|
||||||
function dirs-help() {
|
function dirs-help() {
|
||||||
about 'directory navigation alias usage'
|
about 'directory navigation alias usage'
|
||||||
group 'dirs'
|
group 'dirs'
|
||||||
|
|
||||||
echo "Directory Navigation Alias Usage"
|
echo "Directory Navigation Alias Usage"
|
||||||
echo
|
echo
|
||||||
echo "Use the power of directory stacking to move"
|
echo "Use the power of directory stacking to move"
|
||||||
echo "between several locations with ease."
|
echo "between several locations with ease."
|
||||||
echo
|
echo
|
||||||
echo "d : Show directory stack."
|
echo "d : Show directory stack."
|
||||||
echo "po : Remove current location from stack."
|
echo "po : Remove current location from stack."
|
||||||
echo "pc : Adds current location to stack."
|
echo "pc : Adds current location to stack."
|
||||||
echo "pu <dir>: Adds given location to stack."
|
echo "pu <dir>: Adds given location to stack."
|
||||||
echo "1 : Change to stack location 1."
|
echo "1 : Change to stack location 1."
|
||||||
echo "2 : Change to stack location 2."
|
echo "2 : Change to stack location 2."
|
||||||
echo "3 : Change to stack location 3."
|
echo "3 : Change to stack location 3."
|
||||||
echo "4 : Change to stack location 4."
|
echo "4 : Change to stack location 4."
|
||||||
echo "5 : Change to stack location 5."
|
echo "5 : Change to stack location 5."
|
||||||
echo "6 : Change to stack location 6."
|
echo "6 : Change to stack location 6."
|
||||||
echo "7 : Change to stack location 7."
|
echo "7 : Change to stack location 7."
|
||||||
echo "8 : Change to stack location 8."
|
echo "8 : Change to stack location 8."
|
||||||
echo "9 : Change to stack location 9."
|
echo "9 : Change to stack location 9."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add bookmarking functionality
|
# Add bookmarking functionality
|
||||||
# Usage:
|
# Usage:
|
||||||
|
|
||||||
: "${BASH_IT_DIRS_BKS:=${XDG_STATE_HOME:-~/.local/state}/Bash_it/dirs}"
|
: "${BASH_IT_DIRS_BKS:=${XDG_STATE_HOME:-~/.local/state}/Bash_it/dirs}"
|
||||||
if [[ -f "${BASH_IT_DIRS_BKS:=${XDG_STATE_HOME:-~/.local/state}/Bash_it/dirs}" ]]
|
if [[ -f "${BASH_IT_DIRS_BKS:=${XDG_STATE_HOME:-~/.local/state}/Bash_it/dirs}" ]]; then
|
||||||
then
|
# shellcheck disable=SC1090
|
||||||
source "$BASH_IT_DIRS_BKS"
|
source "$BASH_IT_DIRS_BKS"
|
||||||
elif [[ -f ~/.dirs ]]
|
elif [[ -f ~/.dirs ]]; then
|
||||||
then
|
|
||||||
mv -vn ~/.dirs "$BASH_IT_DIRS_BKS"
|
mv -vn ~/.dirs "$BASH_IT_DIRS_BKS"
|
||||||
|
# shellcheck disable=SC1090
|
||||||
source "$BASH_IT_DIRS_BKS"
|
source "$BASH_IT_DIRS_BKS"
|
||||||
else
|
else
|
||||||
touch "$BASH_IT_DIRS_BKS"
|
touch "$BASH_IT_DIRS_BKS"
|
||||||
|
|
@ -73,44 +74,48 @@ fi
|
||||||
alias L='cat "$BASH_IT_DIRS_BKS"'
|
alias L='cat "$BASH_IT_DIRS_BKS"'
|
||||||
|
|
||||||
# Goes to destination dir, otherwise stay in the dir
|
# Goes to destination dir, otherwise stay in the dir
|
||||||
function G()
|
function G() {
|
||||||
{
|
about 'goes to destination dir'
|
||||||
about 'goes to destination dir'
|
param '1: directory'
|
||||||
param '1: directory'
|
example '$ G ..'
|
||||||
example '$ G ..'
|
group 'dirs'
|
||||||
group 'dirs'
|
|
||||||
|
|
||||||
cd "${1:-${PWD}}" ;
|
cd "${1:-${PWD}}" || return
|
||||||
}
|
}
|
||||||
|
|
||||||
function S ()
|
function S() {
|
||||||
{
|
about 'save a bookmark'
|
||||||
about 'save a bookmark'
|
param '1: bookmark name'
|
||||||
param '1: bookmark name'
|
example '$ S mybkmrk'
|
||||||
example '$ S mybkmrk'
|
group 'dirs'
|
||||||
group 'dirs'
|
|
||||||
|
|
||||||
[[ $# -eq 1 ]] || { echo "${FUNCNAME[0]} function requires 1 argument"; return 1; }
|
[[ $# -eq 1 ]] || {
|
||||||
|
echo "${FUNCNAME[0]} function requires 1 argument"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
sed "/$@/d" "$BASH_IT_DIRS_BKS" > ~/.dirs1;
|
sed "/$1/d" "$BASH_IT_DIRS_BKS" > ~/.dirs1
|
||||||
\mv ~/.dirs1 "$BASH_IT_DIRS_BKS";
|
command mv ~/.dirs1 "$BASH_IT_DIRS_BKS"
|
||||||
echo "$@"=\""${PWD}"\" >> "$BASH_IT_DIRS_BKS";
|
echo "$1"=\""${PWD}"\" >> "$BASH_IT_DIRS_BKS"
|
||||||
source "$BASH_IT_DIRS_BKS" ;
|
# shellcheck disable=SC1090
|
||||||
|
source "$BASH_IT_DIRS_BKS"
|
||||||
}
|
}
|
||||||
|
|
||||||
function R()
|
function R() {
|
||||||
{
|
about 'remove a bookmark'
|
||||||
about 'remove a bookmark'
|
param '1: bookmark name'
|
||||||
param '1: bookmark name'
|
example '$ R mybkmrk'
|
||||||
example '$ R mybkmrk'
|
group 'dirs'
|
||||||
group 'dirs'
|
|
||||||
|
|
||||||
[[ $# -eq 1 ]] || { echo "${FUNCNAME[0]} function requires 1 argument"; return 1; }
|
[[ $# -eq 1 ]] || {
|
||||||
|
echo "${FUNCNAME[0]} function requires 1 argument"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
sed "/$@/d" "$BASH_IT_DIRS_BKS" > ~/.dirs1;
|
sed "/$1/d" "$BASH_IT_DIRS_BKS" > ~/.dirs1
|
||||||
\mv ~/.dirs1 "$BASH_IT_DIRS_BKS";
|
\mv ~/.dirs1 "$BASH_IT_DIRS_BKS"
|
||||||
}
|
}
|
||||||
|
|
||||||
alias U='source "$BASH_IT_DIRS_BKS"' # Update bookmark stack
|
alias U='source "$BASH_IT_DIRS_BKS"' # Update bookmark stack
|
||||||
# Set the Bash option so that no '$' is required when using the above facility
|
# Set the Bash option so that no '$' is required when using the above facility
|
||||||
shopt -s cdable_vars
|
shopt -s cdable_vars
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue