Last active
November 29, 2022 07:02
-
-
Save Esonhugh/c2e76a25db96fc7f4505826b66456e7e to your computer and use it in GitHub Desktop.
not worry you cat a dir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Esonhugh | |
# update date: 2021/11/28 | |
# | |
# c is an alias for clear cd and cat | |
# c with no param will clear | |
# c with one param(file) will like a cat a file | |
# c with one param(dir) will like cd into dir | |
# experimental: if c has more params will cat this all like cat command (finished) | |
# logic is | |
# 1. clear and cd doesn't have second param. if second param exists must cat | |
# 2. if 1 is False, Conditions are param number is 1 or 0. | |
# 3. in condition (param num is 0)clear has no param just clear the screen in terminal | |
# 4. test the param 1 is file or dictionary | |
# 5. dic is cd | |
# 6. file is cat | |
function c () { | |
if [ -n "$2" ] | |
then | |
\cat $* | |
elif [ -z "$1" ] | |
then | |
\clear | |
else | |
if [ -f "$1" ] | |
then | |
\cat "$1" | |
elif [ -d "$1" ] | |
then | |
\cd "$1" | |
else | |
echo "\033[1m $1\033[0m is error name to file or dir" | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage should be like:
add in .zshrc / .bashrc / other profile on your system
or
add in one shell
and source it in the profile on your system