瀏覽代碼

add sl function

Josh Bicking 6 年之前
父節點
當前提交
0cca402b76
共有 1 個文件被更改,包括 14 次插入0 次删除
  1. 14 0
      zsh/.zshrc

+ 14 - 0
zsh/.zshrc

@@ -113,6 +113,20 @@ alias emacs-term='\emacs -nw'
 # alias for vim muscle memory when quitting
 alias :q='exit'
 
+function sl_func() {
+    # sl - prints a mirror image of ls. (C) 2017 Tobias Girstmair, https://gir.st/, GPLv3
+    #
+    LEN=$(ls "$@" |wc -L) # get the length of the longest line
+
+    ls "$@" | rev | while read -r line
+    do
+      printf "%${LEN}.${LEN}s\\n" "$line" | sed 's/^\(\s\+\)\(\S\+\)/\2\1/'
+      done
+
+}
+
+alias sl=sl_func
+
 # vi bindings
 #bindkey -v
 #export KEYTIMEOUT=1