diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2021-06-01 21:17:18 +0200 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2021-06-01 21:17:18 +0200 |
commit | 95e99f1866ef05952f2c6bf89db80341b6abeac4 (patch) | |
tree | 1221b5da6cdcd8963c3a09cd4c1be0b32eb83fe0 /bash | |
parent | aff5e973c018f57172a3218e6a7579f667f2222c (diff) | |
download | dotfiles-95e99f1866ef05952f2c6bf89db80341b6abeac4.tar.gz |
update board.bash
Diffstat (limited to 'bash')
-rw-r--r-- | bash/board.bash | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/bash/board.bash b/bash/board.bash index 08f4da1..7301741 100644 --- a/bash/board.bash +++ b/bash/board.bash @@ -2,12 +2,15 @@ BB_HIST_DIR="$HOME/.cache/bashboard/" BB_SHORTCUT=() +BB_LIST_LEN=5 [ ! -d "$BB_HIST_DIR" ] && mkdir -p "$BB_HIST_DIR" # format # NUM YYYY-MM-DD PATH +# add ssh targets + function cd { local BB_PWD local BB_GREP_RET @@ -17,7 +20,7 @@ function cd { [ -f "$BB_DIR/history" ] || touch "$BB_HIST_DIR/history" BB_PWD="$(pwd)" - [ "$BB_PWD" = "$HOME" ] && return + [ "${BB_PWD%%/}" = "${HOME%%/}" ] && return BB_GREP_RET=$(grep -P "^\d+ \d+ \Q$BB_PWD\E$" "$BB_HIST_DIR/history") read -r BB_NUM BB_DATE BB_DIR <<< "$BB_GREP_RET" @@ -35,17 +38,20 @@ function bashboard { local line local cnt + [ -f "$BB_HIST_DIR/history" ] || return + BB_SHORTCUT=() cnt=0 while read -r line; do read -r BB_NUM BB_DATE BB_DIR <<< "$line" - echo "[$cnt] ${BB_DIR##$HOME/}" + # Trailing / in $HOME + echo "[$cnt] ${BB_DIR##$HOME}" BB_SHORTCUT+=("$BB_DIR") cnt=$((cnt+1)) - done <<< "$(sort -nr "$BB_HIST_DIR/history" | head -n 5)" + done <<< "$(sort -nr "$BB_HIST_DIR/history" | head -n $BB_LIST_LEN)" # TODO recently used } @@ -59,4 +65,11 @@ function bb { cd "${BB_SHORTCUT[$1]}" || return } +function bb_prune { + # Older than... + # Folder exists? + # shorten list + return 1 +} + bashboard |