summaryrefslogtreecommitdiff
path: root/ce
diff options
context:
space:
mode:
authortslil clingman <>2019-02-01 22:08:47 -0500
committertslil clingman <>2019-02-01 22:08:47 -0500
commit2e40486ec6b5c8b2d0880a81ae116a204dbb7f5e (patch)
tree7450a759e9bbaab168f64c7ad87e926dd1d0cd88 /ce
parentd8fae3962161863441ac632ef7b29bb6d3e98854 (diff)
Trimmed ce a little, there was also an issue with echo -e
Diffstat (limited to 'ce')
-rwxr-xr-xce16
1 files changed, 7 insertions, 9 deletions
diff --git a/ce b/ce
index e53bdcf..db21013 100755
--- a/ce
+++ b/ce
@@ -2,13 +2,11 @@
# 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. Depends on: sed, ed, rlwrap, grep
-[ "$1" = "$HOME" ] && echo $HOME && exit
-fl="$HOME/.local/share/dir_lst"; [ ! -f "$fl" ] && touch "$fl"
+[ "$1" = "$HOME" ] && echo $HOME && exit ;
+fl="$HOME/.local/share/dir_lst"; [ ! -f "$fl" ] && echo "\n" > "$fl"
[ "$2" = '!' ] && echo $1 && exit || \
-ln=`grep -n "$1" "$fl" | head -n 1 | cut -d : -f 1`
-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 \?; 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;
+ln=`grep -n "$1" "$fl" | head -n 1 | cut -d : -f 1`; if [ -n "$1" ]; then
+if [ -n "$ln" ]; then echo "$ln m0\n1p\nw" | ed -s "$fl" || echo \?;
+else l="$1"; while [ ! -d "$l" ]; do echo \?; l="$(rlwrap -P$PWD/ -co cat -)";
+done; echo "0i\n$l\n.\nw" | ed -s "$fl"; sed -i '43,$d' "$fl"; fi; else
+echo "2 m0\nw" | ed -s "$fl"; fi