How can I format the output of a bash command in neat columns

column(1) is your friend. $ column -t <<< ‘”option-y” yank-pop > “option-z” execute-last-named-cmd > “option-|” vi-goto-column > “option-~” _bash_complete-word > “option-control-?” backward-kill-word > “control-_” undo > “control-?” backward-delete-char > ‘ “option-y” yank-pop “option-z” execute-last-named-cmd “option-|” vi-goto-column “option-~” _bash_complete-word “option-control-?” backward-kill-word “control-_” undo “control-?” backward-delete-char

Conda command not found

If you’re using zsh and it has not been set up to read .bashrc, you need to add the Miniconda directory to the zsh shell PATH environment variable. Add this to your .zshrc: export PATH=”/home/username/miniconda/bin:$PATH” Make sure to replace /home/username/miniconda with your actual path. Save, exit the terminal and then reopen the terminal. conda command … Read more

Can I alias a subcommand? (shortening the output of `docker ps`)

You can wrap docker in a function that checks for the specific subcommand and passes everything else through. (The below will actually work with not just zsh, but any POSIX-compliant shell — a category to which zsh doesn’t quite belong). docker() { case $1 in ps) shift command docker ps –format ‘table {{.Image}}\t{{.Names}}\t{{.Ports}}\t{{.Status}}’ “$@” ;; … Read more

bash command not found when setting a variable

You define variables with var=string or var=$(command). So you have to remove the leading $ and any other signs around =: tag_name=”proddeploy-$(date +”%Y%m%d_%H%M”)” deploy_date=$(date +”%Y%m%d_%H%M”) ^^ ^ From Command substitution: The second form `COMMAND` is more or less obsolete for Bash, since it has some trouble with nesting (“inner” backticks need to be escaped) and … Read more

Adding a new entry to the PATH variable in ZSH

Actually, using ZSH allows you to use special mapping of environment variables. So you can simply do: # append path+=(‘/home/david/pear/bin’) # or prepend path=(‘/home/david/pear/bin’ $path) # export to sub-processes (make it inherited by child processes) export PATH For me that’s a very neat feature which can be propagated to other variables. Example: typeset -T LD_LIBRARY_PATH … Read more