Skip to content

Instantly share code, notes, and snippets.

@chesio
Last active October 19, 2021 12:33

Revisions

  1. chesio revised this gist Oct 19, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions bash_aliases.sh
    Original file line number Diff line number Diff line change
    @@ -25,8 +25,8 @@ alias lesss='less -S'
    alias curl_headers='curl -s -I -X GET'
    # alias curl_headers='curl -s -D - -o /dev/null'

    # - get list of all URLs on the website
    alias wget_spider="wget --spider -r https://www.hpe.at 2>&1 | grep '^--' | awk '{ print $3 }' | grep -v '\.\(css\|js\|png\|gif\|jpg\|JPG\)$'"
    # - get list of all URLs on the website excluding asset files
    alias wget_spider="wget --spider -r https://www.hpe.at 2>&1 | grep '^--' | awk '{ print $3 }' | grep -v '\.\(css\|js\|png\|gif\|jpg\|jpeg\|webp\)$'"


    ## Git
  2. chesio revised this gist Oct 19, 2021. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion bash_aliases.sh
    Original file line number Diff line number Diff line change
    @@ -19,12 +19,15 @@ alias lfc='find . -maxdepth 1 -type d | while read -r dir; do printf "%s:\t" "$d
    alias lesss='less -S'


    ## cUrl
    ## curl and wget

    # - show response headers
    alias curl_headers='curl -s -I -X GET'
    # alias curl_headers='curl -s -D - -o /dev/null'

    # - get list of all URLs on the website
    alias wget_spider="wget --spider -r https://www.hpe.at 2>&1 | grep '^--' | awk '{ print $3 }' | grep -v '\.\(css\|js\|png\|gif\|jpg\|JPG\)$'"


    ## Git

  3. chesio revised this gist Feb 10, 2021. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions bash_aliases.sh
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,9 @@ alias lu='ls | xargs -d "\n" du -sh'
    # - [l]ist [u]sage [s]orted
    alias lus='ls | xargs -d "\n" du -sh | sort -hr'

    # - list file counts per directory
    alias lfc='find . -maxdepth 1 -type d | while read -r dir; do printf "%s:\t" "$dir"; find "$dir" -type f | wc -l; done'

    # - [less] with e[s]
    alias lesss='less -S'

  4. chesio revised this gist Jul 25, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions bash_aliases.sh
    Original file line number Diff line number Diff line change
    @@ -39,6 +39,8 @@ alias npm_list_flat='npm list --depth=0'

    # - convert Windows line endings with Unix line endings [i]n place (= needs filename)
    alias dos2unix='sed -i "s/\r//g"'
    # - convert Windows line endings in specific text files (CSS, HTML, JS, PHP and TXT) in current directory
    alias convert-line-endings="find . \( -name '*.css' -o -name '*.html' -o -name '*.js' -o -name '*.php' -o -name '*.txt' \) -type f -execdir sed -i 's/\r//g' '{}' +"

    # - drop any lines that are visually empty (ie. have only tabs and spaces)
    alias remove-empty-lines='sed "/^\s*$/d"'
  5. chesio revised this gist Dec 20, 2018. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions bash_aliases.sh
    Original file line number Diff line number Diff line change
    @@ -22,12 +22,14 @@ alias lesss='less -S'
    alias curl_headers='curl -s -I -X GET'
    # alias curl_headers='curl -s -D - -o /dev/null'

    # Git

    ## Git

    # - reset local commits, stash the changes, pull from remote and reapply them from stash
    alias reroll_local_commits='git reset --soft HEAD^ && git stash && git pull && git stash pop'

    # NPM

    ## NPM

    # - list installed packages without dependencies (append -g to display globally installed packages)
    alias npm_list_flat='npm list --depth=0'
  6. chesio renamed this gist Dec 20, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  7. chesio revised this gist Dec 20, 2018. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions .bash_aliases
    Original file line number Diff line number Diff line change
    @@ -22,6 +22,10 @@ alias lesss='less -S'
    alias curl_headers='curl -s -I -X GET'
    # alias curl_headers='curl -s -D - -o /dev/null'

    # Git

    # - reset local commits, stash the changes, pull from remote and reapply them from stash
    alias reroll_local_commits='git reset --soft HEAD^ && git stash && git pull && git stash pop'

    # NPM

  8. chesio revised this gist Nov 29, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion .bash_aliases
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ alias curl_headers='curl -s -I -X GET'

    # NPM

    # List installed packages without dependencies (append -g to display globally installed packages)
    # - list installed packages without dependencies (append -g to display globally installed packages)
    alias npm_list_flat='npm list --depth=0'


  9. chesio revised this gist Nov 29, 2018. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions .bash_aliases
    Original file line number Diff line number Diff line change
    @@ -23,6 +23,12 @@ alias curl_headers='curl -s -I -X GET'
    # alias curl_headers='curl -s -D - -o /dev/null'


    # NPM

    # List installed packages without dependencies (append -g to display globally installed packages)
    alias npm_list_flat='npm list --depth=0'


    ## Working with text files

    # - convert Windows line endings with Unix line endings [i]n place (= needs filename)
  10. chesio revised this gist Oct 2, 2018. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion .bash_aliases
    Original file line number Diff line number Diff line change
    @@ -23,11 +23,20 @@ alias curl_headers='curl -s -I -X GET'
    # alias curl_headers='curl -s -D - -o /dev/null'


    ## Random utils
    ## Working with text files

    # - convert Windows line endings with Unix line endings [i]n place (= needs filename)
    alias dos2unix='sed -i "s/\r//g"'

    # - drop any lines that are visually empty (ie. have only tabs and spaces)
    alias remove-empty-lines='sed "/^\s*$/d"'

    # - drop any lines that are (truly) empty
    alias remove-truly-empty-lines='sed "/^$/d"'


    ## Random utils

    # - pseudo random string (append length parameter)
    alias pseudorandomstring='< /dev/urandom tr -dc A-Z-a-z-0-9 | head -c'

  11. chesio revised this gist Sep 14, 2018. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions .bash_aliases
    Original file line number Diff line number Diff line change
    @@ -25,6 +25,9 @@ alias curl_headers='curl -s -I -X GET'

    ## Random utils

    # - convert Windows line endings with Unix line endings [i]n place (= needs filename)
    alias dos2unix='sed -i "s/\r//g"'

    # - pseudo random string (append length parameter)
    alias pseudorandomstring='< /dev/urandom tr -dc A-Z-a-z-0-9 | head -c'

  12. chesio revised this gist Jul 6, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion .bash_aliases
    Original file line number Diff line number Diff line change
    @@ -46,4 +46,4 @@ alias rsync_web='rsync -rltzv --delete'
    ## Sysadmin

    # Debian: list all services ([-] stopped or [+] running)
    list_services='service --status-all'
    alias list_services='service --status-all'
  13. chesio revised this gist Jul 6, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion .bash_aliases
    Original file line number Diff line number Diff line change
    @@ -46,4 +46,4 @@ alias rsync_web='rsync -rltzv --delete'
    ## Sysadmin

    # Debian: list all services ([-] stopped or [+] running)
    service --status-all
    list_services='service --status-all'
  14. chesio revised this gist Jul 6, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions .bash_aliases
    Original file line number Diff line number Diff line change
    @@ -42,6 +42,8 @@ alias rsync_repo='rsync -rtzv --delete --delete-excluded --exclude=".*"'
    # Params: -[r]ecursive -preserve sym[l]inks -preserve [t]imestamps -compre[z] -[v]erbose
    alias rsync_web='rsync -rltzv --delete'


    ## Sysadmin

    # Debian: list all services ([-] stopped or [+] running)
    service --status-all
  15. chesio revised this gist Jul 6, 2018. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions .bash_aliases
    Original file line number Diff line number Diff line change
    @@ -41,3 +41,7 @@ alias rsync_repo='rsync -rtzv --delete --delete-excluded --exclude=".*"'
    # Example: rsync_web ~/local/project_dir/ ~/remote/project_dir/web/
    # Params: -[r]ecursive -preserve sym[l]inks -preserve [t]imestamps -compre[z] -[v]erbose
    alias rsync_web='rsync -rltzv --delete'

    ## Sysadmin
    # Debian: list all services ([-] stopped or [+] running)
    service --status-all
  16. chesio created this gist Jun 24, 2018.
    43 changes: 43 additions & 0 deletions .bash_aliases
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    ## Working with shell

    # - [r]e[m]ove [d]irectory
    alias rmd='rm -rf'

    # - [l]ist in [h]uman format
    alias lh='ls -lh'

    # - [l]ist [u]sage
    alias lu='ls | xargs -d "\n" du -sh'

    # - [l]ist [u]sage [s]orted
    alias lus='ls | xargs -d "\n" du -sh | sort -hr'

    # - [less] with e[s]
    alias lesss='less -S'


    ## cUrl

    # - show response headers
    alias curl_headers='curl -s -I -X GET'
    # alias curl_headers='curl -s -D - -o /dev/null'


    ## Random utils

    # - pseudo random string (append length parameter)
    alias pseudorandomstring='< /dev/urandom tr -dc A-Z-a-z-0-9 | head -c'


    ## Syncing (and deploying)

    # Sync a (git) repository
    # Params: -[r]ecursive -preserve [t]imestamps -compre[z] -[v]erbose
    # Also, exclude any hidden files and directories.
    alias rsync_repo='rsync -rtzv --delete --delete-excluded --exclude=".*"'

    # Deploy web (development to production) via rsync
    # Note: add trailing slash to <src-dir> in order to sync directory contents rather than directory itself (adding trailing slash to <tgt-dir> makes no difference)
    # Example: rsync_web ~/local/project_dir/ ~/remote/project_dir/web/
    # Params: -[r]ecursive -preserve sym[l]inks -preserve [t]imestamps -compre[z] -[v]erbose
    alias rsync_web='rsync -rltzv --delete'