-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: add max length feature to cwd #326
Conversation
At least one edge case here. For ease of testing, I modified the script to accept limit in $1 and path in $2:
It's a small edge case, but it could be devastating to mislead of their current directory; e.g. they could think they are safely deleting files from a specific directory. I might try something like below:
I would also add that "@dracula-cwd-length" plugin option might be misinterpreted as length of chars, not length of dirs. Perhaps there is a better name for this option like "depth". Also, speaking of length of chars, this PR doesn't really address it. You may have a dir limit of 3, but still get a huge cwd from this plugin if the dir names themselves are too long. I think it would be good to accommodate that as well. As well, when a directory is not in the $HOME path, and it exceeds the limit, I think a specific symbol would be better than leaving it blank. Other programs like starship use ".../" or even better, an ellipsis "…/" And again, testing should probably be quite heavy on this, as it being incorrect could be very damaging. |
scripts/cwd.sh
Outdated
@@ -1,5 +1,8 @@ | |||
#!/usr/bin/env bash | |||
|
|||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |||
source $current_dir/utils.sh |
There was a problem hiding this comment.
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.
hi, thank you very much for your feedback! i looked into the bad home dir substitution and think i got a fix that may run a little faster than yours (please absolutely do correct me if i'm wrong). i'd be happy if you could test the changes. the options are now: set -g @dracula-cwd-max-dirs "3"
set -g @dracula-cwd-max-chars "10" as usual, the respective options are ignored when set to |
Awesome, thanks! |
in reference to #324 this pr attempts to implement the suggestion.
tested on macos
not yet documented.
use
set -g @dracula-cwd-length "0"
to set the max length, where 0 is unrestricted.whenever the paths length is cut, it is displayed without / or ~/ to the left of it to prevent confusion.
example:
max length is 1:
/ becomes / as usual
/Users becomes /Users as usual
/Users/username becomes ~ as usual
/Users/username/.config becomes ~/.config as usual
/Users/username/.config/tmux becomes tmux. no / to the left indicates a cut path
max length is 3:
/Users/username/.config becomes ~/.config as usual
/Users/username/.config/tmux/plugins becomes ~/.config/tmux/plugins as usual
/Users/username/.config/tmux/plugins/tmux becomes tmux. no / to the left indicates a cut path
max length is 0:
unchanged behaviour to previously
my solution seems hacky, but i couldnt think of anything else at this time of day.
please critique or suggest a different solution.
documentation and testing on linux will follow.