diff options
| author | Tslil Clingman <hiato1@gmail.com> | 2015-02-09 22:01:43 +0200 |
|---|---|---|
| committer | Tslil Clingman <hiato1@gmail.com> | 2015-02-09 22:01:43 +0200 |
| commit | 2f41a7e5f4f2aafbad7c2de51dd28e8abbb2ec71 (patch) | |
| tree | 263957b3cd5df86e0196f09c4cef8304b9946f32 | |
| parent | 835d4fbcd1261908b3ef6b82055dafecfa4fd4b0 (diff) | |
Using rlwrap for tab completion of directories!
| -rwxr-xr-x | ce | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1,14 +1,14 @@ #!/usr/bin/env sh # Smart directory changer using the power of grep ;) # source in a function j() { ce $*; cd `head -n 1 ~/.local/share/dir_lst` } -# or some such +# or some such. Depends on: sed, ed, rlwrap, grep [ "$1" = "$HOME" ] && echo $HOME && exit fl="$HOME/.local/share/dir_lst"; [ ! -f "$fl" ] && touch "$fl" [ "$2" = '!' ] && echo $1 && exit || \ ln=`grep -n "$1" "$fl" | head -n 1 | cut -d : -f 1` -if [ "$1" != "" ]; then if [ "$ln" != "" ]; then +if [ -n "$1" ]; then if [ -n "$ln" ]; then echo -e "$ln m0\n1p\nw" | ed -s "$fl" || echo \?; else -l=$1; while [ ! -d "$l" ]; do echo \?; read l; [ ${l:(-1)} != / ] && l+=/; done; -l=`echo "$l" | sed "s|^[^/]|$PWD/&|"`; +l=$1; while [ ! -d "$l" ]; do echo \?; l=$(rlwrap -P$PWD -co cat -); +[ ${l:(-1)} != / ] && l+=/; done; l=`echo "$l" | sed "s|^[^/]|$PWD/&|"`; echo -e "0i\n$l\n.\nw" | ed -s "$fl"; sed -i '43,$d' "$fl" fi; else echo -e "2 m0\nw" | ed -s "$fl"; fi; |
