From 5fc418e479aa79a6192182b93ef4b6d5801cb7c6 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Sat, 18 Sep 2021 13:15:13 -0700 Subject: [PATCH] Use `${PWD}` instead of `$(pwd)` Don't subshell when there's a shell parameter for it. --- completion/available/hub.completion.bash | 2 +- lib/helpers.bash | 2 +- plugins/available/dirs.plugin.bash | 4 ++-- themes/powerturk/powerturk.theme.bash | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) mode change 100644 => 100755 themes/powerturk/powerturk.theme.bash diff --git a/completion/available/hub.completion.bash b/completion/available/hub.completion.bash index 79d76bf0..74c530a8 100644 --- a/completion/available/hub.completion.bash +++ b/completion/available/hub.completion.bash @@ -227,7 +227,7 @@ EOF ((c++)) done if [ -z "$name" ]; then - repo=$(basename "$(pwd)") + repo="$(basename "${PWD}")" fi case "$prev" in -d|-h) diff --git a/lib/helpers.bash b/lib/helpers.bash index 9b95fe65..61705a04 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -449,7 +449,7 @@ _bash-it-restart() { _about 'restarts the shell in order to fully reload it' _group 'lib' - saved_pwd=$(pwd) + saved_pwd="${PWD}" case $OSTYPE in darwin*) diff --git a/plugins/available/dirs.plugin.bash b/plugins/available/dirs.plugin.bash index 5f27db01..2c1adf7a 100644 --- a/plugins/available/dirs.plugin.bash +++ b/plugins/available/dirs.plugin.bash @@ -23,7 +23,7 @@ alias 8="pushd +8" alias 9="pushd +9" # Clone this location -alias pc="pushd \$(pwd)" +alias pc='pushd "${PWD}"' # Push new location alias pu="pushd" @@ -73,7 +73,7 @@ G () { example '$ G ..' group 'dirs' - cd "${1:-$(pwd)}" ; + cd "${1:-${PWD}}" ; } S () { diff --git a/themes/powerturk/powerturk.theme.bash b/themes/powerturk/powerturk.theme.bash old mode 100644 new mode 100755 index 4590a8aa..3352f680 --- a/themes/powerturk/powerturk.theme.bash +++ b/themes/powerturk/powerturk.theme.bash @@ -43,7 +43,7 @@ _swd(){ begin="" # The unshortened beginning of the path. shortbegin="" # The shortened beginning of the path. current="" # The section of the path we're currently working on. - end="${2:-$(pwd)}/" # The unmodified rest of the path. + end="${2:-${PWD}}/" # The unmodified rest of the path. if [[ "$end" =~ "$HOME" ]]; then INHOME=1