Skip to content

Instantly share code, notes, and snippets.

@Syphdias
Created November 19, 2018 23:13
Show Gist options
  • Save Syphdias/a4e204bd513ebefc8458eab7c562b631 to your computer and use it in GitHub Desktop.
Save Syphdias/a4e204bd513ebefc8458eab7c562b631 to your computer and use it in GitHub Desktop.
strategies thoughts
# Strategy Thoughts
## Current state
- Default
- P9K_DIR_SHORTEN_LENGTH: to control how many directories on right
unset to disable Strategy
- P9K_DIR_SHORTEN_DELIMITER: symbol on the left
unset is the same as ''
- truncate_absolute_chars|truncate_absolute
- P9K_DIR_SHORTEN_LENGTH: to control number of characters on right
unset to disable Strategy, 0 displays whole path with symbol in front (bug)
- P9K_DIR_SHORTEN_DELIMITER: symbol on the left
unset is the same as ''
- truncate_middle
- P9K_DIR_SHORTEN_LENGTH: to control number of characters on left and right
unset to disable Strategy
- P9K_DIR_SHORTEN_DELIMITER: symbol in the middle
unset is the same as ''
- Bug: Does not account for delimiter_length
- truncate_from_right|truncate_from_left (undocumented in README)
- P9K_DIR_SHORTEN_LENGTH: number of characters kept on left|right side
unset to disable Strategy
- P9K_DIR_SHORTEN_DELIMITER: symbol on the right|left
unset is the same as ''
- Bug(?): Does not touch directories with 3 or fewer letters
- truncate_to_last
- no options
- same as: unset P9K_DIR_SHORTEN_STRATEGY; P9K_DIR_SHORTEN_DELIMITER='';
P9K_DIR_OMIT_FIRST_CHARACTER=true
- truncate_to_first_and_last
- P9K_DIR_SHORTEN_LENGTH: number of directories on left and right
unset or =0 to disable Strategy
- P9K_DIR_SHORTEN_DELIMITER: replacment for directories
unset is the same as ''
- BUG(?): Does not account for delimiter_length
- truncate_to_unique
- only with #979: P9K_DIR_SHORTEN_LENGTH: number of directories untouch on the right
unset to disable Strategy (defaults to 1 with #979)
- truncate_with_package_name
- P9K_DIR_PACKAGE_FILES: file with json information
- Feature/Functionality change: needs git repo, why not do it with upsearch
with P9K_DIR_PACKAGE_FILES as needles? (like truncate_with_folder_marker)
- remaining path with be treated like truncate_from_right
- P9K_DIR_SHORTEN_LENGTH: number of characters kept on left side
unset to disable Strategy (also truncate_with_package_name)
- P9K_DIR_SHORTEN_DELIMITER: symbol on the right|left
unset is the same as ''
- truncate_with_folder_marker
- P9K_DIR_SHORTEN_DELIMITER: symbol on the left before marked folder
unset is the same as ''
## What I think are bugs in the current implementations
```
P9K_DIR_SHORTEN_STRATEGY=truncate_from_right; P9K_DIR_SHORTEN_LENGTH=2; P9K_DIR_SHORTEN_DELIMITER='*'
P9K_DIR_SHORTEN_STRATEGY=truncate_from_left; P9K_DIR_SHORTEN_LENGTH=2; P9K_DIR_SHORTEN_DELIMITER='*'
1234 -> 1234
P9K_DIR_SHORTEN_STRATEGY=truncate_middle; P9K_DIR_SHORTEN_LENGTH=2; P9K_DIR_SHORTEN_DELIMITER='**'
12345 -> 12**56
```
## Idea for new
P9K_DIR_PATH_ABSOLUTE false
P9K_DIR_SHORTEN_FOLDER_MARKER (.shorten_folder_marker .git)
P9K_DIR_PACKAGE_FILES (package.json composer.json)
P9K_DIR_SHORTEN_SEPARATOR="\u2026\u2026" # ……
P9K_DIR_SHORTEN_LENGTH "1"
P9K_DIR_SHORTEN_DELIMITER="\u2026" # …
P9K_DIR_PATH_HIGHLIGHT_FOREGROUND
P9K_DIR_PATH_HIGHLIGHT_BOLD false
P9K_DIR_HOME_FOLDER_ABBREVIATION "~"
P9K_DIR_PATH_SEPARATOR "/"
P9K_DIR_OMIT_FIRST_CHARACTER true
### Phases
1. Split total_path (PWD) into sections
- `P9K_DIR_PATH_ABSOLUTE` don't replace "~" with $HOME if wanted
- sections: `left_path`, `middle_path`, `right_path`
- `middle_path` can be shortened by strategies
- `right_path` and `left_path` are not to be touched by strategies
- `P9K_DIR_SHORTEN_SEPARATOR` between `left_path` and `middle_path`
2. Shorten `middle_path`
- strategies can use these parameters to change their behavior
- `P9K_DIR_SHORTEN_LENGTH`, `P9K_DIR_SHORTEN_DELIMITER`
3. Piece `*_path` back together
- highlights with `P9K_DIR_PATH_HIGHLIGHT_FOREGROUND` and `P9K_DIR_PATH_HIGHLIGHT_BOLD`
- take care of first character:
- `P9K_DIR_OMIT_FIRST_CHARACTER` and `P9K_DIR_HOME_FOLDER_ABBREVIATION`
- use `P9K_DIR_PATH_SEPARATOR`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment