This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
bash [2013/05/08 17:55] k2patel [Bash Tips / Tricks] |
bash [2020/08/10 02:35] (current) |
||
---|---|---|---|
Line 271: | Line 271: | ||
</code> | </code> | ||
+ | |||
+ | ==== Bash alias and complition ==== | ||
+ | Using command completion for alias in bash. | ||
+ | <code bash ~/.bash_profile> | ||
+ | alias c='/usr/bin/ssh' | ||
+ | export HLIST | ||
+ | HLIST=`cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["` | ||
+ | HLIST="${HLIST} $(cat ~/.ssh/config | grep Host | awk '{print $2}' | grep -v \*)" | ||
+ | HLIST=$(echo ${HLIST} | sort | uniq) | ||
+ | complete -W "${HLIST}" c | ||
+ | </code> | ||
==== Control case ==== | ==== Control case ==== | ||
Line 402: | Line 413: | ||
c3 | c3 | ||
</code> | </code> | ||
- | [[ Link to Article | http://www.linkedin.com/groups/Tuesdays-tip-difference-between-if-3716796.S.236851680?view=&srchtype=discussedNews&gid=3716796&item=236851680&type=member&trk=eml-anet_dig-b_pd-ttl-cn&ut=0FCRGmx_LdW5I1 ]] | + | [[ http://www.linkedin.com/groups/Tuesdays-tip-difference-between-if-3716796.S.236851680?view=&srchtype=discussedNews&gid=3716796&item=236851680&type=member&trk=eml-anet_dig-b_pd-ttl-cn&ut=0FCRGmx_LdW5I1 | Link to Article ]] |
==== Networked Info ==== | ==== Networked Info ==== | ||