learnbyexample

joined 1 year ago
 

I rarely ever use the date command, but when I need it I almost always struggle to get the right incantation. So, wrote a blog post for easy reference.

Do you use a cheatsheet as well?

[–] [email protected] 1 points 2 months ago (1 children)

Not my blog, just sharing it here.

That said, I don't see that broken rectangle on Chromium.

[–] [email protected] 2 points 3 months ago (1 children)

Is it regex or sed/awk syntax (or both) that gives you trouble?

I had similar reaction and didn't even try to learn them for years - then I caught the stackoverflow craze of answering CLI questions (and learning from others).

[–] [email protected] 9 points 3 months ago (1 children)

oxipng, pngquant and svgcleaner for optimizing images

auto-editor for removing silent portions from video recordings

[–] [email protected] 2 points 3 months ago

Not my blog, just sharing it here. Saw it on HN (https://news.ycombinator.com/item?id=40419325)

[–] [email protected] 1 points 5 months ago

Yeah, it is uncommon spelling, but if you google, you'll find it's not that rare ;)

[–] [email protected] 21 points 5 months ago* (last edited 5 months ago)

As per the manual, "Mappings are set up to work like most click-and-type editors" - which is best suited with GUI Vim.

While Vim doesn't make sense to use without the modes, there are plugins like https://github.com/tombh/novim-mode!

[–] [email protected] 4 points 8 months ago

See also: https://github.com/pllk/cphb (Competitive Programmer's Handbook)

[–] [email protected] 2 points 11 months ago

That's great to hear and thanks for the kind feedback :)

[–] [email protected] 8 points 11 months ago (1 children)
[–] [email protected] 1 points 1 year ago

I used to use it for posting on Twitter, with some keywords (like book title) in bold.

[–] [email protected] 7 points 1 year ago* (last edited 1 year ago) (2 children)
alias a='alias'

a c='clear'
a p='pwd'
a e='exit'
a q='exit'

a h='history | tail -n20'
# turn off history, use 'set -o history' to turn it on again
a so='set +o history'

a b1='cd ../'
a b2='cd ../../'
a b3='cd ../../../'
a b4='cd ../../../../'
a b5='cd ../../../../../'

a ls='ls --color=auto'
a l='ls -ltrhG'
a la='l -A'
a vi='gvim'
a grep='grep --color=auto'

# open and source aliases
a oa='vi ~/.bash_aliases'
a sa='source ~/.bash_aliases'

# sort file/directory sizes in current directory in human readable format
a s='du -sh -- * | sort -h'

# save last command from history to a file
# tip, add a comment to end of command before saving, ex: ls --color=auto # colored ls output
a sl='fc -ln -1 | sed "s/^\s*//" >> ~/.saved_commands.txt'
# short-cut to grep that file
a slg='< ~/.saved_commands.txt grep'

# change ascii alphabets to unicode bold characters
a ascii2bold="perl -Mopen=locale -Mutf8 -pe 'tr/a-zA-Z/𝗮-𝘇𝗔-𝗭/'"

### functions
# 'command help' for command name and single option - ex: ch ls -A
# see https://github.com/learnbyexample/command_help for a better script version
ch() { whatis $1; man $1 | sed -n "/^\s*$2/,/^$/p" ; }

# add path to filename(s)
# usage: ap file1 file2 etc
ap() { for f in "$@"; do echo "$PWD/$f"; done; }

# simple case-insensitive file search based on name
# usage: fs name
# remove '-type f' if you want to match directories as well
fs() { find -type f -iname '*'"$1"'*' ; }

# open files with default application, don't print output/error messages
# useful for opening docs, pdfs, images, etc from command line
o() { xdg-open "$@" &> /dev/null ; }

# if unix2dos and dos2unix commands aren't available by default
unix2dos() { sed -i 's/$/\r/' "$@" ; }
dos2unix() { sed -i 's/\r$//' "$@" ; }
view more: next ›