A simple love of the command line

milomak

Honorary Master
Joined
May 23, 2007
Messages
12,571
Reaction score
92
i am pirate . let's get over this now.

so i have sickbeard download the daily show and the colbert report in 720p.

so it ends up naming then in the form of Showname - YYYY-MM-DD.mkv

so i wanted to delete everything before august

a simple rm -rfv "Showname - YYYY-0[1-07]*" did the trick

oh this was on a computer i ssh'd into
 
Yeah command line is awesome for some things. Try do a clean and build in an IDE for 12 projects one after the other. Nope CLI rules here.
PS try "find -mtime"
 
cli rules for many things indeed. I like to take it one step further, and automate some things with scripts.

For example I found nntp getting shaped stupidly nowadays on my openweb account. So I moved my sabnzbd off to a VPS. After modifying a seedbox sync script, it works great, getting awesome speeds with rsync down to my download pc from the VPS, AND a single rsync connection causes even less latency than 20 nntp sessions. I get 5ms ingame latency to gaming servers while download full line speed.
 
cli rules for many things indeed. I like to take it one step further, and automate some things with scripts.

For example I found nntp getting shaped stupidly nowadays on my openweb account. So I moved my sabnzbd off to a VPS. After modifying a seedbox sync script, it works great, getting awesome speeds with rsync down to my download pc from the VPS, AND a single rsync connection causes even less latency than 20 nntp sessions. I get 5ms ingame latency to gaming servers while download full line speed.

You can also limit the speed in rsync:
Code:
--bwlimit=KBPS          limit I/O bandwidth; KBytes per second
 
You can also limit the speed in rsync:
Code:
--bwlimit=KBPS          limit I/O bandwidth; KBytes per second
Yup I know about that, it works wonders if that is your last option :)

That said, I am lucky enough to have a mikrotik router at home, which runs a QoS tree to make sure I lose as little latency as possible, however multiple connections still have their overhead vs a single connection.
 
Yeah command line is awesome for some things. Try do a clean and build in an IDE for 12 projects one after the other. Nope CLI rules here.
Never had an issue doing this in Visual Studio.
 
Dunno if relevant but today i discovered console2 for windows. This, combined with cygwin and zsh for cygwin has made me a very happy man. :)
 
This is what makes zsh for cygwin on windows awesome. :)
 
So you guys who love the command line? How many of you have switched over your user shell from bash to zsh?

I have, using GRML's config from grml.org with it and a few other scripts of my own. Must say, it makes working on the command line even better. For example, imagine typing a command, then use tab-auto-completion to help you auto-complete use flags for that specific command! Like, type "ls -l" then press tab, it will show you a list of possible use flags with a short description, you can even use the arrow keys to move to the flag and press enter to add it, then continue typing your command from there.

I also added a script, that when I use "CTRL + R" to search the history for a previous command I typed, it underlines the part you have typed so far, and then you can half way stop and start using page up and page down to page through the history of commands containing the part of text you typed thus far.
 
What's wrong with you guys, why nobody tell me about this zsh goody? :D

I just installed it and plonking around in it, only scraping the surface of it but it's pretty cool :cool:
 
Had to clean an ickdoze PC of a virus.

It was removed successfully, but there was tons of log files and quarantined files left behind.

Using the GUI took ages. :mad: :sick:

So I opened a CLI window, and got rid of the detritus without any big fuss :cool:
 
zsh by default is good, but what makes it awesome is how much you can customize it. A good default set of scripts to begin with, is with the grml.org configs, or easy on archlinux:
pacman -S grml-zsh-config

If you ever launched the archlinux install iso recently, they use zsh with grml's config as default.

His configs mostly overwrite user based ~/.zshrc so you want to add your own stuff to ~/.zshrc.local

I for example added this plugin: https://github.com/zsh-users/zsh-history-substring-search

And this is what my config on top of grml's config look:
Code:
tinuva@archnix ~ % cat .zshrc.local 
alias ls='ls --color=auto'

# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=10000000
SAVEHIST=10000000
# Appends every command to the history file once it is executed
setopt inc_append_history
# Reloads the history whenever you use it
setopt share_history
source zsh-history-substring-search.zsh


bindkey -e
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/home/tinuva/.zshrc'

autoload -Uz compinit
compinit
# End of lines added by compinstall

# Enable Gnome-Keyring SSH
SSH_AUTH_SOCK=`ss -xl | grep -o '/run/user/1000/keyring-.*/ssh'`
[ -z "$SSH_AUTH_SOCK" ] || export SSH_AUTH_SOCK

# arrow completion
zstyle ':completion:*' menu select

# commandline switches completion
setopt completealiases

# command not found hook
source /usr/share/doc/pkgfile/command-not-found.zsh

# create a zkbd compatible hash;
# to add other keys to this hash, see: man 5 terminfo
typeset -A key

key[Home]=${terminfo[khome]}

key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}

# setup key accordingly
[[ -n "${key[Home]}"    ]]  && bindkey  "${key[Home]}"    beginning-of-line
[[ -n "${key[End]}"     ]]  && bindkey  "${key[End]}"     end-of-line
[[ -n "${key[Insert]}"  ]]  && bindkey  "${key[Insert]}"  overwrite-mode
[[ -n "${key[Delete]}"  ]]  && bindkey  "${key[Delete]}"  delete-char
[[ -n "${key[Up]}"      ]]  && bindkey  "${key[Up]}"      up-line-or-history
[[ -n "${key[Down]}"    ]]  && bindkey  "${key[Down]}"    down-line-or-history
[[ -n "${key[Left]}"    ]]  && bindkey  "${key[Left]}"    backward-char
[[ -n "${key[Right]}"   ]]  && bindkey  "${key[Right]}"   forward-char

# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
    function zle-line-init () {
        printf '%s' "${terminfo[smkx]}"
    }
    function zle-line-finish () {
        printf '%s' "${terminfo[rmkx]}"
    }
    zle -N zle-line-init
    zle -N zle-line-finish
fi


# History
[[ -n "${key[PageUp]}"   ]]  && bindkey  "${key[PageUp]}"    history-beginning-search-backward
[[ -n "${key[PageDown]}" ]]  && bindkey  "${key[PageDown]}"  history-beginning-search-forward
 
Last edited:
Top
Sign up to the MyBroadband newsletter
X