Cool Terminal Tools

fkill-cli

Repo

This terminal gui helps you kill apllications and free up ports easily.
You can use an interactive gui to select the application you want to kill or provide an argument.

Previously i had to use something like this to find the pid of the program that uses a port.

1
2
3
port=8080
pidofprocess=$(lsof -i:"$port" -t)
kill -9 $pidofprocess

Now i can use a single program to browse programs or free up ports.

1
2
3
4
5
6
7
8
# Kill the process that uses port 8080
fkill :8080

# Kill spotify
fkill spotify

# Browse programs to kill
fkill

at

Examples

This program lets you time basically anything.

Typically you would use it like this:

1
echo "script.sh" | at now + 1 hour

With notify send i created a small reminder script.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash
#===============================================================================
#
# FILE: remind
#
# USAGE: remind "match starting" 14:00
#
# DESCRIPTION: reminds you about the set topic at the set time
# REQUIREMENTS: notify-send
# BUGS: ---
# NOTES: only supports single at parameters
# AUTHOR: Peter Forgacs (), peter@sexybuddha.hu
# ORGANIZATION:
# CREATED:
# REVISION: 1.0.0
#===============================================================================

set -o nounset # Treat unset variables as an error
remind(){
echo "notify-send "" "$1" | at "$2"
}

remind "$1" "$2"

fzf

Repo

Command line fuzzy finder.
This provides a selectable, searchable list for anything.

Usage:

1
fd -t f | fzf

By default it seems verbose to type out but you can set pretty advanced default config that works most of the time.

I have placed this in my fish config.

1
2
3
4
5
# Show the contents of the files and color the output with coderay
set -xg FZF_DEFAULT_OPTS "-m --reverse --preview 'head -100 {} | coderay { }'"

# Search files when given no arguments
set -xg FZF_DEFAULT_COMMAND "find * -type f"

You can do the same in your .bashrc.

With these settings fireing up the fzf command shows this and searches downward the current directory.

With the -m flag you can select multiple files with the tab button end send the selected paths to stdout.

Some exapmle usages.

1
2
3
4
5
6
7
8
# Select commands from your history to create a script
history | fzf > script.sh

# Open mutliple files
fd -t f | fzf | xargs vim

# Download some links from a file
cat links.txt | fzf | xargs wget

fd

Repo

I think it has a much nicer syntax then the default find. It supposed to be faster as well.

1
2
3
4
fd -t f 		# Find files recursively
fd -t f -d 0 # Find files in the current directory
fd -t d # Find directories reursively
fd -e .js # Find .js files

Previous commands and arguments

Stack Overflow

This is a really cool thread that shows how the reuse previous commands and arguments.

1
2
3
4
5
6
!! 	- Previous line
!:0 - Previous command
!:1 - Previous first argument
!:2 - Previous second argument
!:1-2 - Previous first and second argument
!:1-$ - Previus first to last argument

An other nice trick is that you can also specify a command number from history and reapply it.

1
!3313

Pure bash bible

Repo

This is a really cool list of functions and best practices for writing bash scripts.