Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions scripts/cwd.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env bash

current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $current_dir/utils.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

source $current_dir/utils.sh
^-------------------^ SC1091 (info): Not following: ./utils.sh was not specified as input (see shellcheck -x).
^----------^ SC2086 (info): Double quote to prevent globbing and word splitting.


# return current working directory of tmux pane
getPaneDir() {
nextone="false"
Expand All @@ -18,6 +21,20 @@ main() {
# change '/home/user' to '~'
cwd="${path/"$HOME"/'~'}"

# check max number of subdirs to display. 0 means unlimited
cwd_len=$(get_tmux_option "@dracula-cwd-length" "0")

if [[ "$cwd_len" -gt 0 ]]; then
base_to_erase=$cwd
for ((i = 0 ; i < cwd_len ; i++)); do
base_to_erase="${base_to_erase%/*}"
done
# / would have #base_to_erase of 0 and ~/ has #base_to_erase of 1. we want to exclude both cases
if [[ ${#base_to_erase} -gt 1 ]]; then
cwd=${cwd:${#base_to_erase}+1}
fi
fi

echo "$cwd"
}

Expand Down